Skip to content

Commit af35233

Browse files
committed
atmel-samd: Add support for SAM E54 family MCUs
This introduces the new macro SAM_D5X_E5X. This is mostly the same as SAMD51 before, except in a few places where a special case for SAME54 is required
1 parent 0b99bac commit af35233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13242
-143
lines changed

ports/atmel-samd/Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ CFLAGS += -Os -DNDEBUG
9797
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
9898
endif
9999

100+
ifeq ($(CHIP_FAMILY), same54)
101+
CFLAGS += -Os -DNDEBUG
102+
# TinyUSB defines
103+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
104+
endif
105+
100106
#Debugging/Optimization
101107
ifeq ($(DEBUG), 1)
102108
CFLAGS += -ggdb
@@ -152,7 +158,16 @@ CFLAGS += \
152158
-mcpu=cortex-m4 \
153159
-mfloat-abi=hard \
154160
-mfpu=fpv4-sp-d16 \
155-
-DSAMD51
161+
-DSAM_D5X_E5X -DSAMD51
162+
endif
163+
ifeq ($(CHIP_FAMILY), same54)
164+
CFLAGS += \
165+
-mthumb \
166+
-mabi=aapcs-linux \
167+
-mcpu=cortex-m4 \
168+
-mfloat-abi=hard \
169+
-mfpu=fpv4-sp-d16 \
170+
-DSAM_D5X_E5X -DSAME54
156171
endif
157172

158173

@@ -171,6 +186,9 @@ BOOTLOADER_SIZE := 0x2000
171186
else ifeq ($(CHIP_FAMILY), samd51)
172187
LDFLAGS += -mthumb -mcpu=cortex-m4
173188
BOOTLOADER_SIZE := 0x4000
189+
else ifeq ($(CHIP_FAMILY), same54)
190+
LDFLAGS += -mthumb -mcpu=cortex-m4
191+
BOOTLOADER_SIZE := 0x4000
174192
endif
175193

176194
SRC_ASF := \
@@ -213,6 +231,15 @@ SRC_ASF += \
213231
hpl/oscctrl/hpl_oscctrl.c \
214232
hpl/trng/hpl_trng.c \
215233

234+
else ifeq ($(CHIP_FAMILY), same54)
235+
SRC_ASF += \
236+
hal/src/hal_rand_sync.c \
237+
hpl/core/hpl_core_m4.c \
238+
hpl/mclk/hpl_mclk.c \
239+
hpl/osc32kctrl/hpl_osc32kctrl.c \
240+
hpl/oscctrl/hpl_oscctrl.c \
241+
hpl/trng/hpl_trng.c \
242+
216243
endif
217244

218245
SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))

ports/atmel-samd/asf4

