blob: a1967918e67cb1990378ebf4b5ab3b5a92a64712 [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
35/*! The buffer size for USART */
Kévin Redonccbed0b2019-01-24 18:30:26 +010036#define UART_DEBUG_BUFFER_SIZE 16
Kévin Redon4cd3f7d2019-01-24 17:57:13 +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 +010045struct usart_async_descriptor UART_debug;
46
Kévin Redon1f8ecef2019-01-31 13:36:12 +010047static uint8_t SIM0_buffer[SIM0_BUFFER_SIZE];
48static uint8_t SIM1_buffer[SIM1_BUFFER_SIZE];
49static uint8_t SIM2_buffer[SIM2_BUFFER_SIZE];
50static uint8_t SIM3_buffer[SIM3_BUFFER_SIZE];
51static uint8_t SIM4_buffer[SIM4_BUFFER_SIZE];
52static uint8_t SIM5_buffer[SIM5_BUFFER_SIZE];
53static uint8_t SIM6_buffer[SIM6_BUFFER_SIZE];
Kévin Redonccbed0b2019-01-24 18:30:26 +010054static uint8_t UART_debug_buffer[UART_DEBUG_BUFFER_SIZE];
55
56/**
57 * \brief USART Clock initialization function
58 *
59 * Enables register interface and peripheral clock
60 */
Kévin Redon1f8ecef2019-01-31 13:36:12 +010061void SIM0_CLOCK_init()
62{
63
64 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
65 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
66
67 hri_mclk_set_APBAMASK_SERCOM0_bit(MCLK);
68}
69
70/**
71 * \brief USART pinmux initialization function
72 *
73 * Set each required pin to USART functionality
74 */
75void SIM0_PORT_init()
76{
77
78 gpio_set_pin_function(SIM0_IO, PINMUX_PA04D_SERCOM0_PAD0);
79}
80
81/**
82 * \brief USART initialization function
83 *
84 * Enables USART peripheral, clocks and initializes USART driver
85 */
86void SIM0_init(void)
87{
88 SIM0_CLOCK_init();
89 usart_async_init(&SIM0, SERCOM0, SIM0_buffer, SIM0_BUFFER_SIZE, (void *)NULL);
90 SIM0_PORT_init();
91}
92
93/**
94 * \brief USART Clock initialization function
95 *
96 * Enables register interface and peripheral clock
97 */
98void SIM1_CLOCK_init()
99{
100
101 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_CORE, CONF_GCLK_SERCOM1_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
102 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_SLOW, CONF_GCLK_SERCOM1_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
103
104 hri_mclk_set_APBAMASK_SERCOM1_bit(MCLK);
105}
106
107/**
108 * \brief USART pinmux initialization function
109 *
110 * Set each required pin to USART functionality
111 */
112void SIM1_PORT_init()
113{
114
115 gpio_set_pin_function(SIM1_IO, PINMUX_PA16C_SERCOM1_PAD0);
116}
117
118/**
119 * \brief USART initialization function
120 *
121 * Enables USART peripheral, clocks and initializes USART driver
122 */
123void SIM1_init(void)
124{
125 SIM1_CLOCK_init();
126 usart_async_init(&SIM1, SERCOM1, SIM1_buffer, SIM1_BUFFER_SIZE, (void *)NULL);
127 SIM1_PORT_init();
128}
129
130/**
131 * \brief USART Clock initialization function
132 *
133 * Enables register interface and peripheral clock
134 */
135void SIM2_CLOCK_init()
136{
137
138 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
139 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
140
141 hri_mclk_set_APBBMASK_SERCOM2_bit(MCLK);
142}
143
144/**
145 * \brief USART pinmux initialization function
146 *
147 * Set each required pin to USART functionality
148 */
149void SIM2_PORT_init()
150{
151
152 gpio_set_pin_function(SIM2_IO, PINMUX_PA09D_SERCOM2_PAD0);
153}
154
155/**
156 * \brief USART initialization function
157 *
158 * Enables USART peripheral, clocks and initializes USART driver
159 */
160void SIM2_init(void)
161{
162 SIM2_CLOCK_init();
163 usart_async_init(&SIM2, SERCOM2, SIM2_buffer, SIM2_BUFFER_SIZE, (void *)NULL);
164 SIM2_PORT_init();
165}
166
167/**
168 * \brief USART Clock initialization function
169 *
170 * Enables register interface and peripheral clock
171 */
172void SIM3_CLOCK_init()
173{
174
175 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
176 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
177
178 hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
179}
180
181/**
182 * \brief USART pinmux initialization function
183 *
184 * Set each required pin to USART functionality
185 */
186void SIM3_PORT_init()
187{
188
189 gpio_set_pin_function(SIM3_IO, PINMUX_PB20C_SERCOM3_PAD0);
190}
191
192/**
193 * \brief USART initialization function
194 *
195 * Enables USART peripheral, clocks and initializes USART driver
196 */
197void SIM3_init(void)
198{
199 SIM3_CLOCK_init();
200 usart_async_init(&SIM3, SERCOM3, SIM3_buffer, SIM3_BUFFER_SIZE, (void *)NULL);
201 SIM3_PORT_init();
202}
203
204/**
205 * \brief USART Clock initialization function
206 *
207 * Enables register interface and peripheral clock
208 */
209void SIM4_CLOCK_init()
210{
211
212 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_CORE, CONF_GCLK_SERCOM4_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
213 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_SLOW, CONF_GCLK_SERCOM4_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
214
215 hri_mclk_set_APBDMASK_SERCOM4_bit(MCLK);
216}
217
218/**
219 * \brief USART pinmux initialization function
220 *
221 * Set each required pin to USART functionality
222 */
223void SIM4_PORT_init()
224{
225
226 gpio_set_pin_function(SIM4_IO, PINMUX_PB08D_SERCOM4_PAD0);
227}
228
229/**
230 * \brief USART initialization function
231 *
232 * Enables USART peripheral, clocks and initializes USART driver
233 */
234void SIM4_init(void)
235{
236 SIM4_CLOCK_init();
237 usart_async_init(&SIM4, SERCOM4, SIM4_buffer, SIM4_BUFFER_SIZE, (void *)NULL);
238 SIM4_PORT_init();
239}
240
241/**
242 * \brief USART Clock initialization function
243 *
244 * Enables register interface and peripheral clock
245 */
246void SIM5_CLOCK_init()
247{
248
249 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_CORE, CONF_GCLK_SERCOM5_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
250 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_SLOW, CONF_GCLK_SERCOM5_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
251
252 hri_mclk_set_APBDMASK_SERCOM5_bit(MCLK);
253}
254
255/**
256 * \brief USART pinmux initialization function
257 *
258 * Set each required pin to USART functionality
259 */
260void SIM5_PORT_init()
261{
262
263 gpio_set_pin_function(SIM5_IO, PINMUX_PB16C_SERCOM5_PAD0);
264}
265
266/**
267 * \brief USART initialization function
268 *
269 * Enables USART peripheral, clocks and initializes USART driver
270 */
271void SIM5_init(void)
272{
273 SIM5_CLOCK_init();
274 usart_async_init(&SIM5, SERCOM5, SIM5_buffer, SIM5_BUFFER_SIZE, (void *)NULL);
275 SIM5_PORT_init();
276}
277
278/**
279 * \brief USART Clock initialization function
280 *
281 * Enables register interface and peripheral clock
282 */
283void SIM6_CLOCK_init()
284{
285
286 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_CORE, CONF_GCLK_SERCOM6_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
287 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_SLOW, CONF_GCLK_SERCOM6_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
288
289 hri_mclk_set_APBDMASK_SERCOM6_bit(MCLK);
290}
291
292/**
293 * \brief USART pinmux initialization function
294 *
295 * Set each required pin to USART functionality
296 */
297void SIM6_PORT_init()
298{
299
300 gpio_set_pin_function(SIM6_IO, PINMUX_PC16C_SERCOM6_PAD0);
301}
302
303/**
304 * \brief USART initialization function
305 *
306 * Enables USART peripheral, clocks and initializes USART driver
307 */
308void SIM6_init(void)
309{
310 SIM6_CLOCK_init();
311 usart_async_init(&SIM6, SERCOM6, SIM6_buffer, SIM6_BUFFER_SIZE, (void *)NULL);
312 SIM6_PORT_init();
313}
314
315/**
316 * \brief USART Clock initialization function
317 *
318 * Enables register interface and peripheral clock
319 */
Kévin Redonccbed0b2019-01-24 18:30:26 +0100320void UART_debug_CLOCK_init()
321{
322
Kévin Redon4e39b012019-01-30 15:55:58 +0100323 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
324 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
Kévin Redonccbed0b2019-01-24 18:30:26 +0100325
Kévin Redon4e39b012019-01-30 15:55:58 +0100326 hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);
Kévin Redonccbed0b2019-01-24 18:30:26 +0100327}
328
329/**
330 * \brief USART pinmux initialization function
331 *
332 * Set each required pin to USART functionality
333 */
334void UART_debug_PORT_init()
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100335{
336
Kévin Redon4e39b012019-01-30 15:55:58 +0100337 gpio_set_pin_function(UART_TX, PINMUX_PB30C_SERCOM7_PAD0);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100338
Kévin Redon4e39b012019-01-30 15:55:58 +0100339 gpio_set_pin_function(UART_RX, PINMUX_PB31C_SERCOM7_PAD1);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100340}
341
Kévin Redonccbed0b2019-01-24 18:30:26 +0100342/**
343 * \brief USART initialization function
344 *
345 * Enables USART peripheral, clocks and initializes USART driver
346 */
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100347void UART_debug_init(void)
348{
349 UART_debug_CLOCK_init();
Kévin Redon4e39b012019-01-30 15:55:58 +0100350 usart_async_init(&UART_debug, SERCOM7, UART_debug_buffer, UART_DEBUG_BUFFER_SIZE, (void *)NULL);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100351 UART_debug_PORT_init();
352}
353
Kévin Redon69b92d92019-01-24 16:39:20 +0100354void USB_DEVICE_INSTANCE_PORT_init(void)
355{
356
Kévin Redon4e39b012019-01-30 15:55:58 +0100357 gpio_set_pin_direction(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100358 // <y> Pin direction
359 // <id> pad_direction
360 // <GPIO_DIRECTION_OFF"> Off
361 // <GPIO_DIRECTION_IN"> In
362 // <GPIO_DIRECTION_OUT"> Out
363 GPIO_DIRECTION_OUT);
364
Kévin Redon4e39b012019-01-30 15:55:58 +0100365 gpio_set_pin_level(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100366 // <y> Initial level
367 // <id> pad_initial_level
368 // <false"> Low
369 // <true"> High
370 false);
371
Kévin Redon4e39b012019-01-30 15:55:58 +0100372 gpio_set_pin_pull_mode(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100373 // <y> Pull configuration
374 // <id> pad_pull_config
375 // <GPIO_PULL_OFF"> Off
376 // <GPIO_PULL_UP"> Pull-up
377 // <GPIO_PULL_DOWN"> Pull-down
378 GPIO_PULL_OFF);
379
Kévin Redon4e39b012019-01-30 15:55:58 +0100380 gpio_set_pin_function(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100381 // <y> Pin function
382 // <id> pad_function
383 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
384 // <PINMUX_PA24H_USB_DM"> Auto
385 // <GPIO_PIN_FUNCTION_OFF"> Off
386 // <GPIO_PIN_FUNCTION_A"> A
387 // <GPIO_PIN_FUNCTION_B"> B
388 // <GPIO_PIN_FUNCTION_C"> C
389 // <GPIO_PIN_FUNCTION_D"> D
390 // <GPIO_PIN_FUNCTION_E"> E
391 // <GPIO_PIN_FUNCTION_F"> F
392 // <GPIO_PIN_FUNCTION_G"> G
393 // <GPIO_PIN_FUNCTION_H"> H
394 // <GPIO_PIN_FUNCTION_I"> I
395 // <GPIO_PIN_FUNCTION_J"> J
396 // <GPIO_PIN_FUNCTION_K"> K
397 // <GPIO_PIN_FUNCTION_L"> L
398 // <GPIO_PIN_FUNCTION_M"> M
399 // <GPIO_PIN_FUNCTION_N"> N
400 PINMUX_PA24H_USB_DM);
401
Kévin Redon4e39b012019-01-30 15:55:58 +0100402 gpio_set_pin_direction(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100403 // <y> Pin direction
404 // <id> pad_direction
405 // <GPIO_DIRECTION_OFF"> Off
406 // <GPIO_DIRECTION_IN"> In
407 // <GPIO_DIRECTION_OUT"> Out
408 GPIO_DIRECTION_OUT);
409
Kévin Redon4e39b012019-01-30 15:55:58 +0100410 gpio_set_pin_level(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100411 // <y> Initial level
412 // <id> pad_initial_level
413 // <false"> Low
414 // <true"> High
415 false);
416
Kévin Redon4e39b012019-01-30 15:55:58 +0100417 gpio_set_pin_pull_mode(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100418 // <y> Pull configuration
419 // <id> pad_pull_config
420 // <GPIO_PULL_OFF"> Off
421 // <GPIO_PULL_UP"> Pull-up
422 // <GPIO_PULL_DOWN"> Pull-down
423 GPIO_PULL_OFF);
424
Kévin Redon4e39b012019-01-30 15:55:58 +0100425 gpio_set_pin_function(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100426 // <y> Pin function
427 // <id> pad_function
428 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
429 // <PINMUX_PA25H_USB_DP"> Auto
430 // <GPIO_PIN_FUNCTION_OFF"> Off
431 // <GPIO_PIN_FUNCTION_A"> A
432 // <GPIO_PIN_FUNCTION_B"> B
433 // <GPIO_PIN_FUNCTION_C"> C
434 // <GPIO_PIN_FUNCTION_D"> D
435 // <GPIO_PIN_FUNCTION_E"> E
436 // <GPIO_PIN_FUNCTION_F"> F
437 // <GPIO_PIN_FUNCTION_G"> G
438 // <GPIO_PIN_FUNCTION_H"> H
439 // <GPIO_PIN_FUNCTION_I"> I
440 // <GPIO_PIN_FUNCTION_J"> J
441 // <GPIO_PIN_FUNCTION_K"> K
442 // <GPIO_PIN_FUNCTION_L"> L
443 // <GPIO_PIN_FUNCTION_M"> M
444 // <GPIO_PIN_FUNCTION_N"> N
445 PINMUX_PA25H_USB_DP);
446}
447
448/* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
449 * for low speed and full speed operation. */
450#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || (CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
451#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
452#endif
453
454void USB_DEVICE_INSTANCE_CLOCK_init(void)
455{
456
457 hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
458 hri_mclk_set_AHBMASK_USB_bit(MCLK);
459 hri_mclk_set_APBBMASK_USB_bit(MCLK);
460}
461
462void USB_DEVICE_INSTANCE_init(void)
463{
464 USB_DEVICE_INSTANCE_CLOCK_init();
465 usb_d_init();
466 USB_DEVICE_INSTANCE_PORT_init();
467}
468
469void system_init(void)
470{
471 init_mcu();
472
Kévin Redon6a8295c2019-01-30 18:58:44 +0100473 // GPIO on PA11
474
475 gpio_set_pin_direction(SIMCLK_20MHZ,
476 // <y> Pin direction
477 // <id> pad_direction
478 // <GPIO_DIRECTION_OFF"> Off
479 // <GPIO_DIRECTION_IN"> In
480 // <GPIO_DIRECTION_OUT"> Out
481 GPIO_DIRECTION_OUT);
482
483 gpio_set_pin_level(SIMCLK_20MHZ,
484 // <y> Initial level
485 // <id> pad_initial_level
486 // <false"> Low
487 // <true"> High
488 false);
489
490 gpio_set_pin_pull_mode(SIMCLK_20MHZ,
491 // <y> Pull configuration
492 // <id> pad_pull_config
493 // <GPIO_PULL_OFF"> Off
494 // <GPIO_PULL_UP"> Pull-up
495 // <GPIO_PULL_DOWN"> Pull-down
496 GPIO_PULL_OFF);
497
498 gpio_set_pin_function(SIMCLK_20MHZ,
499 // <y> Pin function
500 // <id> pad_function
501 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
502 // <GPIO_PIN_FUNCTION_OFF"> Auto
503 // <GPIO_PIN_FUNCTION_OFF"> Off
504 // <GPIO_PIN_FUNCTION_A"> A
505 // <GPIO_PIN_FUNCTION_B"> B
506 // <GPIO_PIN_FUNCTION_C"> C
507 // <GPIO_PIN_FUNCTION_D"> D
508 // <GPIO_PIN_FUNCTION_E"> E
509 // <GPIO_PIN_FUNCTION_F"> F
510 // <GPIO_PIN_FUNCTION_G"> G
511 // <GPIO_PIN_FUNCTION_H"> H
512 // <GPIO_PIN_FUNCTION_I"> I
513 // <GPIO_PIN_FUNCTION_J"> J
514 // <GPIO_PIN_FUNCTION_K"> K
515 // <GPIO_PIN_FUNCTION_L"> L
516 // <GPIO_PIN_FUNCTION_M"> M
517 // <GPIO_PIN_FUNCTION_N"> N
518 GPIO_PIN_FUNCTION_M);
519
520 // GPIO on PA20
521
522 // Set pin direction to input
523 gpio_set_pin_direction(VB0, GPIO_DIRECTION_IN);
524
525 gpio_set_pin_pull_mode(VB0,
526 // <y> Pull configuration
527 // <id> pad_pull_config
528 // <GPIO_PULL_OFF"> Off
529 // <GPIO_PULL_UP"> Pull-up
530 // <GPIO_PULL_DOWN"> Pull-down
531 GPIO_PULL_OFF);
532
533 gpio_set_pin_function(VB0, GPIO_PIN_FUNCTION_OFF);
534
535 // GPIO on PA21
536
537 // Set pin direction to input
538 gpio_set_pin_direction(VB1, GPIO_DIRECTION_IN);
539
540 gpio_set_pin_pull_mode(VB1,
541 // <y> Pull configuration
542 // <id> pad_pull_config
543 // <GPIO_PULL_OFF"> Off
544 // <GPIO_PULL_UP"> Pull-up
545 // <GPIO_PULL_DOWN"> Pull-down
546 GPIO_PULL_OFF);
547
548 gpio_set_pin_function(VB1, GPIO_PIN_FUNCTION_OFF);
549
550 // GPIO on PA22
551
552 // Set pin direction to input
553 gpio_set_pin_direction(VB2, GPIO_DIRECTION_IN);
554
555 gpio_set_pin_pull_mode(VB2,
556 // <y> Pull configuration
557 // <id> pad_pull_config
558 // <GPIO_PULL_OFF"> Off
559 // <GPIO_PULL_UP"> Pull-up
560 // <GPIO_PULL_DOWN"> Pull-down
561 GPIO_PULL_OFF);
562
563 gpio_set_pin_function(VB2, GPIO_PIN_FUNCTION_OFF);
564
565 // GPIO on PA23
566
567 // Set pin direction to input
568 gpio_set_pin_direction(VB3, GPIO_DIRECTION_IN);
569
570 gpio_set_pin_pull_mode(VB3,
571 // <y> Pull configuration
572 // <id> pad_pull_config
573 // <GPIO_PULL_OFF"> Off
574 // <GPIO_PULL_UP"> Pull-up
575 // <GPIO_PULL_DOWN"> Pull-down
576 GPIO_PULL_OFF);
577
578 gpio_set_pin_function(VB3, GPIO_PIN_FUNCTION_OFF);
579
580 // GPIO on PC14
581
582 // Set pin direction to input
583 gpio_set_pin_direction(SWITCH, GPIO_DIRECTION_IN);
584
585 gpio_set_pin_pull_mode(SWITCH,
586 // <y> Pull configuration
587 // <id> pad_pull_config
588 // <GPIO_PULL_OFF"> Off
589 // <GPIO_PULL_UP"> Pull-up
590 // <GPIO_PULL_DOWN"> Pull-down
591 GPIO_PULL_OFF);
592
593 gpio_set_pin_function(SWITCH, GPIO_PIN_FUNCTION_OFF);
594
Kévin Redon4e39b012019-01-30 15:55:58 +0100595 // GPIO on PC26
Kévin Redon5908a5c2019-01-24 18:45:23 +0100596
Kévin Redon6a8295c2019-01-30 18:58:44 +0100597 gpio_set_pin_level(USER_LED,
Kévin Redon5908a5c2019-01-24 18:45:23 +0100598 // <y> Initial level
599 // <id> pad_initial_level
600 // <false"> Low
601 // <true"> High
Kévin Redon4e39b012019-01-30 15:55:58 +0100602 false);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100603
604 // Set pin direction to output
Kévin Redon6a8295c2019-01-30 18:58:44 +0100605 gpio_set_pin_direction(USER_LED, GPIO_DIRECTION_OUT);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100606
Kévin Redon6a8295c2019-01-30 18:58:44 +0100607 gpio_set_pin_function(USER_LED, GPIO_PIN_FUNCTION_OFF);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100608
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100609 SIM0_init();
610 SIM1_init();
611 SIM2_init();
612 SIM3_init();
613 SIM4_init();
614 SIM5_init();
615 SIM6_init();
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100616 UART_debug_init();
617
Kévin Redon69b92d92019-01-24 16:39:20 +0100618 USB_DEVICE_INSTANCE_init();
619}