blob: beac040e0af338d07bc1750b9a6113f1eed2f3b0 [file] [log] [blame]
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001/* Auto-generated config file hpl_sercom_config.h */
2#ifndef HPL_SERCOM_CONFIG_H
3#define HPL_SERCOM_CONFIG_H
4
5// <<< Use Configuration Wizard in Context Menu >>>
6
7#include <peripheral_clk_config.h>
8
Kévin Redon1f8ecef2019-01-31 13:36:12 +01009#ifndef CONF_SERCOM_0_USART_ENABLE
10#define CONF_SERCOM_0_USART_ENABLE 1
11#endif
12
13// <h> Basic Configuration
14
15// <q> Receive buffer enable
16// <i> Enable input buffer in SERCOM module
17// <id> usart_rx_enable
18#ifndef CONF_SERCOM_0_USART_RXEN
19#define CONF_SERCOM_0_USART_RXEN 1
20#endif
21
22// <q> Transmitt buffer enable
23// <i> Enable output buffer in SERCOM module
24// <id> usart_tx_enable
25#ifndef CONF_SERCOM_0_USART_TXEN
26#define CONF_SERCOM_0_USART_TXEN 1
27#endif
28
29// <o> Frame parity
30// <0x1=>Even parity
31// <i> Parity bit mode for USART frame
32// <id> usart_parity
33#ifndef CONF_SERCOM_0_USART_PARITY
34#define CONF_SERCOM_0_USART_PARITY 1
35#endif
36
37// <o> Character Size
38// <0x0=>8 bits
39// <0x1=>9 bits
40// <0x5=>5 bits
41// <0x6=>6 bits
42// <0x7=>7 bits
43// <i> Data character size in USART frame
44// <id> usart_character_size
45#ifndef CONF_SERCOM_0_USART_CHSIZE
46#define CONF_SERCOM_0_USART_CHSIZE 0x0
47#endif
48
49// <o> Stop Bit
50// <0=>One stop bit
51// <1=>Two stop bits
52// <i> Number of stop bits in USART frame
53// <id> usart_stop_bit
54#ifndef CONF_SERCOM_0_USART_SBMODE
55#define CONF_SERCOM_0_USART_SBMODE 0
56#endif
57
58// <o> Baud rate <1-3000000>
59// <i> USART baud rate setting
60// <id> usart_baud_rate
61#ifndef CONF_SERCOM_0_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +020062#define CONF_SERCOM_0_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +010063#endif
64// </h>
65
66// <h> ISO7816 configuration
67// <o> ISO7816 Protocol Type
68// <0x1=> T=0
69// <0x0=> T=1
70// <i> Define ISO7816 protocol type as 0.
71// <id> usart_iso7816_type
72#ifndef CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T
73#define CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T 0x1
74#endif
75
76// <o> ISO7816 Inhibit Not Acknowledge
77// <0x0=> NACK is transmitted when a parity error is received.
78// <0x1=> NACK is not transmitted when a parity error is received.
79// <i> Define whether a NACK is transmitted when a parity error is received.
80// <id> usart_inack
81#ifndef CONF_SERCOM_0_USART_INACK
82#define CONF_SERCOM_0_USART_INACK 0x0
83#endif
84
85// <o> ISO7816 Disable Successive Not Acknowledge
86// <0x0=> The successive receive NACK is disable.
87// <0x1=> The successive receive NACK is enable.
88// <i> Define whether NACK will be sent on parity error reception.
89// <id> usart_dsnack
90#ifndef CONF_SERCOM_0_USART_DSNACK
91#define CONF_SERCOM_0_USART_DSNACK 0x0
92#endif
93
94// <o> ISO7816 Maximum Iterations<0-7>
95// <i> Define the maximum number of retransmit iterations.
96// <id> usart_maxiter
97#ifndef CONF_SERCOM_0_USART_MAXITER
98#define CONF_SERCOM_0_USART_MAXITER 0x7
99#endif
100
101// <o> ISO7816 Guard Time
102// <0x2=> 2-bit times
103// <0x3=> 3-bit times
104// <0x4=> 4-bit times
105// <0x5=> 5-bit times
106// <0x6=> 6-bit times
107// <0x7=> 7-bit times
108// <i> Define the guard time.
109// <id> usart_gtime
110#ifndef CONF_SERCOM_0_USART_GTIME
111#define CONF_SERCOM_0_USART_GTIME 0x2
112#endif
113
114// <q> Inverse transmission and reception enabled
115// <i> Define inverse transmission and reception enabled.
116// <id> usart_inverse_enabled
117#ifndef CONF_SERCOM_0_USART_INVERSE_ENABLED
118#define CONF_SERCOM_0_USART_INVERSE_ENABLED 0x0
119#endif
120
121#if (CONF_SERCOM_0_USART_INVERSE_ENABLED == 1)
122#define CONF_SERCOM_0_USART_RXINV 0x1
123#define CONF_SERCOM_0_USART_TXINV 0x1
124#else
125#define CONF_SERCOM_0_USART_RXINV 0x0
126#define CONF_SERCOM_0_USART_TXINV 0x0
127#endif
128
129// </h>
130
131// <e> Advanced configuration
132// <id> usart_advanced
133#ifndef CONF_SERCOM_0_USART_ADVANCED_CONFIG
134#define CONF_SERCOM_0_USART_ADVANCED_CONFIG 0
135#endif
136
137// <q> Run in stand-by
138// <i> Keep the module running in standby sleep mode
139// <id> usart_arch_runstdby
140#ifndef CONF_SERCOM_0_USART_RUNSTDBY
141#define CONF_SERCOM_0_USART_RUNSTDBY 0
142#endif
143
144// <q> Immediate Buffer Overflow Notification
145// <i> Controls when the BUFOVF status bit is asserted
146// <id> usart_arch_ibon
147#ifndef CONF_SERCOM_0_USART_IBON
148#define CONF_SERCOM_0_USART_IBON 0
149#endif
150
151// <q> Start of Frame Detection Enable
152// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
153// <id> usart_arch_sfde
154#ifndef CONF_SERCOM_0_USART_SFDE
155#define CONF_SERCOM_0_USART_SFDE 0
156#endif
157
158// <q> Collision Detection Enable
159// <i> Collision detection enable
160// <id> usart_arch_cloden
161#ifndef CONF_SERCOM_0_USART_CLODEN
162#define CONF_SERCOM_0_USART_CLODEN 0
163#endif
164
165// <o> Operating Mode
166// <0x1=>USART with internal clock
167// <i> Drive the shift register by an internal clock generated by the baud rate generator.
168// <id> usart_arch_clock_mode
169#ifndef CONF_SERCOM_0_USART_MODE
170#define CONF_SERCOM_0_USART_MODE 0x1
171#endif
172
173// <o> Data Order
174// <0=>MSB is transmitted first
175// <1=>LSB is transmitted first
176// <i> Data order of the data bits in the frame
177// <id> usart_arch_dord
178#ifndef CONF_SERCOM_0_USART_DORD
179#define CONF_SERCOM_0_USART_DORD 1
180#endif
181
182// <o> Debug Stop Mode
183// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
184// <0=>Keep running
185// <1=>Halt
186// <id> usart_arch_dbgstop
187#ifndef CONF_SERCOM_0_USART_DEBUG_STOP_MODE
188#define CONF_SERCOM_0_USART_DEBUG_STOP_MODE 0
189#endif
190
191// Does not do anything in USRT mode
192#define CONF_SERCOM_0_USART_SAMPR 0x0
193#define CONF_SERCOM_0_USART_SAMPA 0x0
194#define CONF_SERCOM_0_USART_FRACTIONAL 0x0
195
196// Does not do anything in UART mode
197#define CONF_SERCOM_0_USART_CPOL 0
198
199// Does not do anything in USRT mode
200#define CONF_SERCOM_0_USART_ENC 0
201
202// </e>
203
204#ifndef CONF_SERCOM_0_USART_CMODE
205#define CONF_SERCOM_0_USART_CMODE CONF_SERCOM_0_USART_ISO7816_PROTOCOL_T
206#endif
207
208/* RX is on PIN_PA04 */
209#ifndef CONF_SERCOM_0_USART_RXPO
210#define CONF_SERCOM_0_USART_RXPO 0
211#endif
212
213/* TX uses the same pin with RX */
214#ifndef CONF_SERCOM_0_USART_TXPO
215#define CONF_SERCOM_0_USART_TXPO 2
216#endif
217
218/* Set iso7816 mode */
219#define CONF_SERCOM_0_USART_PMODE (CONF_SERCOM_0_USART_PARITY - 1)
220#define CONF_SERCOM_0_USART_FORM 7
221
222#if CONF_SERCOM_0_USART_CMODE == 0
223// Calculate BAUD register value in UART mode
224#if CONF_SERCOM_0_USART_SAMPR == 0
225#ifndef CONF_SERCOM_0_USART_BAUD_RATE
226#define CONF_SERCOM_0_USART_BAUD_RATE \
227 65536 - ((65536 * 16.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
228#endif
229#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
230#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
231#endif
232#elif CONF_SERCOM_0_USART_SAMPR == 1
233#ifndef CONF_SERCOM_0_USART_BAUD_RATE
234#define CONF_SERCOM_0_USART_BAUD_RATE \
235 ((CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (CONF_SERCOM_0_USART_BAUD * 16)) - (CONF_SERCOM_0_USART_FRACTIONAL / 8)
236#endif
237#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
238#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
239#endif
240#elif CONF_SERCOM_0_USART_SAMPR == 2
241#ifndef CONF_SERCOM_0_USART_BAUD_RATE
242#define CONF_SERCOM_0_USART_BAUD_RATE \
243 65536 - ((65536 * 8.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
244#endif
245#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
246#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
247#endif
248#elif CONF_SERCOM_0_USART_SAMPR == 3
249#ifndef CONF_SERCOM_0_USART_BAUD_RATE
250#define CONF_SERCOM_0_USART_BAUD_RATE \
251 ((CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (CONF_SERCOM_0_USART_BAUD * 8)) - (CONF_SERCOM_0_USART_FRACTIONAL / 8)
252#endif
253#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
254#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
255#endif
256#elif CONF_SERCOM_0_USART_SAMPR == 4
257#ifndef CONF_SERCOM_0_USART_BAUD_RATE
258#define CONF_SERCOM_0_USART_BAUD_RATE \
259 65536 - ((65536 * 3.0f * CONF_SERCOM_0_USART_BAUD) / CONF_GCLK_SERCOM0_CORE_FREQUENCY)
260#endif
261#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
262#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
263#endif
264#endif
265
266#elif CONF_SERCOM_0_USART_CMODE == 1
267#ifndef CONF_SERCOM_0_USART_BAUD_RATE
268// Calculate BAUD register value in USRT mode
269#define CONF_SERCOM_0_USART_BAUD_RATE (CONF_GCLK_SERCOM0_CORE_FREQUENCY) / (2 * CONF_SERCOM_0_USART_BAUD) - 1
270#endif
271
272#ifndef CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH
273#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
274#endif
275#else
276#error CMODE value for SERCOM 0 in USART mode not known
277#endif
278
279#include <peripheral_clk_config.h>
280
281#ifndef CONF_SERCOM_1_USART_ENABLE
282#define CONF_SERCOM_1_USART_ENABLE 1
283#endif
284
285// <h> Basic Configuration
286
287// <q> Receive buffer enable
288// <i> Enable input buffer in SERCOM module
289// <id> usart_rx_enable
290#ifndef CONF_SERCOM_1_USART_RXEN
291#define CONF_SERCOM_1_USART_RXEN 1
292#endif
293
294// <q> Transmitt buffer enable
295// <i> Enable output buffer in SERCOM module
296// <id> usart_tx_enable
297#ifndef CONF_SERCOM_1_USART_TXEN
298#define CONF_SERCOM_1_USART_TXEN 1
299#endif
300
301// <o> Frame parity
302// <0x1=>Even parity
303// <i> Parity bit mode for USART frame
304// <id> usart_parity
305#ifndef CONF_SERCOM_1_USART_PARITY
306#define CONF_SERCOM_1_USART_PARITY 1
307#endif
308
309// <o> Character Size
310// <0x0=>8 bits
311// <0x1=>9 bits
312// <0x5=>5 bits
313// <0x6=>6 bits
314// <0x7=>7 bits
315// <i> Data character size in USART frame
316// <id> usart_character_size
317#ifndef CONF_SERCOM_1_USART_CHSIZE
318#define CONF_SERCOM_1_USART_CHSIZE 0x0
319#endif
320
321// <o> Stop Bit
322// <0=>One stop bit
323// <1=>Two stop bits
324// <i> Number of stop bits in USART frame
325// <id> usart_stop_bit
326#ifndef CONF_SERCOM_1_USART_SBMODE
327#define CONF_SERCOM_1_USART_SBMODE 0
328#endif
329
330// <o> Baud rate <1-3000000>
331// <i> USART baud rate setting
332// <id> usart_baud_rate
333#ifndef CONF_SERCOM_1_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +0200334#define CONF_SERCOM_1_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100335#endif
336// </h>
337
338// <h> ISO7816 configuration
339// <o> ISO7816 Protocol Type
340// <0x1=> T=0
341// <0x0=> T=1
342// <i> Define ISO7816 protocol type as 0.
343// <id> usart_iso7816_type
344#ifndef CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T
345#define CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T 0x1
346#endif
347
348// <o> ISO7816 Inhibit Not Acknowledge
349// <0x0=> NACK is transmitted when a parity error is received.
350// <0x1=> NACK is not transmitted when a parity error is received.
351// <i> Define whether a NACK is transmitted when a parity error is received.
352// <id> usart_inack
353#ifndef CONF_SERCOM_1_USART_INACK
354#define CONF_SERCOM_1_USART_INACK 0x0
355#endif
356
357// <o> ISO7816 Disable Successive Not Acknowledge
358// <0x0=> The successive receive NACK is disable.
359// <0x1=> The successive receive NACK is enable.
360// <i> Define whether NACK will be sent on parity error reception.
361// <id> usart_dsnack
362#ifndef CONF_SERCOM_1_USART_DSNACK
363#define CONF_SERCOM_1_USART_DSNACK 0x0
364#endif
365
366// <o> ISO7816 Maximum Iterations<0-7>
367// <i> Define the maximum number of retransmit iterations.
368// <id> usart_maxiter
369#ifndef CONF_SERCOM_1_USART_MAXITER
370#define CONF_SERCOM_1_USART_MAXITER 0x7
371#endif
372
373// <o> ISO7816 Guard Time
374// <0x2=> 2-bit times
375// <0x3=> 3-bit times
376// <0x4=> 4-bit times
377// <0x5=> 5-bit times
378// <0x6=> 6-bit times
379// <0x7=> 7-bit times
380// <i> Define the guard time.
381// <id> usart_gtime
382#ifndef CONF_SERCOM_1_USART_GTIME
383#define CONF_SERCOM_1_USART_GTIME 0x2
384#endif
385
386// <q> Inverse transmission and reception enabled
387// <i> Define inverse transmission and reception enabled.
388// <id> usart_inverse_enabled
389#ifndef CONF_SERCOM_1_USART_INVERSE_ENABLED
390#define CONF_SERCOM_1_USART_INVERSE_ENABLED 0x0
391#endif
392
393#if (CONF_SERCOM_1_USART_INVERSE_ENABLED == 1)
394#define CONF_SERCOM_1_USART_RXINV 0x1
395#define CONF_SERCOM_1_USART_TXINV 0x1
396#else
397#define CONF_SERCOM_1_USART_RXINV 0x0
398#define CONF_SERCOM_1_USART_TXINV 0x0
399#endif
400
401// </h>
402
403// <e> Advanced configuration
404// <id> usart_advanced
405#ifndef CONF_SERCOM_1_USART_ADVANCED_CONFIG
406#define CONF_SERCOM_1_USART_ADVANCED_CONFIG 0
407#endif
408
409// <q> Run in stand-by
410// <i> Keep the module running in standby sleep mode
411// <id> usart_arch_runstdby
412#ifndef CONF_SERCOM_1_USART_RUNSTDBY
413#define CONF_SERCOM_1_USART_RUNSTDBY 0
414#endif
415
416// <q> Immediate Buffer Overflow Notification
417// <i> Controls when the BUFOVF status bit is asserted
418// <id> usart_arch_ibon
419#ifndef CONF_SERCOM_1_USART_IBON
420#define CONF_SERCOM_1_USART_IBON 0
421#endif
422
423// <q> Start of Frame Detection Enable
424// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
425// <id> usart_arch_sfde
426#ifndef CONF_SERCOM_1_USART_SFDE
427#define CONF_SERCOM_1_USART_SFDE 0
428#endif
429
430// <q> Collision Detection Enable
431// <i> Collision detection enable
432// <id> usart_arch_cloden
433#ifndef CONF_SERCOM_1_USART_CLODEN
434#define CONF_SERCOM_1_USART_CLODEN 0
435#endif
436
437// <o> Operating Mode
438// <0x1=>USART with internal clock
439// <i> Drive the shift register by an internal clock generated by the baud rate generator.
440// <id> usart_arch_clock_mode
441#ifndef CONF_SERCOM_1_USART_MODE
442#define CONF_SERCOM_1_USART_MODE 0x1
443#endif
444
445// <o> Data Order
446// <0=>MSB is transmitted first
447// <1=>LSB is transmitted first
448// <i> Data order of the data bits in the frame
449// <id> usart_arch_dord
450#ifndef CONF_SERCOM_1_USART_DORD
451#define CONF_SERCOM_1_USART_DORD 1
452#endif
453
454// <o> Debug Stop Mode
455// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
456// <0=>Keep running
457// <1=>Halt
458// <id> usart_arch_dbgstop
459#ifndef CONF_SERCOM_1_USART_DEBUG_STOP_MODE
460#define CONF_SERCOM_1_USART_DEBUG_STOP_MODE 0
461#endif
462
463// Does not do anything in USRT mode
464#define CONF_SERCOM_1_USART_SAMPR 0x0
465#define CONF_SERCOM_1_USART_SAMPA 0x0
466#define CONF_SERCOM_1_USART_FRACTIONAL 0x0
467
468// Does not do anything in UART mode
469#define CONF_SERCOM_1_USART_CPOL 0
470
471// Does not do anything in USRT mode
472#define CONF_SERCOM_1_USART_ENC 0
473
474// </e>
475
476#ifndef CONF_SERCOM_1_USART_CMODE
477#define CONF_SERCOM_1_USART_CMODE CONF_SERCOM_1_USART_ISO7816_PROTOCOL_T
478#endif
479
480/* RX is on PIN_PA16 */
481#ifndef CONF_SERCOM_1_USART_RXPO
482#define CONF_SERCOM_1_USART_RXPO 0
483#endif
484
485/* TX uses the same pin with RX */
486#ifndef CONF_SERCOM_1_USART_TXPO
487#define CONF_SERCOM_1_USART_TXPO 2
488#endif
489
490/* Set iso7816 mode */
491#define CONF_SERCOM_1_USART_PMODE (CONF_SERCOM_1_USART_PARITY - 1)
492#define CONF_SERCOM_1_USART_FORM 7
493
494#if CONF_SERCOM_1_USART_CMODE == 0
495// Calculate BAUD register value in UART mode
496#if CONF_SERCOM_1_USART_SAMPR == 0
497#ifndef CONF_SERCOM_1_USART_BAUD_RATE
498#define CONF_SERCOM_1_USART_BAUD_RATE \
499 65536 - ((65536 * 16.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
500#endif
501#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
502#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
503#endif
504#elif CONF_SERCOM_1_USART_SAMPR == 1
505#ifndef CONF_SERCOM_1_USART_BAUD_RATE
506#define CONF_SERCOM_1_USART_BAUD_RATE \
507 ((CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (CONF_SERCOM_1_USART_BAUD * 16)) - (CONF_SERCOM_1_USART_FRACTIONAL / 8)
508#endif
509#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
510#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
511#endif
512#elif CONF_SERCOM_1_USART_SAMPR == 2
513#ifndef CONF_SERCOM_1_USART_BAUD_RATE
514#define CONF_SERCOM_1_USART_BAUD_RATE \
515 65536 - ((65536 * 8.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
516#endif
517#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
518#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
519#endif
520#elif CONF_SERCOM_1_USART_SAMPR == 3
521#ifndef CONF_SERCOM_1_USART_BAUD_RATE
522#define CONF_SERCOM_1_USART_BAUD_RATE \
523 ((CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (CONF_SERCOM_1_USART_BAUD * 8)) - (CONF_SERCOM_1_USART_FRACTIONAL / 8)
524#endif
525#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
526#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
527#endif
528#elif CONF_SERCOM_1_USART_SAMPR == 4
529#ifndef CONF_SERCOM_1_USART_BAUD_RATE
530#define CONF_SERCOM_1_USART_BAUD_RATE \
531 65536 - ((65536 * 3.0f * CONF_SERCOM_1_USART_BAUD) / CONF_GCLK_SERCOM1_CORE_FREQUENCY)
532#endif
533#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
534#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
535#endif
536#endif
537
538#elif CONF_SERCOM_1_USART_CMODE == 1
539#ifndef CONF_SERCOM_1_USART_BAUD_RATE
540// Calculate BAUD register value in USRT mode
541#define CONF_SERCOM_1_USART_BAUD_RATE (CONF_GCLK_SERCOM1_CORE_FREQUENCY) / (2 * CONF_SERCOM_1_USART_BAUD) - 1
542#endif
543
544#ifndef CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH
545#define CONF_SERCOM_1_USART_RECEIVE_PULSE_LENGTH 0
546#endif
547#else
548#error CMODE value for SERCOM 1 in USART mode not known
549#endif
550
551#include <peripheral_clk_config.h>
552
553#ifndef CONF_SERCOM_2_USART_ENABLE
554#define CONF_SERCOM_2_USART_ENABLE 1
555#endif
556
557// <h> Basic Configuration
558
559// <q> Receive buffer enable
560// <i> Enable input buffer in SERCOM module
561// <id> usart_rx_enable
562#ifndef CONF_SERCOM_2_USART_RXEN
563#define CONF_SERCOM_2_USART_RXEN 1
564#endif
565
566// <q> Transmitt buffer enable
567// <i> Enable output buffer in SERCOM module
568// <id> usart_tx_enable
569#ifndef CONF_SERCOM_2_USART_TXEN
570#define CONF_SERCOM_2_USART_TXEN 1
571#endif
572
573// <o> Frame parity
574// <0x1=>Even parity
575// <i> Parity bit mode for USART frame
576// <id> usart_parity
577#ifndef CONF_SERCOM_2_USART_PARITY
578#define CONF_SERCOM_2_USART_PARITY 1
579#endif
580
581// <o> Character Size
582// <0x0=>8 bits
583// <0x1=>9 bits
584// <0x5=>5 bits
585// <0x6=>6 bits
586// <0x7=>7 bits
587// <i> Data character size in USART frame
588// <id> usart_character_size
589#ifndef CONF_SERCOM_2_USART_CHSIZE
590#define CONF_SERCOM_2_USART_CHSIZE 0x0
591#endif
592
593// <o> Stop Bit
594// <0=>One stop bit
595// <1=>Two stop bits
596// <i> Number of stop bits in USART frame
597// <id> usart_stop_bit
598#ifndef CONF_SERCOM_2_USART_SBMODE
599#define CONF_SERCOM_2_USART_SBMODE 0
600#endif
601
602// <o> Baud rate <1-3000000>
603// <i> USART baud rate setting
604// <id> usart_baud_rate
605#ifndef CONF_SERCOM_2_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +0200606#define CONF_SERCOM_2_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100607#endif
608// </h>
609
610// <h> ISO7816 configuration
611// <o> ISO7816 Protocol Type
612// <0x1=> T=0
613// <0x0=> T=1
614// <i> Define ISO7816 protocol type as 0.
615// <id> usart_iso7816_type
616#ifndef CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T
617#define CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T 0x1
618#endif
619
620// <o> ISO7816 Inhibit Not Acknowledge
621// <0x0=> NACK is transmitted when a parity error is received.
622// <0x1=> NACK is not transmitted when a parity error is received.
623// <i> Define whether a NACK is transmitted when a parity error is received.
624// <id> usart_inack
625#ifndef CONF_SERCOM_2_USART_INACK
626#define CONF_SERCOM_2_USART_INACK 0x0
627#endif
628
629// <o> ISO7816 Disable Successive Not Acknowledge
630// <0x0=> The successive receive NACK is disable.
631// <0x1=> The successive receive NACK is enable.
632// <i> Define whether NACK will be sent on parity error reception.
633// <id> usart_dsnack
634#ifndef CONF_SERCOM_2_USART_DSNACK
635#define CONF_SERCOM_2_USART_DSNACK 0x0
636#endif
637
638// <o> ISO7816 Maximum Iterations<0-7>
639// <i> Define the maximum number of retransmit iterations.
640// <id> usart_maxiter
641#ifndef CONF_SERCOM_2_USART_MAXITER
642#define CONF_SERCOM_2_USART_MAXITER 0x7
643#endif
644
645// <o> ISO7816 Guard Time
646// <0x2=> 2-bit times
647// <0x3=> 3-bit times
648// <0x4=> 4-bit times
649// <0x5=> 5-bit times
650// <0x6=> 6-bit times
651// <0x7=> 7-bit times
652// <i> Define the guard time.
653// <id> usart_gtime
654#ifndef CONF_SERCOM_2_USART_GTIME
655#define CONF_SERCOM_2_USART_GTIME 0x2
656#endif
657
658// <q> Inverse transmission and reception enabled
659// <i> Define inverse transmission and reception enabled.
660// <id> usart_inverse_enabled
661#ifndef CONF_SERCOM_2_USART_INVERSE_ENABLED
662#define CONF_SERCOM_2_USART_INVERSE_ENABLED 0x0
663#endif
664
665#if (CONF_SERCOM_2_USART_INVERSE_ENABLED == 1)
666#define CONF_SERCOM_2_USART_RXINV 0x1
667#define CONF_SERCOM_2_USART_TXINV 0x1
668#else
669#define CONF_SERCOM_2_USART_RXINV 0x0
670#define CONF_SERCOM_2_USART_TXINV 0x0
671#endif
672
673// </h>
674
675// <e> Advanced configuration
676// <id> usart_advanced
677#ifndef CONF_SERCOM_2_USART_ADVANCED_CONFIG
678#define CONF_SERCOM_2_USART_ADVANCED_CONFIG 0
679#endif
680
681// <q> Run in stand-by
682// <i> Keep the module running in standby sleep mode
683// <id> usart_arch_runstdby
684#ifndef CONF_SERCOM_2_USART_RUNSTDBY
685#define CONF_SERCOM_2_USART_RUNSTDBY 0
686#endif
687
688// <q> Immediate Buffer Overflow Notification
689// <i> Controls when the BUFOVF status bit is asserted
690// <id> usart_arch_ibon
691#ifndef CONF_SERCOM_2_USART_IBON
692#define CONF_SERCOM_2_USART_IBON 0
693#endif
694
695// <q> Start of Frame Detection Enable
696// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
697// <id> usart_arch_sfde
698#ifndef CONF_SERCOM_2_USART_SFDE
699#define CONF_SERCOM_2_USART_SFDE 0
700#endif
701
702// <q> Collision Detection Enable
703// <i> Collision detection enable
704// <id> usart_arch_cloden
705#ifndef CONF_SERCOM_2_USART_CLODEN
706#define CONF_SERCOM_2_USART_CLODEN 0
707#endif
708
709// <o> Operating Mode
710// <0x1=>USART with internal clock
711// <i> Drive the shift register by an internal clock generated by the baud rate generator.
712// <id> usart_arch_clock_mode
713#ifndef CONF_SERCOM_2_USART_MODE
714#define CONF_SERCOM_2_USART_MODE 0x1
715#endif
716
717// <o> Data Order
718// <0=>MSB is transmitted first
719// <1=>LSB is transmitted first
720// <i> Data order of the data bits in the frame
721// <id> usart_arch_dord
722#ifndef CONF_SERCOM_2_USART_DORD
723#define CONF_SERCOM_2_USART_DORD 1
724#endif
725
726// <o> Debug Stop Mode
727// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
728// <0=>Keep running
729// <1=>Halt
730// <id> usart_arch_dbgstop
731#ifndef CONF_SERCOM_2_USART_DEBUG_STOP_MODE
732#define CONF_SERCOM_2_USART_DEBUG_STOP_MODE 0
733#endif
734
735// Does not do anything in USRT mode
736#define CONF_SERCOM_2_USART_SAMPR 0x0
737#define CONF_SERCOM_2_USART_SAMPA 0x0
738#define CONF_SERCOM_2_USART_FRACTIONAL 0x0
739
740// Does not do anything in UART mode
741#define CONF_SERCOM_2_USART_CPOL 0
742
743// Does not do anything in USRT mode
744#define CONF_SERCOM_2_USART_ENC 0
745
746// </e>
747
748#ifndef CONF_SERCOM_2_USART_CMODE
749#define CONF_SERCOM_2_USART_CMODE CONF_SERCOM_2_USART_ISO7816_PROTOCOL_T
750#endif
751
752/* RX is on PIN_PA09 */
753#ifndef CONF_SERCOM_2_USART_RXPO
754#define CONF_SERCOM_2_USART_RXPO 0
755#endif
756
757/* TX uses the same pin with RX */
758#ifndef CONF_SERCOM_2_USART_TXPO
759#define CONF_SERCOM_2_USART_TXPO 2
760#endif
761
762/* Set iso7816 mode */
763#define CONF_SERCOM_2_USART_PMODE (CONF_SERCOM_2_USART_PARITY - 1)
764#define CONF_SERCOM_2_USART_FORM 7
765
766#if CONF_SERCOM_2_USART_CMODE == 0
767// Calculate BAUD register value in UART mode
768#if CONF_SERCOM_2_USART_SAMPR == 0
769#ifndef CONF_SERCOM_2_USART_BAUD_RATE
770#define CONF_SERCOM_2_USART_BAUD_RATE \
771 65536 - ((65536 * 16.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
772#endif
773#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
774#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
775#endif
776#elif CONF_SERCOM_2_USART_SAMPR == 1
777#ifndef CONF_SERCOM_2_USART_BAUD_RATE
778#define CONF_SERCOM_2_USART_BAUD_RATE \
779 ((CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (CONF_SERCOM_2_USART_BAUD * 16)) - (CONF_SERCOM_2_USART_FRACTIONAL / 8)
780#endif
781#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
782#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
783#endif
784#elif CONF_SERCOM_2_USART_SAMPR == 2
785#ifndef CONF_SERCOM_2_USART_BAUD_RATE
786#define CONF_SERCOM_2_USART_BAUD_RATE \
787 65536 - ((65536 * 8.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
788#endif
789#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
790#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
791#endif
792#elif CONF_SERCOM_2_USART_SAMPR == 3
793#ifndef CONF_SERCOM_2_USART_BAUD_RATE
794#define CONF_SERCOM_2_USART_BAUD_RATE \
795 ((CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (CONF_SERCOM_2_USART_BAUD * 8)) - (CONF_SERCOM_2_USART_FRACTIONAL / 8)
796#endif
797#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
798#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
799#endif
800#elif CONF_SERCOM_2_USART_SAMPR == 4
801#ifndef CONF_SERCOM_2_USART_BAUD_RATE
802#define CONF_SERCOM_2_USART_BAUD_RATE \
803 65536 - ((65536 * 3.0f * CONF_SERCOM_2_USART_BAUD) / CONF_GCLK_SERCOM2_CORE_FREQUENCY)
804#endif
805#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
806#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
807#endif
808#endif
809
810#elif CONF_SERCOM_2_USART_CMODE == 1
811#ifndef CONF_SERCOM_2_USART_BAUD_RATE
812// Calculate BAUD register value in USRT mode
813#define CONF_SERCOM_2_USART_BAUD_RATE (CONF_GCLK_SERCOM2_CORE_FREQUENCY) / (2 * CONF_SERCOM_2_USART_BAUD) - 1
814#endif
815
816#ifndef CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH
817#define CONF_SERCOM_2_USART_RECEIVE_PULSE_LENGTH 0
818#endif
819#else
820#error CMODE value for SERCOM 2 in USART mode not known
821#endif
822
823#include <peripheral_clk_config.h>
824
825#ifndef CONF_SERCOM_3_USART_ENABLE
826#define CONF_SERCOM_3_USART_ENABLE 1
827#endif
828
829// <h> Basic Configuration
830
831// <q> Receive buffer enable
832// <i> Enable input buffer in SERCOM module
833// <id> usart_rx_enable
834#ifndef CONF_SERCOM_3_USART_RXEN
835#define CONF_SERCOM_3_USART_RXEN 1
836#endif
837
838// <q> Transmitt buffer enable
839// <i> Enable output buffer in SERCOM module
840// <id> usart_tx_enable
841#ifndef CONF_SERCOM_3_USART_TXEN
842#define CONF_SERCOM_3_USART_TXEN 1
843#endif
844
845// <o> Frame parity
846// <0x1=>Even parity
847// <i> Parity bit mode for USART frame
848// <id> usart_parity
849#ifndef CONF_SERCOM_3_USART_PARITY
850#define CONF_SERCOM_3_USART_PARITY 1
851#endif
852
853// <o> Character Size
854// <0x0=>8 bits
855// <0x1=>9 bits
856// <0x5=>5 bits
857// <0x6=>6 bits
858// <0x7=>7 bits
859// <i> Data character size in USART frame
860// <id> usart_character_size
861#ifndef CONF_SERCOM_3_USART_CHSIZE
862#define CONF_SERCOM_3_USART_CHSIZE 0x0
863#endif
864
865// <o> Stop Bit
866// <0=>One stop bit
867// <1=>Two stop bits
868// <i> Number of stop bits in USART frame
869// <id> usart_stop_bit
870#ifndef CONF_SERCOM_3_USART_SBMODE
871#define CONF_SERCOM_3_USART_SBMODE 0
872#endif
873
874// <o> Baud rate <1-3000000>
875// <i> USART baud rate setting
876// <id> usart_baud_rate
877#ifndef CONF_SERCOM_3_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +0200878#define CONF_SERCOM_3_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100879#endif
880// </h>
881
882// <h> ISO7816 configuration
883// <o> ISO7816 Protocol Type
884// <0x1=> T=0
885// <0x0=> T=1
886// <i> Define ISO7816 protocol type as 0.
887// <id> usart_iso7816_type
888#ifndef CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T
889#define CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T 0x1
890#endif
891
892// <o> ISO7816 Inhibit Not Acknowledge
893// <0x0=> NACK is transmitted when a parity error is received.
894// <0x1=> NACK is not transmitted when a parity error is received.
895// <i> Define whether a NACK is transmitted when a parity error is received.
896// <id> usart_inack
897#ifndef CONF_SERCOM_3_USART_INACK
898#define CONF_SERCOM_3_USART_INACK 0x0
899#endif
900
901// <o> ISO7816 Disable Successive Not Acknowledge
902// <0x0=> The successive receive NACK is disable.
903// <0x1=> The successive receive NACK is enable.
904// <i> Define whether NACK will be sent on parity error reception.
905// <id> usart_dsnack
906#ifndef CONF_SERCOM_3_USART_DSNACK
907#define CONF_SERCOM_3_USART_DSNACK 0x0
908#endif
909
910// <o> ISO7816 Maximum Iterations<0-7>
911// <i> Define the maximum number of retransmit iterations.
912// <id> usart_maxiter
913#ifndef CONF_SERCOM_3_USART_MAXITER
914#define CONF_SERCOM_3_USART_MAXITER 0x7
915#endif
916
917// <o> ISO7816 Guard Time
918// <0x2=> 2-bit times
919// <0x3=> 3-bit times
920// <0x4=> 4-bit times
921// <0x5=> 5-bit times
922// <0x6=> 6-bit times
923// <0x7=> 7-bit times
924// <i> Define the guard time.
925// <id> usart_gtime
926#ifndef CONF_SERCOM_3_USART_GTIME
927#define CONF_SERCOM_3_USART_GTIME 0x2
928#endif
929
930// <q> Inverse transmission and reception enabled
931// <i> Define inverse transmission and reception enabled.
932// <id> usart_inverse_enabled
933#ifndef CONF_SERCOM_3_USART_INVERSE_ENABLED
934#define CONF_SERCOM_3_USART_INVERSE_ENABLED 0x0
935#endif
936
937#if (CONF_SERCOM_3_USART_INVERSE_ENABLED == 1)
938#define CONF_SERCOM_3_USART_RXINV 0x1
939#define CONF_SERCOM_3_USART_TXINV 0x1
940#else
941#define CONF_SERCOM_3_USART_RXINV 0x0
942#define CONF_SERCOM_3_USART_TXINV 0x0
943#endif
944
945// </h>
946
947// <e> Advanced configuration
948// <id> usart_advanced
949#ifndef CONF_SERCOM_3_USART_ADVANCED_CONFIG
950#define CONF_SERCOM_3_USART_ADVANCED_CONFIG 0
951#endif
952
953// <q> Run in stand-by
954// <i> Keep the module running in standby sleep mode
955// <id> usart_arch_runstdby
956#ifndef CONF_SERCOM_3_USART_RUNSTDBY
957#define CONF_SERCOM_3_USART_RUNSTDBY 0
958#endif
959
960// <q> Immediate Buffer Overflow Notification
961// <i> Controls when the BUFOVF status bit is asserted
962// <id> usart_arch_ibon
963#ifndef CONF_SERCOM_3_USART_IBON
964#define CONF_SERCOM_3_USART_IBON 0
965#endif
966
967// <q> Start of Frame Detection Enable
968// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
969// <id> usart_arch_sfde
970#ifndef CONF_SERCOM_3_USART_SFDE
971#define CONF_SERCOM_3_USART_SFDE 0
972#endif
973
974// <q> Collision Detection Enable
975// <i> Collision detection enable
976// <id> usart_arch_cloden
977#ifndef CONF_SERCOM_3_USART_CLODEN
978#define CONF_SERCOM_3_USART_CLODEN 0
979#endif
980
981// <o> Operating Mode
982// <0x1=>USART with internal clock
983// <i> Drive the shift register by an internal clock generated by the baud rate generator.
984// <id> usart_arch_clock_mode
985#ifndef CONF_SERCOM_3_USART_MODE
986#define CONF_SERCOM_3_USART_MODE 0x1
987#endif
988
989// <o> Data Order
990// <0=>MSB is transmitted first
991// <1=>LSB is transmitted first
992// <i> Data order of the data bits in the frame
993// <id> usart_arch_dord
994#ifndef CONF_SERCOM_3_USART_DORD
995#define CONF_SERCOM_3_USART_DORD 1
996#endif
997
998// <o> Debug Stop Mode
999// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
1000// <0=>Keep running
1001// <1=>Halt
1002// <id> usart_arch_dbgstop
1003#ifndef CONF_SERCOM_3_USART_DEBUG_STOP_MODE
1004#define CONF_SERCOM_3_USART_DEBUG_STOP_MODE 0
1005#endif
1006
1007// Does not do anything in USRT mode
1008#define CONF_SERCOM_3_USART_SAMPR 0x0
1009#define CONF_SERCOM_3_USART_SAMPA 0x0
1010#define CONF_SERCOM_3_USART_FRACTIONAL 0x0
1011
1012// Does not do anything in UART mode
1013#define CONF_SERCOM_3_USART_CPOL 0
1014
1015// Does not do anything in USRT mode
1016#define CONF_SERCOM_3_USART_ENC 0
1017
1018// </e>
1019
1020#ifndef CONF_SERCOM_3_USART_CMODE
1021#define CONF_SERCOM_3_USART_CMODE CONF_SERCOM_3_USART_ISO7816_PROTOCOL_T
1022#endif
1023
1024/* RX is on PIN_PB20 */
1025#ifndef CONF_SERCOM_3_USART_RXPO
1026#define CONF_SERCOM_3_USART_RXPO 0
1027#endif
1028
1029/* TX uses the same pin with RX */
1030#ifndef CONF_SERCOM_3_USART_TXPO
1031#define CONF_SERCOM_3_USART_TXPO 2
1032#endif
1033
1034/* Set iso7816 mode */
1035#define CONF_SERCOM_3_USART_PMODE (CONF_SERCOM_3_USART_PARITY - 1)
1036#define CONF_SERCOM_3_USART_FORM 7
1037
1038#if CONF_SERCOM_3_USART_CMODE == 0
1039// Calculate BAUD register value in UART mode
1040#if CONF_SERCOM_3_USART_SAMPR == 0
1041#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1042#define CONF_SERCOM_3_USART_BAUD_RATE \
1043 65536 - ((65536 * 16.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
1044#endif
1045#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1046#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1047#endif
1048#elif CONF_SERCOM_3_USART_SAMPR == 1
1049#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1050#define CONF_SERCOM_3_USART_BAUD_RATE \
1051 ((CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (CONF_SERCOM_3_USART_BAUD * 16)) - (CONF_SERCOM_3_USART_FRACTIONAL / 8)
1052#endif
1053#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1054#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1055#endif
1056#elif CONF_SERCOM_3_USART_SAMPR == 2
1057#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1058#define CONF_SERCOM_3_USART_BAUD_RATE \
1059 65536 - ((65536 * 8.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
1060#endif
1061#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1062#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1063#endif
1064#elif CONF_SERCOM_3_USART_SAMPR == 3
1065#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1066#define CONF_SERCOM_3_USART_BAUD_RATE \
1067 ((CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (CONF_SERCOM_3_USART_BAUD * 8)) - (CONF_SERCOM_3_USART_FRACTIONAL / 8)
1068#endif
1069#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1070#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1071#endif
1072#elif CONF_SERCOM_3_USART_SAMPR == 4
1073#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1074#define CONF_SERCOM_3_USART_BAUD_RATE \
1075 65536 - ((65536 * 3.0f * CONF_SERCOM_3_USART_BAUD) / CONF_GCLK_SERCOM3_CORE_FREQUENCY)
1076#endif
1077#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1078#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1079#endif
1080#endif
1081
1082#elif CONF_SERCOM_3_USART_CMODE == 1
1083#ifndef CONF_SERCOM_3_USART_BAUD_RATE
1084// Calculate BAUD register value in USRT mode
1085#define CONF_SERCOM_3_USART_BAUD_RATE (CONF_GCLK_SERCOM3_CORE_FREQUENCY) / (2 * CONF_SERCOM_3_USART_BAUD) - 1
1086#endif
1087
1088#ifndef CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH
1089#define CONF_SERCOM_3_USART_RECEIVE_PULSE_LENGTH 0
1090#endif
1091#else
1092#error CMODE value for SERCOM 3 in USART mode not known
1093#endif
1094
1095#include <peripheral_clk_config.h>
1096
1097#ifndef CONF_SERCOM_4_USART_ENABLE
1098#define CONF_SERCOM_4_USART_ENABLE 1
1099#endif
1100
1101// <h> Basic Configuration
1102
1103// <q> Receive buffer enable
1104// <i> Enable input buffer in SERCOM module
1105// <id> usart_rx_enable
1106#ifndef CONF_SERCOM_4_USART_RXEN
1107#define CONF_SERCOM_4_USART_RXEN 1
1108#endif
1109
1110// <q> Transmitt buffer enable
1111// <i> Enable output buffer in SERCOM module
1112// <id> usart_tx_enable
1113#ifndef CONF_SERCOM_4_USART_TXEN
1114#define CONF_SERCOM_4_USART_TXEN 1
1115#endif
1116
1117// <o> Frame parity
1118// <0x1=>Even parity
1119// <i> Parity bit mode for USART frame
1120// <id> usart_parity
1121#ifndef CONF_SERCOM_4_USART_PARITY
1122#define CONF_SERCOM_4_USART_PARITY 1
1123#endif
1124
1125// <o> Character Size
1126// <0x0=>8 bits
1127// <0x1=>9 bits
1128// <0x5=>5 bits
1129// <0x6=>6 bits
1130// <0x7=>7 bits
1131// <i> Data character size in USART frame
1132// <id> usart_character_size
1133#ifndef CONF_SERCOM_4_USART_CHSIZE
1134#define CONF_SERCOM_4_USART_CHSIZE 0x0
1135#endif
1136
1137// <o> Stop Bit
1138// <0=>One stop bit
1139// <1=>Two stop bits
1140// <i> Number of stop bits in USART frame
1141// <id> usart_stop_bit
1142#ifndef CONF_SERCOM_4_USART_SBMODE
1143#define CONF_SERCOM_4_USART_SBMODE 0
1144#endif
1145
1146// <o> Baud rate <1-3000000>
1147// <i> USART baud rate setting
1148// <id> usart_baud_rate
1149#ifndef CONF_SERCOM_4_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +02001150#define CONF_SERCOM_4_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +01001151#endif
1152// </h>
1153
1154// <h> ISO7816 configuration
1155// <o> ISO7816 Protocol Type
1156// <0x1=> T=0
1157// <0x0=> T=1
1158// <i> Define ISO7816 protocol type as 0.
1159// <id> usart_iso7816_type
1160#ifndef CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T
1161#define CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T 0x1
1162#endif
1163
1164// <o> ISO7816 Inhibit Not Acknowledge
1165// <0x0=> NACK is transmitted when a parity error is received.
1166// <0x1=> NACK is not transmitted when a parity error is received.
1167// <i> Define whether a NACK is transmitted when a parity error is received.
1168// <id> usart_inack
1169#ifndef CONF_SERCOM_4_USART_INACK
1170#define CONF_SERCOM_4_USART_INACK 0x0
1171#endif
1172
1173// <o> ISO7816 Disable Successive Not Acknowledge
1174// <0x0=> The successive receive NACK is disable.
1175// <0x1=> The successive receive NACK is enable.
1176// <i> Define whether NACK will be sent on parity error reception.
1177// <id> usart_dsnack
1178#ifndef CONF_SERCOM_4_USART_DSNACK
1179#define CONF_SERCOM_4_USART_DSNACK 0x0
1180#endif
1181
1182// <o> ISO7816 Maximum Iterations<0-7>
1183// <i> Define the maximum number of retransmit iterations.
1184// <id> usart_maxiter
1185#ifndef CONF_SERCOM_4_USART_MAXITER
1186#define CONF_SERCOM_4_USART_MAXITER 0x7
1187#endif
1188
1189// <o> ISO7816 Guard Time
1190// <0x2=> 2-bit times
1191// <0x3=> 3-bit times
1192// <0x4=> 4-bit times
1193// <0x5=> 5-bit times
1194// <0x6=> 6-bit times
1195// <0x7=> 7-bit times
1196// <i> Define the guard time.
1197// <id> usart_gtime
1198#ifndef CONF_SERCOM_4_USART_GTIME
1199#define CONF_SERCOM_4_USART_GTIME 0x2
1200#endif
1201
1202// <q> Inverse transmission and reception enabled
1203// <i> Define inverse transmission and reception enabled.
1204// <id> usart_inverse_enabled
1205#ifndef CONF_SERCOM_4_USART_INVERSE_ENABLED
1206#define CONF_SERCOM_4_USART_INVERSE_ENABLED 0x0
1207#endif
1208
1209#if (CONF_SERCOM_4_USART_INVERSE_ENABLED == 1)
1210#define CONF_SERCOM_4_USART_RXINV 0x1
1211#define CONF_SERCOM_4_USART_TXINV 0x1
1212#else
1213#define CONF_SERCOM_4_USART_RXINV 0x0
1214#define CONF_SERCOM_4_USART_TXINV 0x0
1215#endif
1216
1217// </h>
1218
1219// <e> Advanced configuration
1220// <id> usart_advanced
1221#ifndef CONF_SERCOM_4_USART_ADVANCED_CONFIG
1222#define CONF_SERCOM_4_USART_ADVANCED_CONFIG 0
1223#endif
1224
1225// <q> Run in stand-by
1226// <i> Keep the module running in standby sleep mode
1227// <id> usart_arch_runstdby
1228#ifndef CONF_SERCOM_4_USART_RUNSTDBY
1229#define CONF_SERCOM_4_USART_RUNSTDBY 0
1230#endif
1231
1232// <q> Immediate Buffer Overflow Notification
1233// <i> Controls when the BUFOVF status bit is asserted
1234// <id> usart_arch_ibon
1235#ifndef CONF_SERCOM_4_USART_IBON
1236#define CONF_SERCOM_4_USART_IBON 0
1237#endif
1238
1239// <q> Start of Frame Detection Enable
1240// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
1241// <id> usart_arch_sfde
1242#ifndef CONF_SERCOM_4_USART_SFDE
1243#define CONF_SERCOM_4_USART_SFDE 0
1244#endif
1245
1246// <q> Collision Detection Enable
1247// <i> Collision detection enable
1248// <id> usart_arch_cloden
1249#ifndef CONF_SERCOM_4_USART_CLODEN
1250#define CONF_SERCOM_4_USART_CLODEN 0
1251#endif
1252
1253// <o> Operating Mode
1254// <0x1=>USART with internal clock
1255// <i> Drive the shift register by an internal clock generated by the baud rate generator.
1256// <id> usart_arch_clock_mode
1257#ifndef CONF_SERCOM_4_USART_MODE
1258#define CONF_SERCOM_4_USART_MODE 0x1
1259#endif
1260
1261// <o> Data Order
1262// <0=>MSB is transmitted first
1263// <1=>LSB is transmitted first
1264// <i> Data order of the data bits in the frame
1265// <id> usart_arch_dord
1266#ifndef CONF_SERCOM_4_USART_DORD
1267#define CONF_SERCOM_4_USART_DORD 1
1268#endif
1269
1270// <o> Debug Stop Mode
1271// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
1272// <0=>Keep running
1273// <1=>Halt
1274// <id> usart_arch_dbgstop
1275#ifndef CONF_SERCOM_4_USART_DEBUG_STOP_MODE
1276#define CONF_SERCOM_4_USART_DEBUG_STOP_MODE 0
1277#endif
1278
1279// Does not do anything in USRT mode
1280#define CONF_SERCOM_4_USART_SAMPR 0x0
1281#define CONF_SERCOM_4_USART_SAMPA 0x0
1282#define CONF_SERCOM_4_USART_FRACTIONAL 0x0
1283
1284// Does not do anything in UART mode
1285#define CONF_SERCOM_4_USART_CPOL 0
1286
1287// Does not do anything in USRT mode
1288#define CONF_SERCOM_4_USART_ENC 0
1289
1290// </e>
1291
1292#ifndef CONF_SERCOM_4_USART_CMODE
1293#define CONF_SERCOM_4_USART_CMODE CONF_SERCOM_4_USART_ISO7816_PROTOCOL_T
1294#endif
1295
1296/* RX is on PIN_PB08 */
1297#ifndef CONF_SERCOM_4_USART_RXPO
1298#define CONF_SERCOM_4_USART_RXPO 0
1299#endif
1300
1301/* TX uses the same pin with RX */
1302#ifndef CONF_SERCOM_4_USART_TXPO
1303#define CONF_SERCOM_4_USART_TXPO 2
1304#endif
1305
1306/* Set iso7816 mode */
1307#define CONF_SERCOM_4_USART_PMODE (CONF_SERCOM_4_USART_PARITY - 1)
1308#define CONF_SERCOM_4_USART_FORM 7
1309
1310#if CONF_SERCOM_4_USART_CMODE == 0
1311// Calculate BAUD register value in UART mode
1312#if CONF_SERCOM_4_USART_SAMPR == 0
1313#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1314#define CONF_SERCOM_4_USART_BAUD_RATE \
1315 65536 - ((65536 * 16.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
1316#endif
1317#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1318#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1319#endif
1320#elif CONF_SERCOM_4_USART_SAMPR == 1
1321#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1322#define CONF_SERCOM_4_USART_BAUD_RATE \
1323 ((CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (CONF_SERCOM_4_USART_BAUD * 16)) - (CONF_SERCOM_4_USART_FRACTIONAL / 8)
1324#endif
1325#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1326#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1327#endif
1328#elif CONF_SERCOM_4_USART_SAMPR == 2
1329#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1330#define CONF_SERCOM_4_USART_BAUD_RATE \
1331 65536 - ((65536 * 8.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
1332#endif
1333#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1334#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1335#endif
1336#elif CONF_SERCOM_4_USART_SAMPR == 3
1337#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1338#define CONF_SERCOM_4_USART_BAUD_RATE \
1339 ((CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (CONF_SERCOM_4_USART_BAUD * 8)) - (CONF_SERCOM_4_USART_FRACTIONAL / 8)
1340#endif
1341#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1342#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1343#endif
1344#elif CONF_SERCOM_4_USART_SAMPR == 4
1345#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1346#define CONF_SERCOM_4_USART_BAUD_RATE \
1347 65536 - ((65536 * 3.0f * CONF_SERCOM_4_USART_BAUD) / CONF_GCLK_SERCOM4_CORE_FREQUENCY)
1348#endif
1349#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1350#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1351#endif
1352#endif
1353
1354#elif CONF_SERCOM_4_USART_CMODE == 1
1355#ifndef CONF_SERCOM_4_USART_BAUD_RATE
1356// Calculate BAUD register value in USRT mode
1357#define CONF_SERCOM_4_USART_BAUD_RATE (CONF_GCLK_SERCOM4_CORE_FREQUENCY) / (2 * CONF_SERCOM_4_USART_BAUD) - 1
1358#endif
1359
1360#ifndef CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH
1361#define CONF_SERCOM_4_USART_RECEIVE_PULSE_LENGTH 0
1362#endif
1363#else
1364#error CMODE value for SERCOM 4 in USART mode not known
1365#endif
1366
1367#include <peripheral_clk_config.h>
1368
1369#ifndef CONF_SERCOM_5_USART_ENABLE
1370#define CONF_SERCOM_5_USART_ENABLE 1
1371#endif
1372
1373// <h> Basic Configuration
1374
1375// <q> Receive buffer enable
1376// <i> Enable input buffer in SERCOM module
1377// <id> usart_rx_enable
1378#ifndef CONF_SERCOM_5_USART_RXEN
1379#define CONF_SERCOM_5_USART_RXEN 1
1380#endif
1381
1382// <q> Transmitt buffer enable
1383// <i> Enable output buffer in SERCOM module
1384// <id> usart_tx_enable
1385#ifndef CONF_SERCOM_5_USART_TXEN
1386#define CONF_SERCOM_5_USART_TXEN 1
1387#endif
1388
1389// <o> Frame parity
1390// <0x1=>Even parity
1391// <i> Parity bit mode for USART frame
1392// <id> usart_parity
1393#ifndef CONF_SERCOM_5_USART_PARITY
1394#define CONF_SERCOM_5_USART_PARITY 1
1395#endif
1396
1397// <o> Character Size
1398// <0x0=>8 bits
1399// <0x1=>9 bits
1400// <0x5=>5 bits
1401// <0x6=>6 bits
1402// <0x7=>7 bits
1403// <i> Data character size in USART frame
1404// <id> usart_character_size
1405#ifndef CONF_SERCOM_5_USART_CHSIZE
1406#define CONF_SERCOM_5_USART_CHSIZE 0x0
1407#endif
1408
1409// <o> Stop Bit
1410// <0=>One stop bit
1411// <1=>Two stop bits
1412// <i> Number of stop bits in USART frame
1413// <id> usart_stop_bit
1414#ifndef CONF_SERCOM_5_USART_SBMODE
1415#define CONF_SERCOM_5_USART_SBMODE 0
1416#endif
1417
1418// <o> Baud rate <1-3000000>
1419// <i> USART baud rate setting
1420// <id> usart_baud_rate
1421#ifndef CONF_SERCOM_5_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +02001422#define CONF_SERCOM_5_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +01001423#endif
1424// </h>
1425
1426// <h> ISO7816 configuration
1427// <o> ISO7816 Protocol Type
1428// <0x1=> T=0
1429// <0x0=> T=1
1430// <i> Define ISO7816 protocol type as 0.
1431// <id> usart_iso7816_type
1432#ifndef CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T
1433#define CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T 0x1
1434#endif
1435
1436// <o> ISO7816 Inhibit Not Acknowledge
1437// <0x0=> NACK is transmitted when a parity error is received.
1438// <0x1=> NACK is not transmitted when a parity error is received.
1439// <i> Define whether a NACK is transmitted when a parity error is received.
1440// <id> usart_inack
1441#ifndef CONF_SERCOM_5_USART_INACK
1442#define CONF_SERCOM_5_USART_INACK 0x0
1443#endif
1444
1445// <o> ISO7816 Disable Successive Not Acknowledge
1446// <0x0=> The successive receive NACK is disable.
1447// <0x1=> The successive receive NACK is enable.
1448// <i> Define whether NACK will be sent on parity error reception.
1449// <id> usart_dsnack
1450#ifndef CONF_SERCOM_5_USART_DSNACK
1451#define CONF_SERCOM_5_USART_DSNACK 0x0
1452#endif
1453
1454// <o> ISO7816 Maximum Iterations<0-7>
1455// <i> Define the maximum number of retransmit iterations.
1456// <id> usart_maxiter
1457#ifndef CONF_SERCOM_5_USART_MAXITER
1458#define CONF_SERCOM_5_USART_MAXITER 0x7
1459#endif
1460
1461// <o> ISO7816 Guard Time
1462// <0x2=> 2-bit times
1463// <0x3=> 3-bit times
1464// <0x4=> 4-bit times
1465// <0x5=> 5-bit times
1466// <0x6=> 6-bit times
1467// <0x7=> 7-bit times
1468// <i> Define the guard time.
1469// <id> usart_gtime
1470#ifndef CONF_SERCOM_5_USART_GTIME
1471#define CONF_SERCOM_5_USART_GTIME 0x2
1472#endif
1473
1474// <q> Inverse transmission and reception enabled
1475// <i> Define inverse transmission and reception enabled.
1476// <id> usart_inverse_enabled
1477#ifndef CONF_SERCOM_5_USART_INVERSE_ENABLED
1478#define CONF_SERCOM_5_USART_INVERSE_ENABLED 0x0
1479#endif
1480
1481#if (CONF_SERCOM_5_USART_INVERSE_ENABLED == 1)
1482#define CONF_SERCOM_5_USART_RXINV 0x1
1483#define CONF_SERCOM_5_USART_TXINV 0x1
1484#else
1485#define CONF_SERCOM_5_USART_RXINV 0x0
1486#define CONF_SERCOM_5_USART_TXINV 0x0
1487#endif
1488
1489// </h>
1490
1491// <e> Advanced configuration
1492// <id> usart_advanced
1493#ifndef CONF_SERCOM_5_USART_ADVANCED_CONFIG
1494#define CONF_SERCOM_5_USART_ADVANCED_CONFIG 0
1495#endif
1496
1497// <q> Run in stand-by
1498// <i> Keep the module running in standby sleep mode
1499// <id> usart_arch_runstdby
1500#ifndef CONF_SERCOM_5_USART_RUNSTDBY
1501#define CONF_SERCOM_5_USART_RUNSTDBY 0
1502#endif
1503
1504// <q> Immediate Buffer Overflow Notification
1505// <i> Controls when the BUFOVF status bit is asserted
1506// <id> usart_arch_ibon
1507#ifndef CONF_SERCOM_5_USART_IBON
1508#define CONF_SERCOM_5_USART_IBON 0
1509#endif
1510
1511// <q> Start of Frame Detection Enable
1512// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
1513// <id> usart_arch_sfde
1514#ifndef CONF_SERCOM_5_USART_SFDE
1515#define CONF_SERCOM_5_USART_SFDE 0
1516#endif
1517
1518// <q> Collision Detection Enable
1519// <i> Collision detection enable
1520// <id> usart_arch_cloden
1521#ifndef CONF_SERCOM_5_USART_CLODEN
1522#define CONF_SERCOM_5_USART_CLODEN 0
1523#endif
1524
1525// <o> Operating Mode
1526// <0x1=>USART with internal clock
1527// <i> Drive the shift register by an internal clock generated by the baud rate generator.
1528// <id> usart_arch_clock_mode
1529#ifndef CONF_SERCOM_5_USART_MODE
1530#define CONF_SERCOM_5_USART_MODE 0x1
1531#endif
1532
1533// <o> Data Order
1534// <0=>MSB is transmitted first
1535// <1=>LSB is transmitted first
1536// <i> Data order of the data bits in the frame
1537// <id> usart_arch_dord
1538#ifndef CONF_SERCOM_5_USART_DORD
1539#define CONF_SERCOM_5_USART_DORD 1
1540#endif
1541
1542// <o> Debug Stop Mode
1543// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
1544// <0=>Keep running
1545// <1=>Halt
1546// <id> usart_arch_dbgstop
1547#ifndef CONF_SERCOM_5_USART_DEBUG_STOP_MODE
1548#define CONF_SERCOM_5_USART_DEBUG_STOP_MODE 0
1549#endif
1550
1551// Does not do anything in USRT mode
1552#define CONF_SERCOM_5_USART_SAMPR 0x0
1553#define CONF_SERCOM_5_USART_SAMPA 0x0
1554#define CONF_SERCOM_5_USART_FRACTIONAL 0x0
1555
1556// Does not do anything in UART mode
1557#define CONF_SERCOM_5_USART_CPOL 0
1558
1559// Does not do anything in USRT mode
1560#define CONF_SERCOM_5_USART_ENC 0
1561
1562// </e>
1563
1564#ifndef CONF_SERCOM_5_USART_CMODE
1565#define CONF_SERCOM_5_USART_CMODE CONF_SERCOM_5_USART_ISO7816_PROTOCOL_T
1566#endif
1567
1568/* RX is on PIN_PB16 */
1569#ifndef CONF_SERCOM_5_USART_RXPO
1570#define CONF_SERCOM_5_USART_RXPO 0
1571#endif
1572
1573/* TX uses the same pin with RX */
1574#ifndef CONF_SERCOM_5_USART_TXPO
1575#define CONF_SERCOM_5_USART_TXPO 2
1576#endif
1577
1578/* Set iso7816 mode */
1579#define CONF_SERCOM_5_USART_PMODE (CONF_SERCOM_5_USART_PARITY - 1)
1580#define CONF_SERCOM_5_USART_FORM 7
1581
1582#if CONF_SERCOM_5_USART_CMODE == 0
1583// Calculate BAUD register value in UART mode
1584#if CONF_SERCOM_5_USART_SAMPR == 0
1585#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1586#define CONF_SERCOM_5_USART_BAUD_RATE \
1587 65536 - ((65536 * 16.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
1588#endif
1589#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1590#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1591#endif
1592#elif CONF_SERCOM_5_USART_SAMPR == 1
1593#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1594#define CONF_SERCOM_5_USART_BAUD_RATE \
1595 ((CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (CONF_SERCOM_5_USART_BAUD * 16)) - (CONF_SERCOM_5_USART_FRACTIONAL / 8)
1596#endif
1597#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1598#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1599#endif
1600#elif CONF_SERCOM_5_USART_SAMPR == 2
1601#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1602#define CONF_SERCOM_5_USART_BAUD_RATE \
1603 65536 - ((65536 * 8.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
1604#endif
1605#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1606#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1607#endif
1608#elif CONF_SERCOM_5_USART_SAMPR == 3
1609#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1610#define CONF_SERCOM_5_USART_BAUD_RATE \
1611 ((CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (CONF_SERCOM_5_USART_BAUD * 8)) - (CONF_SERCOM_5_USART_FRACTIONAL / 8)
1612#endif
1613#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1614#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1615#endif
1616#elif CONF_SERCOM_5_USART_SAMPR == 4
1617#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1618#define CONF_SERCOM_5_USART_BAUD_RATE \
1619 65536 - ((65536 * 3.0f * CONF_SERCOM_5_USART_BAUD) / CONF_GCLK_SERCOM5_CORE_FREQUENCY)
1620#endif
1621#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1622#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1623#endif
1624#endif
1625
1626#elif CONF_SERCOM_5_USART_CMODE == 1
1627#ifndef CONF_SERCOM_5_USART_BAUD_RATE
1628// Calculate BAUD register value in USRT mode
1629#define CONF_SERCOM_5_USART_BAUD_RATE (CONF_GCLK_SERCOM5_CORE_FREQUENCY) / (2 * CONF_SERCOM_5_USART_BAUD) - 1
1630#endif
1631
1632#ifndef CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH
1633#define CONF_SERCOM_5_USART_RECEIVE_PULSE_LENGTH 0
1634#endif
1635#else
1636#error CMODE value for SERCOM 5 in USART mode not known
1637#endif
1638
1639#include <peripheral_clk_config.h>
1640
1641#ifndef CONF_SERCOM_6_USART_ENABLE
1642#define CONF_SERCOM_6_USART_ENABLE 1
1643#endif
1644
1645// <h> Basic Configuration
1646
1647// <q> Receive buffer enable
1648// <i> Enable input buffer in SERCOM module
1649// <id> usart_rx_enable
1650#ifndef CONF_SERCOM_6_USART_RXEN
1651#define CONF_SERCOM_6_USART_RXEN 1
1652#endif
1653
1654// <q> Transmitt buffer enable
1655// <i> Enable output buffer in SERCOM module
1656// <id> usart_tx_enable
1657#ifndef CONF_SERCOM_6_USART_TXEN
1658#define CONF_SERCOM_6_USART_TXEN 1
1659#endif
1660
1661// <o> Frame parity
1662// <0x1=>Even parity
1663// <i> Parity bit mode for USART frame
1664// <id> usart_parity
1665#ifndef CONF_SERCOM_6_USART_PARITY
1666#define CONF_SERCOM_6_USART_PARITY 1
1667#endif
1668
1669// <o> Character Size
1670// <0x0=>8 bits
1671// <0x1=>9 bits
1672// <0x5=>5 bits
1673// <0x6=>6 bits
1674// <0x7=>7 bits
1675// <i> Data character size in USART frame
1676// <id> usart_character_size
1677#ifndef CONF_SERCOM_6_USART_CHSIZE
1678#define CONF_SERCOM_6_USART_CHSIZE 0x0
1679#endif
1680
1681// <o> Stop Bit
1682// <0=>One stop bit
1683// <1=>Two stop bits
1684// <i> Number of stop bits in USART frame
1685// <id> usart_stop_bit
1686#ifndef CONF_SERCOM_6_USART_SBMODE
1687#define CONF_SERCOM_6_USART_SBMODE 0
1688#endif
1689
1690// <o> Baud rate <1-3000000>
1691// <i> USART baud rate setting
1692// <id> usart_baud_rate
1693#ifndef CONF_SERCOM_6_USART_BAUD
Kévin Redonee491292019-04-17 01:01:26 +02001694#define CONF_SERCOM_6_USART_BAUD 6720
Kévin Redon1f8ecef2019-01-31 13:36:12 +01001695#endif
1696// </h>
1697
1698// <h> ISO7816 configuration
1699// <o> ISO7816 Protocol Type
1700// <0x1=> T=0
1701// <0x0=> T=1
1702// <i> Define ISO7816 protocol type as 0.
1703// <id> usart_iso7816_type
1704#ifndef CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T
1705#define CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T 0x1
1706#endif
1707
1708// <o> ISO7816 Inhibit Not Acknowledge
1709// <0x0=> NACK is transmitted when a parity error is received.
1710// <0x1=> NACK is not transmitted when a parity error is received.
1711// <i> Define whether a NACK is transmitted when a parity error is received.
1712// <id> usart_inack
1713#ifndef CONF_SERCOM_6_USART_INACK
1714#define CONF_SERCOM_6_USART_INACK 0x0
1715#endif
1716
1717// <o> ISO7816 Disable Successive Not Acknowledge
1718// <0x0=> The successive receive NACK is disable.
1719// <0x1=> The successive receive NACK is enable.
1720// <i> Define whether NACK will be sent on parity error reception.
1721// <id> usart_dsnack
1722#ifndef CONF_SERCOM_6_USART_DSNACK
1723#define CONF_SERCOM_6_USART_DSNACK 0x0
1724#endif
1725
1726// <o> ISO7816 Maximum Iterations<0-7>
1727// <i> Define the maximum number of retransmit iterations.
1728// <id> usart_maxiter
1729#ifndef CONF_SERCOM_6_USART_MAXITER
1730#define CONF_SERCOM_6_USART_MAXITER 0x7
1731#endif
1732
1733// <o> ISO7816 Guard Time
1734// <0x2=> 2-bit times
1735// <0x3=> 3-bit times
1736// <0x4=> 4-bit times
1737// <0x5=> 5-bit times
1738// <0x6=> 6-bit times
1739// <0x7=> 7-bit times
1740// <i> Define the guard time.
1741// <id> usart_gtime
1742#ifndef CONF_SERCOM_6_USART_GTIME
1743#define CONF_SERCOM_6_USART_GTIME 0x2
1744#endif
1745
1746// <q> Inverse transmission and reception enabled
1747// <i> Define inverse transmission and reception enabled.
1748// <id> usart_inverse_enabled
1749#ifndef CONF_SERCOM_6_USART_INVERSE_ENABLED
1750#define CONF_SERCOM_6_USART_INVERSE_ENABLED 0x0
1751#endif
1752
1753#if (CONF_SERCOM_6_USART_INVERSE_ENABLED == 1)
1754#define CONF_SERCOM_6_USART_RXINV 0x1
1755#define CONF_SERCOM_6_USART_TXINV 0x1
1756#else
1757#define CONF_SERCOM_6_USART_RXINV 0x0
1758#define CONF_SERCOM_6_USART_TXINV 0x0
1759#endif
1760
1761// </h>
1762
1763// <e> Advanced configuration
1764// <id> usart_advanced
1765#ifndef CONF_SERCOM_6_USART_ADVANCED_CONFIG
1766#define CONF_SERCOM_6_USART_ADVANCED_CONFIG 0
1767#endif
1768
1769// <q> Run in stand-by
1770// <i> Keep the module running in standby sleep mode
1771// <id> usart_arch_runstdby
1772#ifndef CONF_SERCOM_6_USART_RUNSTDBY
1773#define CONF_SERCOM_6_USART_RUNSTDBY 0
1774#endif
1775
1776// <q> Immediate Buffer Overflow Notification
1777// <i> Controls when the BUFOVF status bit is asserted
1778// <id> usart_arch_ibon
1779#ifndef CONF_SERCOM_6_USART_IBON
1780#define CONF_SERCOM_6_USART_IBON 0
1781#endif
1782
1783// <q> Start of Frame Detection Enable
1784// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
1785// <id> usart_arch_sfde
1786#ifndef CONF_SERCOM_6_USART_SFDE
1787#define CONF_SERCOM_6_USART_SFDE 0
1788#endif
1789
1790// <q> Collision Detection Enable
1791// <i> Collision detection enable
1792// <id> usart_arch_cloden
1793#ifndef CONF_SERCOM_6_USART_CLODEN
1794#define CONF_SERCOM_6_USART_CLODEN 0
1795#endif
1796
1797// <o> Operating Mode
1798// <0x1=>USART with internal clock
1799// <i> Drive the shift register by an internal clock generated by the baud rate generator.
1800// <id> usart_arch_clock_mode
1801#ifndef CONF_SERCOM_6_USART_MODE
1802#define CONF_SERCOM_6_USART_MODE 0x1
1803#endif
1804
1805// <o> Data Order
1806// <0=>MSB is transmitted first
1807// <1=>LSB is transmitted first
1808// <i> Data order of the data bits in the frame
1809// <id> usart_arch_dord
1810#ifndef CONF_SERCOM_6_USART_DORD
1811#define CONF_SERCOM_6_USART_DORD 1
1812#endif
1813
1814// <o> Debug Stop Mode
1815// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
1816// <0=>Keep running
1817// <1=>Halt
1818// <id> usart_arch_dbgstop
1819#ifndef CONF_SERCOM_6_USART_DEBUG_STOP_MODE
1820#define CONF_SERCOM_6_USART_DEBUG_STOP_MODE 0
1821#endif
1822
1823// Does not do anything in USRT mode
1824#define CONF_SERCOM_6_USART_SAMPR 0x0
1825#define CONF_SERCOM_6_USART_SAMPA 0x0
1826#define CONF_SERCOM_6_USART_FRACTIONAL 0x0
1827
1828// Does not do anything in UART mode
1829#define CONF_SERCOM_6_USART_CPOL 0
1830
1831// Does not do anything in USRT mode
1832#define CONF_SERCOM_6_USART_ENC 0
1833
1834// </e>
1835
1836#ifndef CONF_SERCOM_6_USART_CMODE
1837#define CONF_SERCOM_6_USART_CMODE CONF_SERCOM_6_USART_ISO7816_PROTOCOL_T
1838#endif
1839
1840/* RX is on PIN_PC16 */
1841#ifndef CONF_SERCOM_6_USART_RXPO
1842#define CONF_SERCOM_6_USART_RXPO 0
1843#endif
1844
1845/* TX uses the same pin with RX */
1846#ifndef CONF_SERCOM_6_USART_TXPO
1847#define CONF_SERCOM_6_USART_TXPO 2
1848#endif
1849
1850/* Set iso7816 mode */
1851#define CONF_SERCOM_6_USART_PMODE (CONF_SERCOM_6_USART_PARITY - 1)
1852#define CONF_SERCOM_6_USART_FORM 7
1853
1854#if CONF_SERCOM_6_USART_CMODE == 0
1855// Calculate BAUD register value in UART mode
1856#if CONF_SERCOM_6_USART_SAMPR == 0
1857#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1858#define CONF_SERCOM_6_USART_BAUD_RATE \
1859 65536 - ((65536 * 16.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
1860#endif
1861#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1862#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1863#endif
1864#elif CONF_SERCOM_6_USART_SAMPR == 1
1865#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1866#define CONF_SERCOM_6_USART_BAUD_RATE \
1867 ((CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (CONF_SERCOM_6_USART_BAUD * 16)) - (CONF_SERCOM_6_USART_FRACTIONAL / 8)
1868#endif
1869#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1870#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1871#endif
1872#elif CONF_SERCOM_6_USART_SAMPR == 2
1873#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1874#define CONF_SERCOM_6_USART_BAUD_RATE \
1875 65536 - ((65536 * 8.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
1876#endif
1877#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1878#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1879#endif
1880#elif CONF_SERCOM_6_USART_SAMPR == 3
1881#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1882#define CONF_SERCOM_6_USART_BAUD_RATE \
1883 ((CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (CONF_SERCOM_6_USART_BAUD * 8)) - (CONF_SERCOM_6_USART_FRACTIONAL / 8)
1884#endif
1885#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1886#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1887#endif
1888#elif CONF_SERCOM_6_USART_SAMPR == 4
1889#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1890#define CONF_SERCOM_6_USART_BAUD_RATE \
1891 65536 - ((65536 * 3.0f * CONF_SERCOM_6_USART_BAUD) / CONF_GCLK_SERCOM6_CORE_FREQUENCY)
1892#endif
1893#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1894#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1895#endif
1896#endif
1897
1898#elif CONF_SERCOM_6_USART_CMODE == 1
1899#ifndef CONF_SERCOM_6_USART_BAUD_RATE
1900// Calculate BAUD register value in USRT mode
1901#define CONF_SERCOM_6_USART_BAUD_RATE (CONF_GCLK_SERCOM6_CORE_FREQUENCY) / (2 * CONF_SERCOM_6_USART_BAUD) - 1
1902#endif
1903
1904#ifndef CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH
1905#define CONF_SERCOM_6_USART_RECEIVE_PULSE_LENGTH 0
1906#endif
1907#else
1908#error CMODE value for SERCOM 6 in USART mode not known
1909#endif
1910
1911#include <peripheral_clk_config.h>
1912
Kévin Redon4e39b012019-01-30 15:55:58 +01001913#ifndef CONF_SERCOM_7_USART_ENABLE
1914#define CONF_SERCOM_7_USART_ENABLE 1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001915#endif
1916
1917// <h> Basic Configuration
1918
1919// <q> Receive buffer enable
1920// <i> Enable input buffer in SERCOM module
1921// <id> usart_rx_enable
Kévin Redon4e39b012019-01-30 15:55:58 +01001922#ifndef CONF_SERCOM_7_USART_RXEN
1923#define CONF_SERCOM_7_USART_RXEN 1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001924#endif
1925
1926// <q> Transmitt buffer enable
1927// <i> Enable output buffer in SERCOM module
1928// <id> usart_tx_enable
Kévin Redon4e39b012019-01-30 15:55:58 +01001929#ifndef CONF_SERCOM_7_USART_TXEN
1930#define CONF_SERCOM_7_USART_TXEN 1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001931#endif
1932
1933// <o> Frame parity
1934// <0x0=>No parity
1935// <0x1=>Even parity
1936// <0x2=>Odd parity
1937// <i> Parity bit mode for USART frame
1938// <id> usart_parity
Kévin Redon4e39b012019-01-30 15:55:58 +01001939#ifndef CONF_SERCOM_7_USART_PARITY
1940#define CONF_SERCOM_7_USART_PARITY 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001941#endif
1942
1943// <o> Character Size
1944// <0x0=>8 bits
1945// <0x1=>9 bits
1946// <0x5=>5 bits
1947// <0x6=>6 bits
1948// <0x7=>7 bits
1949// <i> Data character size in USART frame
1950// <id> usart_character_size
Kévin Redon4e39b012019-01-30 15:55:58 +01001951#ifndef CONF_SERCOM_7_USART_CHSIZE
1952#define CONF_SERCOM_7_USART_CHSIZE 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001953#endif
1954
1955// <o> Stop Bit
1956// <0=>One stop bit
1957// <1=>Two stop bits
1958// <i> Number of stop bits in USART frame
1959// <id> usart_stop_bit
Kévin Redon4e39b012019-01-30 15:55:58 +01001960#ifndef CONF_SERCOM_7_USART_SBMODE
1961#define CONF_SERCOM_7_USART_SBMODE 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001962#endif
1963
1964// <o> Baud rate <1-6250000>
1965// <i> USART baud rate setting
1966// <id> usart_baud_rate
Kévin Redon4e39b012019-01-30 15:55:58 +01001967#ifndef CONF_SERCOM_7_USART_BAUD
1968#define CONF_SERCOM_7_USART_BAUD 921600
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001969#endif
1970
1971// </h>
1972
1973// <e> Advanced configuration
1974// <id> usart_advanced
Kévin Redon4e39b012019-01-30 15:55:58 +01001975#ifndef CONF_SERCOM_7_USART_ADVANCED_CONFIG
1976#define CONF_SERCOM_7_USART_ADVANCED_CONFIG 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001977#endif
1978
1979// <q> Run in stand-by
1980// <i> Keep the module running in standby sleep mode
1981// <id> usart_arch_runstdby
Kévin Redon4e39b012019-01-30 15:55:58 +01001982#ifndef CONF_SERCOM_7_USART_RUNSTDBY
1983#define CONF_SERCOM_7_USART_RUNSTDBY 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001984#endif
1985
1986// <q> Immediate Buffer Overflow Notification
1987// <i> Controls when the BUFOVF status bit is asserted
1988// <id> usart_arch_ibon
Kévin Redon4e39b012019-01-30 15:55:58 +01001989#ifndef CONF_SERCOM_7_USART_IBON
1990#define CONF_SERCOM_7_USART_IBON 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001991#endif
1992
1993// <q> Start of Frame Detection Enable
1994// <i> Will wake the device from any sleep mode if usart_init and usart_enable was run priort to going to sleep. (receive buffer must be enabled)
1995// <id> usart_arch_sfde
Kévin Redon4e39b012019-01-30 15:55:58 +01001996#ifndef CONF_SERCOM_7_USART_SFDE
1997#define CONF_SERCOM_7_USART_SFDE 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01001998#endif
1999
2000// <q> Collision Detection Enable
2001// <i> Collision detection enable
2002// <id> usart_arch_cloden
Kévin Redon4e39b012019-01-30 15:55:58 +01002003#ifndef CONF_SERCOM_7_USART_CLODEN
2004#define CONF_SERCOM_7_USART_CLODEN 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002005#endif
2006
2007// <o> Operating Mode
2008// <0x0=>USART with external clock
2009// <0x1=>USART with internal clock
2010// <i> Drive the shift register by an internal clock generated by the baud rate generator or an external clock supplied on the XCK pin.
2011// <id> usart_arch_clock_mode
Kévin Redon4e39b012019-01-30 15:55:58 +01002012#ifndef CONF_SERCOM_7_USART_MODE
2013#define CONF_SERCOM_7_USART_MODE 0x1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002014#endif
2015
2016// <o> Sample Rate
2017// <0x0=>16x arithmetic
2018// <0x1=>16x fractional
2019// <0x2=>8x arithmetic
2020// <0x3=>8x fractional
2021// <0x4=>3x arithmetic
2022// <i> How many over-sampling bits used when sampling data state
2023// <id> usart_arch_sampr
Kévin Redon4e39b012019-01-30 15:55:58 +01002024#ifndef CONF_SERCOM_7_USART_SAMPR
2025#define CONF_SERCOM_7_USART_SAMPR 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002026#endif
2027
2028// <o> Sample Adjustment
2029// <0x0=>7-8-9 (3-4-5 8-bit over-sampling)
2030// <0x1=>9-10-11 (4-5-6 8-bit over-sampling)
2031// <0x2=>11-12-13 (5-6-7 8-bit over-sampling)
2032// <0x3=>13-14-15 (6-7-8 8-bit over-sampling)
2033// <i> Adjust which samples to use for data sampling in asynchronous mode
2034// <id> usart_arch_sampa
Kévin Redon4e39b012019-01-30 15:55:58 +01002035#ifndef CONF_SERCOM_7_USART_SAMPA
2036#define CONF_SERCOM_7_USART_SAMPA 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002037#endif
2038
2039// <o> Fractional Part <0-7>
2040// <i> Fractional part of the baud rate if baud rate generator is in fractional mode
2041// <id> usart_arch_fractional
Kévin Redon4e39b012019-01-30 15:55:58 +01002042#ifndef CONF_SERCOM_7_USART_FRACTIONAL
2043#define CONF_SERCOM_7_USART_FRACTIONAL 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002044#endif
2045
2046// <o> Data Order
2047// <0=>MSB is transmitted first
2048// <1=>LSB is transmitted first
2049// <i> Data order of the data bits in the frame
2050// <id> usart_arch_dord
Kévin Redon4e39b012019-01-30 15:55:58 +01002051#ifndef CONF_SERCOM_7_USART_DORD
2052#define CONF_SERCOM_7_USART_DORD 1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002053#endif
2054
2055// Does not do anything in UART mode
Kévin Redon4e39b012019-01-30 15:55:58 +01002056#define CONF_SERCOM_7_USART_CPOL 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002057
2058// <o> Encoding Format
2059// <0=>No encoding
2060// <1=>IrDA encoded
2061// <id> usart_arch_enc
Kévin Redon4e39b012019-01-30 15:55:58 +01002062#ifndef CONF_SERCOM_7_USART_ENC
2063#define CONF_SERCOM_7_USART_ENC 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002064#endif
2065
2066// <o> LIN Slave Enable
2067// <i> Break Character Detection and Auto-Baud/LIN Slave Enable.
2068// <i> Additional setting needed: 16x sample rate using fractional baud rate generation (CTRLA.SAMPR = 1).
2069// <0=>Disable
2070// <1=>Enable
2071// <id> usart_arch_lin_slave_enable
Kévin Redon4e39b012019-01-30 15:55:58 +01002072#ifndef CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE
2073#define CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002074#endif
2075
2076// <o> Debug Stop Mode
2077// <i> Behavior of the baud-rate generator when CPU is halted by external debugger.
2078// <0=>Keep running
2079// <1=>Halt
2080// <id> usart_arch_dbgstop
Kévin Redon4e39b012019-01-30 15:55:58 +01002081#ifndef CONF_SERCOM_7_USART_DEBUG_STOP_MODE
2082#define CONF_SERCOM_7_USART_DEBUG_STOP_MODE 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002083#endif
2084
2085// </e>
2086
Kévin Redon4e39b012019-01-30 15:55:58 +01002087#ifndef CONF_SERCOM_7_USART_INACK
2088#define CONF_SERCOM_7_USART_INACK 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002089#endif
2090
Kévin Redon4e39b012019-01-30 15:55:58 +01002091#ifndef CONF_SERCOM_7_USART_DSNACK
2092#define CONF_SERCOM_7_USART_DSNACK 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002093#endif
2094
Kévin Redon4e39b012019-01-30 15:55:58 +01002095#ifndef CONF_SERCOM_7_USART_MAXITER
2096#define CONF_SERCOM_7_USART_MAXITER 0x7
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002097#endif
2098
Kévin Redon4e39b012019-01-30 15:55:58 +01002099#ifndef CONF_SERCOM_7_USART_GTIME
2100#define CONF_SERCOM_7_USART_GTIME 0x2
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002101#endif
2102
Kévin Redon4e39b012019-01-30 15:55:58 +01002103#define CONF_SERCOM_7_USART_RXINV 0x0
2104#define CONF_SERCOM_7_USART_TXINV 0x0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002105
Kévin Redon4e39b012019-01-30 15:55:58 +01002106#ifndef CONF_SERCOM_7_USART_CMODE
2107#define CONF_SERCOM_7_USART_CMODE 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002108#endif
2109
Kévin Redon4e39b012019-01-30 15:55:58 +01002110#ifndef CONF_SERCOM_7_USART_RXPO
2111#define CONF_SERCOM_7_USART_RXPO 1 /* RX is on PIN_PB31 */
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002112#endif
2113
Kévin Redon4e39b012019-01-30 15:55:58 +01002114#ifndef CONF_SERCOM_7_USART_TXPO
2115#define CONF_SERCOM_7_USART_TXPO 0 /* TX is on PIN_PB30 */
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002116#endif
2117
2118/* Set correct parity settings in register interface based on PARITY setting */
Kévin Redon4e39b012019-01-30 15:55:58 +01002119#if CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE == 1
2120#if CONF_SERCOM_7_USART_PARITY == 0
2121#define CONF_SERCOM_7_USART_PMODE 0
2122#define CONF_SERCOM_7_USART_FORM 4
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002123#else
Kévin Redon4e39b012019-01-30 15:55:58 +01002124#define CONF_SERCOM_7_USART_PMODE CONF_SERCOM_7_USART_PARITY - 1
2125#define CONF_SERCOM_7_USART_FORM 5
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002126#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002127#else /* #if CONF_SERCOM_7_USART_LIN_SLAVE_ENABLE == 0 */
2128#if CONF_SERCOM_7_USART_PARITY == 0
2129#define CONF_SERCOM_7_USART_PMODE 0
2130#define CONF_SERCOM_7_USART_FORM 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002131#else
Kévin Redon4e39b012019-01-30 15:55:58 +01002132#define CONF_SERCOM_7_USART_PMODE CONF_SERCOM_7_USART_PARITY - 1
2133#define CONF_SERCOM_7_USART_FORM 1
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002134#endif
2135#endif
2136
2137// Calculate BAUD register value in UART mode
Kévin Redon4e39b012019-01-30 15:55:58 +01002138#if CONF_SERCOM_7_USART_SAMPR == 0
2139#ifndef CONF_SERCOM_7_USART_BAUD_RATE
2140#define CONF_SERCOM_7_USART_BAUD_RATE \
2141 65536 - ((65536 * 16.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002142#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002143#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
2144#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002145#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002146#elif CONF_SERCOM_7_USART_SAMPR == 1
2147#ifndef CONF_SERCOM_7_USART_BAUD_RATE
2148#define CONF_SERCOM_7_USART_BAUD_RATE \
2149 ((CONF_GCLK_SERCOM7_CORE_FREQUENCY) / (CONF_SERCOM_7_USART_BAUD * 16)) - (CONF_SERCOM_7_USART_FRACTIONAL / 8)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002150#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002151#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
2152#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002153#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002154#elif CONF_SERCOM_7_USART_SAMPR == 2
2155#ifndef CONF_SERCOM_7_USART_BAUD_RATE
2156#define CONF_SERCOM_7_USART_BAUD_RATE \
2157 65536 - ((65536 * 8.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002158#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002159#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
2160#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002161#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002162#elif CONF_SERCOM_7_USART_SAMPR == 3
2163#ifndef CONF_SERCOM_7_USART_BAUD_RATE
2164#define CONF_SERCOM_7_USART_BAUD_RATE \
2165 ((CONF_GCLK_SERCOM7_CORE_FREQUENCY) / (CONF_SERCOM_7_USART_BAUD * 8)) - (CONF_SERCOM_7_USART_FRACTIONAL / 8)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002166#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002167#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
2168#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002169#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002170#elif CONF_SERCOM_7_USART_SAMPR == 4
2171#ifndef CONF_SERCOM_7_USART_BAUD_RATE
2172#define CONF_SERCOM_7_USART_BAUD_RATE \
2173 65536 - ((65536 * 3.0f * CONF_SERCOM_7_USART_BAUD) / CONF_GCLK_SERCOM7_CORE_FREQUENCY)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002174#endif
Kévin Redon4e39b012019-01-30 15:55:58 +01002175#ifndef CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH
2176#define CONF_SERCOM_7_USART_RECEIVE_PULSE_LENGTH 0
Kévin Redon4cd3f7d2019-01-24 17:57:13 +01002177#endif
2178#endif
2179
2180// <<< end of configuration section >>>
2181
2182#endif // HPL_SERCOM_CONFIG_H