Submodule asf4 updated 409 files
Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
/* Auto-generated config file hpl_adc_config.h */
2+
#ifndef HPL_ADC_CONFIG_H
3+
#define HPL_ADC_CONFIG_H
4+
5+
// <<< Use Configuration Wizard in Context Menu >>>
6+
7+
#ifndef CONF_ADC_0_ENABLE
8+
#define CONF_ADC_0_ENABLE 1
9+
#endif
10+
11+
// <h> Basic Configuration
12+
13+
// <o> Conversion Result Resolution
14+
// <0x0=>12-bit
15+
// <0x1=>16-bit (averaging must be enabled)
16+
// <0x2=>10-bit
17+
// <0x3=>8-bit
18+
// <i> Defines the bit resolution for the ADC sample values (RESSEL)
19+
// <id> adc_resolution
20+
#ifndef CONF_ADC_0_RESSEL
21+
#define CONF_ADC_0_RESSEL 0x0
22+
#endif
23+
24+
// <o> Reference Selection
25+
// <0x0=>Internal bandgap reference
26+
// <0x2=>1/2 VDDANA (only for VDDANA > 2.0V)
27+
// <0x3=>VDDANA
28+
// <0x4=>External reference A
29+
// <0x5=>External reference B
30+
// <0x6=>External reference C
31+
// <i> Select the reference for the ADC (REFSEL)
32+
// <id> adc_reference
33+
#ifndef CONF_ADC_0_REFSEL
34+
#define CONF_ADC_0_REFSEL 0x0
35+
#endif
36+
37+
// <o> Prescaler configuration
38+
// <0x0=>Peripheral clock divided by 2
39+
// <0x1=>Peripheral clock divided by 4
40+
// <0x2=>Peripheral clock divided by 8
41+
// <0x3=>Peripheral clock divided by 16
42+
// <0x4=>Peripheral clock divided by 32
43+
// <0x5=>Peripheral clock divided by 64
44+
// <0x6=>Peripheral clock divided by 128
45+
// <0x7=>Peripheral clock divided by 256
46+
// <i> These bits define the ADC clock relative to the peripheral clock (PRESCALER)
47+
// <id> adc_prescaler
48+
#ifndef CONF_ADC_0_PRESCALER
49+
#define CONF_ADC_0_PRESCALER 0x3
50+
#endif
51+
52+
// <q> Free Running Mode
53+
// <i> When enabled, the ADC is in free running mode and a new conversion will be initiated when a previous conversion completes. (FREERUN)
54+
// <id> adc_freerunning_mode
55+
#ifndef CONF_ADC_0_FREERUN
56+
#define CONF_ADC_0_FREERUN 0
57+
#endif
58+
59+
// <q> Differential Mode
60+
// <i> In differential mode, the voltage difference between the MUXPOS and MUXNEG inputs will be converted by the ADC. (DIFFMODE)
61+
// <id> adc_differential_mode
62+
#ifndef CONF_ADC_0_DIFFMODE
63+
#define CONF_ADC_0_DIFFMODE 0
64+
#endif
65+
66+
// <o> Positive Mux Input Selection
67+
// <0x00=>ADC AIN0 pin
68+
// <0x01=>ADC AIN1 pin
69+
// <0x02=>ADC AIN2 pin
70+
// <0x03=>ADC AIN3 pin
71+
// <0x04=>ADC AIN4 pin
72+
// <0x05=>ADC AIN5 pin
73+
// <0x06=>ADC AIN6 pin
74+
// <0x07=>ADC AIN7 pin
75+
// <0x08=>ADC AIN8 pin
76+
// <0x09=>ADC AIN9 pin
77+
// <0x0A=>ADC AIN10 pin
78+
// <0x0B=>ADC AIN11 pin
79+
// <0x0C=>ADC AIN12 pin
80+
// <0x0D=>ADC AIN13 pin
81+
// <0x0E=>ADC AIN14 pin
82+
// <0x0F=>ADC AIN15 pin
83+
// <0x18=>1/4 scaled core supply
84+
// <0x19=>1/4 Scaled VBAT Supply
85+
// <0x1A=>1/4 scaled I/O supply
86+
// <0x1B=>Bandgap voltage
87+
// <0x1C=>Temperature reference (PTAT)
88+
// <0x1D=>Temperature reference (CTAT)
89+
// <0x1E=>DAC Output
90+
// <i> These bits define the Mux selection for the positive ADC input. (MUXPOS)
91+
// <id> adc_pinmux_positive
92+
#ifndef CONF_ADC_0_MUXPOS
93+
#define CONF_ADC_0_MUXPOS 0x0
94+
#endif
95+
96+
// <o> Negative Mux Input Selection
97+
// <0x00=>ADC AIN0 pin
98+
// <0x01=>ADC AIN1 pin
99+
// <0x02=>ADC AIN2 pin
100+
// <0x03=>ADC AIN3 pin
101+
// <0x04=>ADC AIN4 pin
102+
// <0x05=>ADC AIN5 pin
103+
// <0x06=>ADC AIN6 pin
104+
// <0x07=>ADC AIN7 pin
105+
// <0x18=>Internal ground
106+
// <0x19=>I/O ground
107+
// <i> These bits define the Mux selection for the negative ADC input. (MUXNEG)
108+
// <id> adc_pinmux_negative
109+
#ifndef CONF_ADC_0_MUXNEG
110+
#define CONF_ADC_0_MUXNEG 0x0
111+
#endif
112+
113+
// </h>
114+
115+
// <e> Advanced Configuration
116+
// <id> adc_advanced_settings
117+
#ifndef CONF_ADC_0_ADVANCED
118+
#define CONF_ADC_0_ADVANCED 0
119+
#endif
120+
121+
// <q> Run in standby
122+
// <i> Indicates whether the ADC will continue running in standby sleep mode or not (RUNSTDBY)
123+
// <id> adc_arch_runstdby
124+
#ifndef CONF_ADC_0_RUNSTDBY
125+
#define CONF_ADC_0_RUNSTDBY 0
126+
#endif
127+
128+
// <q>Debug Run
129+
// <i> If enabled, the ADC is running if the CPU is halted by an external debugger. (DBGRUN)
130+
// <id> adc_arch_dbgrun
131+
#ifndef CONF_ADC_0_DBGRUN
132+
#define CONF_ADC_0_DBGRUN 0
133+
#endif
134+
135+
// <q> On Demand Control
136+
// <i> Will keep the ADC peripheral running if requested by other peripherals (ONDEMAND)
137+
// <id> adc_arch_ondemand
138+
#ifndef CONF_ADC_0_ONDEMAND
139+
#define CONF_ADC_0_ONDEMAND 0
140+
#endif
141+
142+
// <q> Left-Adjusted Result
143+
// <i> When enabled, the ADC conversion result is left-adjusted in the RESULT register. The high byte of the 12-bit result will be present in the upper part of the result register. (LEFTADJ)
144+
// <id> adc_arch_leftadj
145+
#ifndef CONF_ADC_0_LEFTADJ
146+
#define CONF_ADC_0_LEFTADJ 0
147+
#endif
148+
149+
// <q> Reference Buffer Offset Compensation Enable
150+
// <i> The accuracy of the gain stage can be increased by enabling the reference buffer offset compensation. This will decrease the input impedance and thus increase the start-up time of the reference. (REFCOMP)
151+
// <id> adc_arch_refcomp
152+
#ifndef CONF_ADC_0_REFCOMP
153+
#define CONF_ADC_0_REFCOMP 0
154+
#endif
155+
156+
// <q>Comparator Offset Compensation Enable
157+
// <i> This bit indicates whether the Comparator Offset Compensation is enabled or not (OFFCOMP)
158+
// <id> adc_arch_offcomp
159+
#ifndef CONF_ADC_0_OFFCOMP
160+
#define CONF_ADC_0_OFFCOMP 0
161+
#endif
162+
163+
// <q> Digital Correction Logic Enabled
164+
// <i> When enabled, the ADC conversion result in the RESULT register is then corrected for gain and offset based on the values in the GAINCAL and OFFSETCAL registers. (CORREN)
165+
// <id> adc_arch_corren
166+
#ifndef CONF_ADC_0_CORREN
167+
#define CONF_ADC_0_CORREN 0
168+
#endif
169+
170+
// <o> Offset Correction Value <0-4095>
171+
// <i> If the digital correction logic is enabled (CTRLB.CORREN = 1), these bits define how the ADC conversion result is compensated for offset error before being written to the Result register. (OFFSETCORR)
172+
// <id> adc_arch_offsetcorr
173+
#ifndef CONF_ADC_0_OFFSETCORR
174+
#define CONF_ADC_0_OFFSETCORR 0
175+
#endif
176+
177+
// <o> Gain Correction Value <0-4095>
178+
// <i> If the digital correction logic is enabled (CTRLB.CORREN = 1), these bits define how the ADC conversion result is compensated for gain error before being written to the result register. (GAINCORR)
179+
// <id> adc_arch_gaincorr
180+
#ifndef CONF_ADC_0_GAINCORR
181+
#define CONF_ADC_0_GAINCORR 0
182+
#endif
183+
184+
// <o> Adjusting Result / Division Coefficient <0-7>
185+
// <i> These bits define the division coefficient in 2n steps. (ADJRES)
186+
// <id> adc_arch_adjres
187+
#ifndef CONF_ADC_0_ADJRES
188+
#define CONF_ADC_0_ADJRES 0x0
189+
#endif
190+
191+
// <o.0..10> Number of Samples to be Collected
192+
// <0x0=>1 sample
193+
// <0x1=>2 samples
194+
// <0x2=>4 samples
195+
// <0x3=>8 samples
196+
// <0x4=>16 samples
197+
// <0x5=>32 samples
198+
// <0x6=>64 samples
199+
// <0x7=>128 samples
200+
// <0x8=>256 samples
201+
// <0x9=>512 samples
202+
// <0xA=>1024 samples
203+
// <i> Define how many samples should be added together.The result will be available in the Result register (SAMPLENUM)
204+
// <id> adc_arch_samplenum
205+
#ifndef CONF_ADC_0_SAMPLENUM
206+
#define CONF_ADC_0_SAMPLENUM 0x0
207+
#endif
208+
209+
// <o> Sampling Time Length <0-63>
210+
// <i> These bits control the ADC sampling time in number of half CLK_ADC cycles, depending of the prescaler value, thus controlling the ADC input impedance. (SAMPLEN)
211+
// <id> adc_arch_samplen
212+
#ifndef CONF_ADC_0_SAMPLEN
213+
#define CONF_ADC_0_SAMPLEN 0
214+
#endif
215+
216+
// <o> Window Monitor Mode
217+
// <0x0=>No window mode
218+
// <0x1=>Mode 1: RESULT above lower threshold
219+
// <0x2=>Mode 2: RESULT beneath upper threshold
220+
// <0x3=>Mode 3: RESULT inside lower and upper threshold
221+
// <0x4=>Mode 4: RESULT outside lower and upper threshold
222+
// <i> These bits enable and define the window monitor mode. (WINMODE)
223+
// <id> adc_arch_winmode
224+
#ifndef CONF_ADC_0_WINMODE
225+
#define CONF_ADC_0_WINMODE 0x0
226+
#endif
227+
228+
// <o> Window Monitor Lower Threshold <0-65535>
229+
// <i> If the window monitor is enabled, these bits define the lower threshold value. (WINLT)
230+
// <id> adc_arch_winlt
231+
#ifndef CONF_ADC_0_WINLT
232+
#define CONF_ADC_0_WINLT 0
233+
#endif
234+
235+
// <o> Window Monitor Upper Threshold <0-65535>
236+
// <i> If the window monitor is enabled, these bits define the lower threshold value. (WINUT)
237+
// <id> adc_arch_winut
238+
#ifndef CONF_ADC_0_WINUT
239+
#define CONF_ADC_0_WINUT 0
240+
#endif
241+
242+
// <o> Bitmask for positive input sequence <0-4294967295>
243+
// <i> Use this parameter to input the bitmask for positive input sequence control (refer to datasheet for the device).
244+
// <id> adc_arch_seqen
245+
#ifndef CONF_ADC_0_SEQEN
246+
#define CONF_ADC_0_SEQEN 0x0
247+
#endif
248+
249+
// </e>
250+
251+
// <e> Event Control
252+
// <id> adc_arch_event_settings
253+
#ifndef CONF_ADC_0_EVENT_CONTROL
254+
#define CONF_ADC_0_EVENT_CONTROL 0
255+
#endif
256+
257+
// <q> Window Monitor Event Out
258+
// <i> Enables event output on window event (WINMONEO)
259+
// <id> adc_arch_winmoneo
260+
#ifndef CONF_ADC_0_WINMONEO
261+
#define CONF_ADC_0_WINMONEO 0
262+
#endif
263+
264+
// <q> Result Ready Event Out
265+
// <i> Enables event output on result ready event (RESRDEO)
266+
// <id> adc_arch_resrdyeo
267+
#ifndef CONF_ADC_0_RESRDYEO
268+
#define CONF_ADC_0_RESRDYEO 0
269+
#endif
270+
271+
// <q> Invert flush Event Signal
272+
// <i> Invert the flush event input signal (FLUSHINV)
273+
// <id> adc_arch_flushinv
274+
#ifndef CONF_ADC_0_FLUSHINV
275+
#define CONF_ADC_0_FLUSHINV 0
276+
#endif
277+
278+
// <q> Trigger Flush On Event
279+
// <i> Trigger an ADC pipeline flush on event (FLUSHEI)
280+
// <id> adc_arch_flushei
281+
#ifndef CONF_ADC_0_FLUSHEI
282+
#define CONF_ADC_0_FLUSHEI 0
283+
#endif
284+
285+
// <q> Invert Start Conversion Event Signal
286+
// <i> Invert the start conversion event input signal (STARTINV)
287+
// <id> adc_arch_startinv
288+
#ifndef CONF_ADC_0_STARTINV
289+
#define CONF_ADC_0_STARTINV 0
290+
#endif
291+
292+
// <q> Trigger Conversion On Event
293+
// <i> Trigger a conversion on event. (STARTEI)
294+
// <id> adc_arch_startei
295+
#ifndef CONF_ADC_0_STARTEI
296+
#define CONF_ADC_0_STARTEI 0
297+
#endif
298+
299+
// </e>
300+
301+
// <<< end of configuration section >>>
302+
303+
#endif // HPL_ADC_CONFIG_H

0 commit comments

Comments
 (0)