blob: 0b6b1909e448145c0e2627191569fc6fa41056bb [file] [log] [blame]
Kévin Redon69b92d92019-01-24 16:39:20 +01001/*
2 * Code generated from Atmel Start.
3 *
4 * This file will be overwritten when reconfiguring your Atmel Start project.
5 * Please copy examples or other code you want to keep to a separate file
6 * to avoid losing it when reconfiguring.
7 */
8
9#include "driver_init.h"
10#include <peripheral_clk_config.h>
11#include <utils.h>
12#include <hal_init.h>
13
Kévin Redonccbed0b2019-01-24 18:30:26 +010014/*! The buffer size for USART */
Kévin Redon1f8ecef2019-01-31 13:36:12 +010015#define SIM0_BUFFER_SIZE 16
16
17/*! The buffer size for USART */
18#define SIM1_BUFFER_SIZE 16
19
20/*! The buffer size for USART */
21#define SIM2_BUFFER_SIZE 16
22
23/*! The buffer size for USART */
24#define SIM3_BUFFER_SIZE 16
25
26/*! The buffer size for USART */
27#define SIM4_BUFFER_SIZE 16
28
29/*! The buffer size for USART */
30#define SIM5_BUFFER_SIZE 16
31
32/*! The buffer size for USART */
33#define SIM6_BUFFER_SIZE 16
34
Kévin Redonba3a2fa2019-03-07 15:52:27 +010035/*! The buffer size for USART */
Kévin Redon0c3533f2019-04-03 21:00:09 +020036#define UART_DEBUG_BUFFER_SIZE 256
Kévin Redonba3a2fa2019-03-07 15:52:27 +010037
Kévin Redon1f8ecef2019-01-31 13:36:12 +010038struct usart_async_descriptor SIM0;
39struct usart_async_descriptor SIM1;
40struct usart_async_descriptor SIM2;
41struct usart_async_descriptor SIM3;
42struct usart_async_descriptor SIM4;
43struct usart_async_descriptor SIM5;
44struct usart_async_descriptor SIM6;
Kévin Redonccbed0b2019-01-24 18:30:26 +010045
Kévin Redon1f8ecef2019-01-31 13:36:12 +010046static uint8_t SIM0_buffer[SIM0_BUFFER_SIZE];
47static uint8_t SIM1_buffer[SIM1_BUFFER_SIZE];
48static uint8_t SIM2_buffer[SIM2_BUFFER_SIZE];
49static uint8_t SIM3_buffer[SIM3_BUFFER_SIZE];
50static uint8_t SIM4_buffer[SIM4_BUFFER_SIZE];
51static uint8_t SIM5_buffer[SIM5_BUFFER_SIZE];
52static uint8_t SIM6_buffer[SIM6_BUFFER_SIZE];
Harald Welte361ed202019-02-24 21:15:39 +010053
Kévin Redon0c3533f2019-04-03 21:00:09 +020054struct usart_async_rings_descriptor UART_debug;
Kévin Redonba3a2fa2019-03-07 15:52:27 +010055
Kévin Redon0c3533f2019-04-03 21:00:09 +020056static uint8_t UART_DEBUG_buffer_rx[UART_DEBUG_BUFFER_SIZE];
57static uint8_t UART_DEBUG_buffer_tx[UART_DEBUG_BUFFER_SIZE];
Kévin Redonccbed0b2019-01-24 18:30:26 +010058
59/**
60 * \brief USART Clock initialization function
61 *
62 * Enables register interface and peripheral clock
63 */
Kévin Redon1f8ecef2019-01-31 13:36:12 +010064void SIM0_CLOCK_init()
65{
66
67 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
68 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
69
70 hri_mclk_set_APBAMASK_SERCOM0_bit(MCLK);
71}
72
73/**
74 * \brief USART pinmux initialization function
75 *
76 * Set each required pin to USART functionality
77 */
78void SIM0_PORT_init()
79{
80
81 gpio_set_pin_function(SIM0_IO, PINMUX_PA04D_SERCOM0_PAD0);
82}
83
84/**
85 * \brief USART initialization function
86 *
87 * Enables USART peripheral, clocks and initializes USART driver
88 */
89void SIM0_init(void)
90{
91 SIM0_CLOCK_init();
92 usart_async_init(&SIM0, SERCOM0, SIM0_buffer, SIM0_BUFFER_SIZE, (void *)NULL);
93 SIM0_PORT_init();
94}
95
96/**
97 * \brief USART Clock initialization function
98 *
99 * Enables register interface and peripheral clock
100 */
101void SIM1_CLOCK_init()
102{
103
104 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_CORE, CONF_GCLK_SERCOM1_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
105 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_SLOW, CONF_GCLK_SERCOM1_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
106
107 hri_mclk_set_APBAMASK_SERCOM1_bit(MCLK);
108}
109
110/**
111 * \brief USART pinmux initialization function
112 *
113 * Set each required pin to USART functionality
114 */
115void SIM1_PORT_init()
116{
117
118 gpio_set_pin_function(SIM1_IO, PINMUX_PA16C_SERCOM1_PAD0);
119}
120
121/**
122 * \brief USART initialization function
123 *
124 * Enables USART peripheral, clocks and initializes USART driver
125 */
126void SIM1_init(void)
127{
128 SIM1_CLOCK_init();
129 usart_async_init(&SIM1, SERCOM1, SIM1_buffer, SIM1_BUFFER_SIZE, (void *)NULL);
130 SIM1_PORT_init();
131}
132
133/**
134 * \brief USART Clock initialization function
135 *
136 * Enables register interface and peripheral clock
137 */
138void SIM2_CLOCK_init()
139{
140
141 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
142 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
143
144 hri_mclk_set_APBBMASK_SERCOM2_bit(MCLK);
145}
146
147/**
148 * \brief USART pinmux initialization function
149 *
150 * Set each required pin to USART functionality
151 */
152void SIM2_PORT_init()
153{
154
155 gpio_set_pin_function(SIM2_IO, PINMUX_PA09D_SERCOM2_PAD0);
156}
157
158/**
159 * \brief USART initialization function
160 *
161 * Enables USART peripheral, clocks and initializes USART driver
162 */
163void SIM2_init(void)
164{
165 SIM2_CLOCK_init();
166 usart_async_init(&SIM2, SERCOM2, SIM2_buffer, SIM2_BUFFER_SIZE, (void *)NULL);
167 SIM2_PORT_init();
168}
169
170/**
171 * \brief USART Clock initialization function
172 *
173 * Enables register interface and peripheral clock
174 */
175void SIM3_CLOCK_init()
176{
177
178 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
179 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
180
181 hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
182}
183
184/**
185 * \brief USART pinmux initialization function
186 *
187 * Set each required pin to USART functionality
188 */
189void SIM3_PORT_init()
190{
191
192 gpio_set_pin_function(SIM3_IO, PINMUX_PB20C_SERCOM3_PAD0);
193}
194
195/**
196 * \brief USART initialization function
197 *
198 * Enables USART peripheral, clocks and initializes USART driver
199 */
200void SIM3_init(void)
201{
202 SIM3_CLOCK_init();
203 usart_async_init(&SIM3, SERCOM3, SIM3_buffer, SIM3_BUFFER_SIZE, (void *)NULL);
204 SIM3_PORT_init();
205}
206
207/**
208 * \brief USART Clock initialization function
209 *
210 * Enables register interface and peripheral clock
211 */
212void SIM4_CLOCK_init()
213{
214
215 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_CORE, CONF_GCLK_SERCOM4_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
216 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_SLOW, CONF_GCLK_SERCOM4_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
217
218 hri_mclk_set_APBDMASK_SERCOM4_bit(MCLK);
219}
220
221/**
222 * \brief USART pinmux initialization function
223 *
224 * Set each required pin to USART functionality
225 */
226void SIM4_PORT_init()
227{
228
229 gpio_set_pin_function(SIM4_IO, PINMUX_PB08D_SERCOM4_PAD0);
230}
231
232/**
233 * \brief USART initialization function
234 *
235 * Enables USART peripheral, clocks and initializes USART driver
236 */
237void SIM4_init(void)
238{
239 SIM4_CLOCK_init();
240 usart_async_init(&SIM4, SERCOM4, SIM4_buffer, SIM4_BUFFER_SIZE, (void *)NULL);
241 SIM4_PORT_init();
242}
243
244/**
245 * \brief USART Clock initialization function
246 *
247 * Enables register interface and peripheral clock
248 */
249void SIM5_CLOCK_init()
250{
251
252 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_CORE, CONF_GCLK_SERCOM5_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
253 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_SLOW, CONF_GCLK_SERCOM5_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
254
255 hri_mclk_set_APBDMASK_SERCOM5_bit(MCLK);
256}
257
258/**
259 * \brief USART pinmux initialization function
260 *
261 * Set each required pin to USART functionality
262 */
263void SIM5_PORT_init()
264{
265
266 gpio_set_pin_function(SIM5_IO, PINMUX_PB16C_SERCOM5_PAD0);
267}
268
269/**
270 * \brief USART initialization function
271 *
272 * Enables USART peripheral, clocks and initializes USART driver
273 */
274void SIM5_init(void)
275{
276 SIM5_CLOCK_init();
277 usart_async_init(&SIM5, SERCOM5, SIM5_buffer, SIM5_BUFFER_SIZE, (void *)NULL);
278 SIM5_PORT_init();
279}
280
281/**
282 * \brief USART Clock initialization function
283 *
284 * Enables register interface and peripheral clock
285 */
286void SIM6_CLOCK_init()
287{
288
289 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_CORE, CONF_GCLK_SERCOM6_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
290 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_SLOW, CONF_GCLK_SERCOM6_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
291
292 hri_mclk_set_APBDMASK_SERCOM6_bit(MCLK);
293}
294
295/**
296 * \brief USART pinmux initialization function
297 *
298 * Set each required pin to USART functionality
299 */
300void SIM6_PORT_init()
301{
302
303 gpio_set_pin_function(SIM6_IO, PINMUX_PC16C_SERCOM6_PAD0);
304}
305
306/**
307 * \brief USART initialization function
308 *
309 * Enables USART peripheral, clocks and initializes USART driver
310 */
311void SIM6_init(void)
312{
313 SIM6_CLOCK_init();
314 usart_async_init(&SIM6, SERCOM6, SIM6_buffer, SIM6_BUFFER_SIZE, (void *)NULL);
315 SIM6_PORT_init();
316}
317
Kévin Redonba3a2fa2019-03-07 15:52:27 +0100318/**
319 * \brief USART Clock initialization function
320 *
321 * Enables register interface and peripheral clock
322 */
323void UART_debug_CLOCK_init()
324{
325
326 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
327 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
328
329 hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);
330}
331
332/**
333 * \brief USART pinmux initialization function
334 *
335 * Set each required pin to USART functionality
336 */
337void UART_debug_PORT_init()
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100338{
339
Kévin Redon4e39b012019-01-30 15:55:58 +0100340 gpio_set_pin_function(UART_TX, PINMUX_PB30C_SERCOM7_PAD0);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100341
Kévin Redon4e39b012019-01-30 15:55:58 +0100342 gpio_set_pin_function(UART_RX, PINMUX_PB31C_SERCOM7_PAD1);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100343}
344
Kévin Redonba3a2fa2019-03-07 15:52:27 +0100345/**
346 * \brief USART initialization function
347 *
348 * Enables USART peripheral, clocks and initializes USART driver
349 */
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100350void UART_debug_init(void)
351{
352 UART_debug_CLOCK_init();
Kévin Redon0c3533f2019-04-03 21:00:09 +0200353 usart_async_rings_init(&UART_debug, SERCOM7, UART_DEBUG_buffer_rx, UART_DEBUG_BUFFER_SIZE, UART_DEBUG_buffer_tx, UART_DEBUG_BUFFER_SIZE, (void *)NULL);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100354 UART_debug_PORT_init();
355}
356
Kévin Redon69b92d92019-01-24 16:39:20 +0100357void USB_DEVICE_INSTANCE_PORT_init(void)
358{
359
Kévin Redon4e39b012019-01-30 15:55:58 +0100360 gpio_set_pin_direction(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100361 // <y> Pin direction
362 // <id> pad_direction
363 // <GPIO_DIRECTION_OFF"> Off
364 // <GPIO_DIRECTION_IN"> In
365 // <GPIO_DIRECTION_OUT"> Out
366 GPIO_DIRECTION_OUT);
367
Kévin Redon4e39b012019-01-30 15:55:58 +0100368 gpio_set_pin_level(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100369 // <y> Initial level
370 // <id> pad_initial_level
371 // <false"> Low
372 // <true"> High
373 false);
374
Kévin Redon4e39b012019-01-30 15:55:58 +0100375 gpio_set_pin_pull_mode(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100376 // <y> Pull configuration
377 // <id> pad_pull_config
378 // <GPIO_PULL_OFF"> Off
379 // <GPIO_PULL_UP"> Pull-up
380 // <GPIO_PULL_DOWN"> Pull-down
381 GPIO_PULL_OFF);
382
Kévin Redon4e39b012019-01-30 15:55:58 +0100383 gpio_set_pin_function(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100384 // <y> Pin function
385 // <id> pad_function
386 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
387 // <PINMUX_PA24H_USB_DM"> Auto
388 // <GPIO_PIN_FUNCTION_OFF"> Off
389 // <GPIO_PIN_FUNCTION_A"> A
390 // <GPIO_PIN_FUNCTION_B"> B
391 // <GPIO_PIN_FUNCTION_C"> C
392 // <GPIO_PIN_FUNCTION_D"> D
393 // <GPIO_PIN_FUNCTION_E"> E
394 // <GPIO_PIN_FUNCTION_F"> F
395 // <GPIO_PIN_FUNCTION_G"> G
396 // <GPIO_PIN_FUNCTION_H"> H
397 // <GPIO_PIN_FUNCTION_I"> I
398 // <GPIO_PIN_FUNCTION_J"> J
399 // <GPIO_PIN_FUNCTION_K"> K
400 // <GPIO_PIN_FUNCTION_L"> L
401 // <GPIO_PIN_FUNCTION_M"> M
402 // <GPIO_PIN_FUNCTION_N"> N
403 PINMUX_PA24H_USB_DM);
404
Kévin Redon4e39b012019-01-30 15:55:58 +0100405 gpio_set_pin_direction(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100406 // <y> Pin direction
407 // <id> pad_direction
408 // <GPIO_DIRECTION_OFF"> Off
409 // <GPIO_DIRECTION_IN"> In
410 // <GPIO_DIRECTION_OUT"> Out
411 GPIO_DIRECTION_OUT);
412
Kévin Redon4e39b012019-01-30 15:55:58 +0100413 gpio_set_pin_level(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100414 // <y> Initial level
415 // <id> pad_initial_level
416 // <false"> Low
417 // <true"> High
418 false);
419
Kévin Redon4e39b012019-01-30 15:55:58 +0100420 gpio_set_pin_pull_mode(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100421 // <y> Pull configuration
422 // <id> pad_pull_config
423 // <GPIO_PULL_OFF"> Off
424 // <GPIO_PULL_UP"> Pull-up
425 // <GPIO_PULL_DOWN"> Pull-down
426 GPIO_PULL_OFF);
427
Kévin Redon4e39b012019-01-30 15:55:58 +0100428 gpio_set_pin_function(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100429 // <y> Pin function
430 // <id> pad_function
431 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
432 // <PINMUX_PA25H_USB_DP"> Auto
433 // <GPIO_PIN_FUNCTION_OFF"> Off
434 // <GPIO_PIN_FUNCTION_A"> A
435 // <GPIO_PIN_FUNCTION_B"> B
436 // <GPIO_PIN_FUNCTION_C"> C
437 // <GPIO_PIN_FUNCTION_D"> D
438 // <GPIO_PIN_FUNCTION_E"> E
439 // <GPIO_PIN_FUNCTION_F"> F
440 // <GPIO_PIN_FUNCTION_G"> G
441 // <GPIO_PIN_FUNCTION_H"> H
442 // <GPIO_PIN_FUNCTION_I"> I
443 // <GPIO_PIN_FUNCTION_J"> J
444 // <GPIO_PIN_FUNCTION_K"> K
445 // <GPIO_PIN_FUNCTION_L"> L
446 // <GPIO_PIN_FUNCTION_M"> M
447 // <GPIO_PIN_FUNCTION_N"> N
448 PINMUX_PA25H_USB_DP);
449}
450
451/* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
452 * for low speed and full speed operation. */
453#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || (CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
454#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
455#endif
456
457void USB_DEVICE_INSTANCE_CLOCK_init(void)
458{
459
460 hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
461 hri_mclk_set_AHBMASK_USB_bit(MCLK);
462 hri_mclk_set_APBBMASK_USB_bit(MCLK);
463}
464
465void USB_DEVICE_INSTANCE_init(void)
466{
467 USB_DEVICE_INSTANCE_CLOCK_init();
468 usb_d_init();
469 USB_DEVICE_INSTANCE_PORT_init();
470}
471
472void system_init(void)
473{
474 init_mcu();
475
Harald Welte092494e2019-02-24 10:33:40 +0100476 // GPIO on PA02
477
478 // Set pin direction to input
479 gpio_set_pin_direction(SIM4_INT, GPIO_DIRECTION_IN);
480
481 gpio_set_pin_pull_mode(SIM4_INT,
482 // <y> Pull configuration
483 // <id> pad_pull_config
484 // <GPIO_PULL_OFF"> Off
485 // <GPIO_PULL_UP"> Pull-up
486 // <GPIO_PULL_DOWN"> Pull-down
487 GPIO_PULL_OFF);
488
489 gpio_set_pin_function(SIM4_INT, GPIO_PIN_FUNCTION_OFF);
490
491 // GPIO on PA03
492
493 // Set pin direction to input
494 gpio_set_pin_direction(SIM5_INT, GPIO_DIRECTION_IN);
495
496 gpio_set_pin_pull_mode(SIM5_INT,
497 // <y> Pull configuration
498 // <id> pad_pull_config
499 // <GPIO_PULL_OFF"> Off
500 // <GPIO_PULL_UP"> Pull-up
501 // <GPIO_PULL_DOWN"> Pull-down
502 GPIO_PULL_OFF);
503
504 gpio_set_pin_function(SIM5_INT, GPIO_PIN_FUNCTION_OFF);
505
Kévin Redon6a8295c2019-01-30 18:58:44 +0100506 // GPIO on PA11
507
508 gpio_set_pin_direction(SIMCLK_20MHZ,
509 // <y> Pin direction
510 // <id> pad_direction
511 // <GPIO_DIRECTION_OFF"> Off
512 // <GPIO_DIRECTION_IN"> In
513 // <GPIO_DIRECTION_OUT"> Out
514 GPIO_DIRECTION_OUT);
515
516 gpio_set_pin_level(SIMCLK_20MHZ,
517 // <y> Initial level
518 // <id> pad_initial_level
519 // <false"> Low
520 // <true"> High
521 false);
522
523 gpio_set_pin_pull_mode(SIMCLK_20MHZ,
524 // <y> Pull configuration
525 // <id> pad_pull_config
526 // <GPIO_PULL_OFF"> Off
527 // <GPIO_PULL_UP"> Pull-up
528 // <GPIO_PULL_DOWN"> Pull-down
529 GPIO_PULL_OFF);
530
531 gpio_set_pin_function(SIMCLK_20MHZ,
532 // <y> Pin function
533 // <id> pad_function
534 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
535 // <GPIO_PIN_FUNCTION_OFF"> Auto
536 // <GPIO_PIN_FUNCTION_OFF"> Off
537 // <GPIO_PIN_FUNCTION_A"> A
538 // <GPIO_PIN_FUNCTION_B"> B
539 // <GPIO_PIN_FUNCTION_C"> C
540 // <GPIO_PIN_FUNCTION_D"> D
541 // <GPIO_PIN_FUNCTION_E"> E
542 // <GPIO_PIN_FUNCTION_F"> F
543 // <GPIO_PIN_FUNCTION_G"> G
544 // <GPIO_PIN_FUNCTION_H"> H
545 // <GPIO_PIN_FUNCTION_I"> I
546 // <GPIO_PIN_FUNCTION_J"> J
547 // <GPIO_PIN_FUNCTION_K"> K
548 // <GPIO_PIN_FUNCTION_L"> L
549 // <GPIO_PIN_FUNCTION_M"> M
550 // <GPIO_PIN_FUNCTION_N"> N
551 GPIO_PIN_FUNCTION_M);
552
553 // GPIO on PA20
554
555 // Set pin direction to input
556 gpio_set_pin_direction(VB0, GPIO_DIRECTION_IN);
557
558 gpio_set_pin_pull_mode(VB0,
559 // <y> Pull configuration
560 // <id> pad_pull_config
561 // <GPIO_PULL_OFF"> Off
562 // <GPIO_PULL_UP"> Pull-up
563 // <GPIO_PULL_DOWN"> Pull-down
564 GPIO_PULL_OFF);
565
566 gpio_set_pin_function(VB0, GPIO_PIN_FUNCTION_OFF);
567
568 // GPIO on PA21
569
570 // Set pin direction to input
571 gpio_set_pin_direction(VB1, GPIO_DIRECTION_IN);
572
573 gpio_set_pin_pull_mode(VB1,
574 // <y> Pull configuration
575 // <id> pad_pull_config
576 // <GPIO_PULL_OFF"> Off
577 // <GPIO_PULL_UP"> Pull-up
578 // <GPIO_PULL_DOWN"> Pull-down
579 GPIO_PULL_OFF);
580
581 gpio_set_pin_function(VB1, GPIO_PIN_FUNCTION_OFF);
582
583 // GPIO on PA22
584
585 // Set pin direction to input
586 gpio_set_pin_direction(VB2, GPIO_DIRECTION_IN);
587
588 gpio_set_pin_pull_mode(VB2,
589 // <y> Pull configuration
590 // <id> pad_pull_config
591 // <GPIO_PULL_OFF"> Off
592 // <GPIO_PULL_UP"> Pull-up
593 // <GPIO_PULL_DOWN"> Pull-down
594 GPIO_PULL_OFF);
595
596 gpio_set_pin_function(VB2, GPIO_PIN_FUNCTION_OFF);
597
598 // GPIO on PA23
599
600 // Set pin direction to input
601 gpio_set_pin_direction(VB3, GPIO_DIRECTION_IN);
602
603 gpio_set_pin_pull_mode(VB3,
604 // <y> Pull configuration
605 // <id> pad_pull_config
606 // <GPIO_PULL_OFF"> Off
607 // <GPIO_PULL_UP"> Pull-up
608 // <GPIO_PULL_DOWN"> Pull-down
609 GPIO_PULL_OFF);
610
611 gpio_set_pin_function(VB3, GPIO_PIN_FUNCTION_OFF);
612
Harald Welte092494e2019-02-24 10:33:40 +0100613 // GPIO on PB02
614
615 gpio_set_pin_level(SCL2,
616 // <y> Initial level
617 // <id> pad_initial_level
618 // <false"> Low
619 // <true"> High
620 false);
621
622 // Set pin direction to output
623 gpio_set_pin_direction(SCL2, GPIO_DIRECTION_OUT);
624
625 gpio_set_pin_function(SCL2, GPIO_PIN_FUNCTION_OFF);
626
627 // GPIO on PB03
628
629 gpio_set_pin_level(SDA2,
630 // <y> Initial level
631 // <id> pad_initial_level
632 // <false"> Low
633 // <true"> High
634 false);
635
636 // Set pin direction to output
637 gpio_set_pin_direction(SDA2, GPIO_DIRECTION_OUT);
638
639 gpio_set_pin_function(SDA2, GPIO_PIN_FUNCTION_OFF);
640
641 // GPIO on PB04
642
643 // Set pin direction to input
644 gpio_set_pin_direction(SIM6_INT, GPIO_DIRECTION_IN);
645
646 gpio_set_pin_pull_mode(SIM6_INT,
647 // <y> Pull configuration
648 // <id> pad_pull_config
649 // <GPIO_PULL_OFF"> Off
650 // <GPIO_PULL_UP"> Pull-up
651 // <GPIO_PULL_DOWN"> Pull-down
652 GPIO_PULL_OFF);
653
654 gpio_set_pin_function(SIM6_INT, GPIO_PIN_FUNCTION_OFF);
655
656 // GPIO on PB05
657
658 // Set pin direction to input
659 gpio_set_pin_direction(SIM7_INT, GPIO_DIRECTION_IN);
660
661 gpio_set_pin_pull_mode(SIM7_INT,
662 // <y> Pull configuration
663 // <id> pad_pull_config
664 // <GPIO_PULL_OFF"> Off
665 // <GPIO_PULL_UP"> Pull-up
666 // <GPIO_PULL_DOWN"> Pull-down
667 GPIO_PULL_OFF);
668
669 gpio_set_pin_function(SIM7_INT, GPIO_PIN_FUNCTION_OFF);
670
671 // GPIO on PB06
672
673 gpio_set_pin_level(SCL3,
674 // <y> Initial level
675 // <id> pad_initial_level
676 // <false"> Low
677 // <true"> High
678 false);
679
680 // Set pin direction to output
681 gpio_set_pin_direction(SCL3, GPIO_DIRECTION_OUT);
682
683 gpio_set_pin_function(SCL3, GPIO_PIN_FUNCTION_OFF);
684
685 // GPIO on PB07
686
687 gpio_set_pin_level(SDA3,
688 // <y> Initial level
689 // <id> pad_initial_level
690 // <false"> Low
691 // <true"> High
692 false);
693
694 // Set pin direction to output
695 gpio_set_pin_direction(SDA3, GPIO_DIRECTION_OUT);
696
697 gpio_set_pin_function(SDA3, GPIO_PIN_FUNCTION_OFF);
698
699 // GPIO on PB14
700
701 gpio_set_pin_level(SCL1,
702 // <y> Initial level
703 // <id> pad_initial_level
704 // <false"> Low
705 // <true"> High
706 false);
707
708 // Set pin direction to output
709 gpio_set_pin_direction(SCL1, GPIO_DIRECTION_OUT);
710
711 gpio_set_pin_function(SCL1, GPIO_PIN_FUNCTION_OFF);
712
713 // GPIO on PB15
714
715 gpio_set_pin_level(SDA1,
716 // <y> Initial level
717 // <id> pad_initial_level
718 // <false"> Low
719 // <true"> High
720 false);
721
722 // Set pin direction to output
723 gpio_set_pin_direction(SDA1, GPIO_DIRECTION_OUT);
724
725 gpio_set_pin_function(SDA1, GPIO_PIN_FUNCTION_OFF);
726
727 // GPIO on PC00
728
729 // Set pin direction to input
730 gpio_set_pin_direction(SIM0_INT, GPIO_DIRECTION_IN);
731
732 gpio_set_pin_pull_mode(SIM0_INT,
733 // <y> Pull configuration
734 // <id> pad_pull_config
735 // <GPIO_PULL_OFF"> Off
736 // <GPIO_PULL_UP"> Pull-up
737 // <GPIO_PULL_DOWN"> Pull-down
738 GPIO_PULL_OFF);
739
740 gpio_set_pin_function(SIM0_INT, GPIO_PIN_FUNCTION_OFF);
741
742 // GPIO on PC01
743
744 // Set pin direction to input
745 gpio_set_pin_direction(SIM1_INT, GPIO_DIRECTION_IN);
746
747 gpio_set_pin_pull_mode(SIM1_INT,
748 // <y> Pull configuration
749 // <id> pad_pull_config
750 // <GPIO_PULL_OFF"> Off
751 // <GPIO_PULL_UP"> Pull-up
752 // <GPIO_PULL_DOWN"> Pull-down
753 GPIO_PULL_OFF);
754
755 gpio_set_pin_function(SIM1_INT, GPIO_PIN_FUNCTION_OFF);
756
757 // GPIO on PC02
758
759 // Set pin direction to input
760 gpio_set_pin_direction(SIM2_INT, GPIO_DIRECTION_IN);
761
762 gpio_set_pin_pull_mode(SIM2_INT,
763 // <y> Pull configuration
764 // <id> pad_pull_config
765 // <GPIO_PULL_OFF"> Off
766 // <GPIO_PULL_UP"> Pull-up
767 // <GPIO_PULL_DOWN"> Pull-down
768 GPIO_PULL_OFF);
769
770 gpio_set_pin_function(SIM2_INT, GPIO_PIN_FUNCTION_OFF);
771
772 // GPIO on PC03
773
774 // Set pin direction to input
775 gpio_set_pin_direction(SIM3_INT, GPIO_DIRECTION_IN);
776
777 gpio_set_pin_pull_mode(SIM3_INT,
778 // <y> Pull configuration
779 // <id> pad_pull_config
780 // <GPIO_PULL_OFF"> Off
781 // <GPIO_PULL_UP"> Pull-up
782 // <GPIO_PULL_DOWN"> Pull-down
783 GPIO_PULL_OFF);
784
785 gpio_set_pin_function(SIM3_INT, GPIO_PIN_FUNCTION_OFF);
786
Kévin Redon6a8295c2019-01-30 18:58:44 +0100787 // GPIO on PC14
788
789 // Set pin direction to input
790 gpio_set_pin_direction(SWITCH, GPIO_DIRECTION_IN);
791
792 gpio_set_pin_pull_mode(SWITCH,
793 // <y> Pull configuration
794 // <id> pad_pull_config
795 // <GPIO_PULL_OFF"> Off
796 // <GPIO_PULL_UP"> Pull-up
797 // <GPIO_PULL_DOWN"> Pull-down
798 GPIO_PULL_OFF);
799
800 gpio_set_pin_function(SWITCH, GPIO_PIN_FUNCTION_OFF);
801
Harald Welte092494e2019-02-24 10:33:40 +0100802 // GPIO on PC15
803
804 // Set pin direction to input
Kévin Redon3c045b22019-02-26 19:52:02 +0100805 gpio_set_pin_direction(MUX_STAT, GPIO_DIRECTION_IN);
Harald Welte092494e2019-02-24 10:33:40 +0100806
Kévin Redon3c045b22019-02-26 19:52:02 +0100807 gpio_set_pin_pull_mode(MUX_STAT,
Harald Welte092494e2019-02-24 10:33:40 +0100808 // <y> Pull configuration
809 // <id> pad_pull_config
810 // <GPIO_PULL_OFF"> Off
811 // <GPIO_PULL_UP"> Pull-up
812 // <GPIO_PULL_DOWN"> Pull-down
813 GPIO_PULL_OFF);
814
Kévin Redon3c045b22019-02-26 19:52:02 +0100815 gpio_set_pin_function(MUX_STAT, GPIO_PIN_FUNCTION_OFF);
Harald Welte092494e2019-02-24 10:33:40 +0100816
Kévin Redon4e39b012019-01-30 15:55:58 +0100817 // GPIO on PC26
Kévin Redon5908a5c2019-01-24 18:45:23 +0100818
Kévin Redon6a8295c2019-01-30 18:58:44 +0100819 gpio_set_pin_level(USER_LED,
Kévin Redon5908a5c2019-01-24 18:45:23 +0100820 // <y> Initial level
821 // <id> pad_initial_level
822 // <false"> Low
823 // <true"> High
Kévin Redon4e39b012019-01-30 15:55:58 +0100824 false);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100825
826 // Set pin direction to output
Kévin Redon6a8295c2019-01-30 18:58:44 +0100827 gpio_set_pin_direction(USER_LED, GPIO_DIRECTION_OUT);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100828
Kévin Redon6a8295c2019-01-30 18:58:44 +0100829 gpio_set_pin_function(USER_LED, GPIO_PIN_FUNCTION_OFF);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100830
Harald Welte092494e2019-02-24 10:33:40 +0100831 // GPIO on PC27
832
833 gpio_set_pin_level(SCL4,
834 // <y> Initial level
835 // <id> pad_initial_level
836 // <false"> Low
837 // <true"> High
838 false);
839
840 // Set pin direction to output
841 gpio_set_pin_direction(SCL4, GPIO_DIRECTION_OUT);
842
843 gpio_set_pin_function(SCL4, GPIO_PIN_FUNCTION_OFF);
844
845 // GPIO on PC28
846
847 gpio_set_pin_level(SDA4,
848 // <y> Initial level
849 // <id> pad_initial_level
850 // <false"> Low
851 // <true"> High
852 false);
853
854 // Set pin direction to output
855 gpio_set_pin_direction(SDA4, GPIO_DIRECTION_OUT);
856
857 gpio_set_pin_function(SDA4, GPIO_PIN_FUNCTION_OFF);
858
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100859 SIM0_init();
860 SIM1_init();
861 SIM2_init();
862 SIM3_init();
863 SIM4_init();
864 SIM5_init();
865 SIM6_init();
Harald Welte361ed202019-02-24 21:15:39 +0100866
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100867 UART_debug_init();
868
Kévin Redon69b92d92019-01-24 16:39:20 +0100869 USB_DEVICE_INSTANCE_init();
870}