blob: 726129d10df21175164467e76fe9976027d63bdb [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 Redon1f8ecef2019-01-31 13:36:12 +010035struct usart_async_descriptor SIM0;
36struct usart_async_descriptor SIM1;
37struct usart_async_descriptor SIM2;
38struct usart_async_descriptor SIM3;
39struct usart_async_descriptor SIM4;
40struct usart_async_descriptor SIM5;
41struct usart_async_descriptor SIM6;
Kévin Redonccbed0b2019-01-24 18:30:26 +010042
Kévin Redon1f8ecef2019-01-31 13:36:12 +010043static uint8_t SIM0_buffer[SIM0_BUFFER_SIZE];
44static uint8_t SIM1_buffer[SIM1_BUFFER_SIZE];
45static uint8_t SIM2_buffer[SIM2_BUFFER_SIZE];
46static uint8_t SIM3_buffer[SIM3_BUFFER_SIZE];
47static uint8_t SIM4_buffer[SIM4_BUFFER_SIZE];
48static uint8_t SIM5_buffer[SIM5_BUFFER_SIZE];
49static uint8_t SIM6_buffer[SIM6_BUFFER_SIZE];
Harald Welte361ed202019-02-24 21:15:39 +010050
51struct usart_sync_descriptor UART_debug;
Kévin Redonccbed0b2019-01-24 18:30:26 +010052
53/**
54 * \brief USART Clock initialization function
55 *
56 * Enables register interface and peripheral clock
57 */
Kévin Redon1f8ecef2019-01-31 13:36:12 +010058void SIM0_CLOCK_init()
59{
60
61 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
62 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
63
64 hri_mclk_set_APBAMASK_SERCOM0_bit(MCLK);
65}
66
67/**
68 * \brief USART pinmux initialization function
69 *
70 * Set each required pin to USART functionality
71 */
72void SIM0_PORT_init()
73{
74
75 gpio_set_pin_function(SIM0_IO, PINMUX_PA04D_SERCOM0_PAD0);
76}
77
78/**
79 * \brief USART initialization function
80 *
81 * Enables USART peripheral, clocks and initializes USART driver
82 */
83void SIM0_init(void)
84{
85 SIM0_CLOCK_init();
86 usart_async_init(&SIM0, SERCOM0, SIM0_buffer, SIM0_BUFFER_SIZE, (void *)NULL);
87 SIM0_PORT_init();
88}
89
90/**
91 * \brief USART Clock initialization function
92 *
93 * Enables register interface and peripheral clock
94 */
95void SIM1_CLOCK_init()
96{
97
98 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_CORE, CONF_GCLK_SERCOM1_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
99 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_SLOW, CONF_GCLK_SERCOM1_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
100
101 hri_mclk_set_APBAMASK_SERCOM1_bit(MCLK);
102}
103
104/**
105 * \brief USART pinmux initialization function
106 *
107 * Set each required pin to USART functionality
108 */
109void SIM1_PORT_init()
110{
111
112 gpio_set_pin_function(SIM1_IO, PINMUX_PA16C_SERCOM1_PAD0);
113}
114
115/**
116 * \brief USART initialization function
117 *
118 * Enables USART peripheral, clocks and initializes USART driver
119 */
120void SIM1_init(void)
121{
122 SIM1_CLOCK_init();
123 usart_async_init(&SIM1, SERCOM1, SIM1_buffer, SIM1_BUFFER_SIZE, (void *)NULL);
124 SIM1_PORT_init();
125}
126
127/**
128 * \brief USART Clock initialization function
129 *
130 * Enables register interface and peripheral clock
131 */
132void SIM2_CLOCK_init()
133{
134
135 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
136 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
137
138 hri_mclk_set_APBBMASK_SERCOM2_bit(MCLK);
139}
140
141/**
142 * \brief USART pinmux initialization function
143 *
144 * Set each required pin to USART functionality
145 */
146void SIM2_PORT_init()
147{
148
149 gpio_set_pin_function(SIM2_IO, PINMUX_PA09D_SERCOM2_PAD0);
150}
151
152/**
153 * \brief USART initialization function
154 *
155 * Enables USART peripheral, clocks and initializes USART driver
156 */
157void SIM2_init(void)
158{
159 SIM2_CLOCK_init();
160 usart_async_init(&SIM2, SERCOM2, SIM2_buffer, SIM2_BUFFER_SIZE, (void *)NULL);
161 SIM2_PORT_init();
162}
163
164/**
165 * \brief USART Clock initialization function
166 *
167 * Enables register interface and peripheral clock
168 */
169void SIM3_CLOCK_init()
170{
171
172 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
173 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
174
175 hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK);
176}
177
178/**
179 * \brief USART pinmux initialization function
180 *
181 * Set each required pin to USART functionality
182 */
183void SIM3_PORT_init()
184{
185
186 gpio_set_pin_function(SIM3_IO, PINMUX_PB20C_SERCOM3_PAD0);
187}
188
189/**
190 * \brief USART initialization function
191 *
192 * Enables USART peripheral, clocks and initializes USART driver
193 */
194void SIM3_init(void)
195{
196 SIM3_CLOCK_init();
197 usart_async_init(&SIM3, SERCOM3, SIM3_buffer, SIM3_BUFFER_SIZE, (void *)NULL);
198 SIM3_PORT_init();
199}
200
201/**
202 * \brief USART Clock initialization function
203 *
204 * Enables register interface and peripheral clock
205 */
206void SIM4_CLOCK_init()
207{
208
209 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_CORE, CONF_GCLK_SERCOM4_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
210 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_SLOW, CONF_GCLK_SERCOM4_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
211
212 hri_mclk_set_APBDMASK_SERCOM4_bit(MCLK);
213}
214
215/**
216 * \brief USART pinmux initialization function
217 *
218 * Set each required pin to USART functionality
219 */
220void SIM4_PORT_init()
221{
222
223 gpio_set_pin_function(SIM4_IO, PINMUX_PB08D_SERCOM4_PAD0);
224}
225
226/**
227 * \brief USART initialization function
228 *
229 * Enables USART peripheral, clocks and initializes USART driver
230 */
231void SIM4_init(void)
232{
233 SIM4_CLOCK_init();
234 usart_async_init(&SIM4, SERCOM4, SIM4_buffer, SIM4_BUFFER_SIZE, (void *)NULL);
235 SIM4_PORT_init();
236}
237
238/**
239 * \brief USART Clock initialization function
240 *
241 * Enables register interface and peripheral clock
242 */
243void SIM5_CLOCK_init()
244{
245
246 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_CORE, CONF_GCLK_SERCOM5_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
247 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_SLOW, CONF_GCLK_SERCOM5_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
248
249 hri_mclk_set_APBDMASK_SERCOM5_bit(MCLK);
250}
251
252/**
253 * \brief USART pinmux initialization function
254 *
255 * Set each required pin to USART functionality
256 */
257void SIM5_PORT_init()
258{
259
260 gpio_set_pin_function(SIM5_IO, PINMUX_PB16C_SERCOM5_PAD0);
261}
262
263/**
264 * \brief USART initialization function
265 *
266 * Enables USART peripheral, clocks and initializes USART driver
267 */
268void SIM5_init(void)
269{
270 SIM5_CLOCK_init();
271 usart_async_init(&SIM5, SERCOM5, SIM5_buffer, SIM5_BUFFER_SIZE, (void *)NULL);
272 SIM5_PORT_init();
273}
274
275/**
276 * \brief USART Clock initialization function
277 *
278 * Enables register interface and peripheral clock
279 */
280void SIM6_CLOCK_init()
281{
282
283 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_CORE, CONF_GCLK_SERCOM6_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
284 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_SLOW, CONF_GCLK_SERCOM6_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
285
286 hri_mclk_set_APBDMASK_SERCOM6_bit(MCLK);
287}
288
289/**
290 * \brief USART pinmux initialization function
291 *
292 * Set each required pin to USART functionality
293 */
294void SIM6_PORT_init()
295{
296
297 gpio_set_pin_function(SIM6_IO, PINMUX_PC16C_SERCOM6_PAD0);
298}
299
300/**
301 * \brief USART initialization function
302 *
303 * Enables USART peripheral, clocks and initializes USART driver
304 */
305void SIM6_init(void)
306{
307 SIM6_CLOCK_init();
308 usart_async_init(&SIM6, SERCOM6, SIM6_buffer, SIM6_BUFFER_SIZE, (void *)NULL);
309 SIM6_PORT_init();
310}
311
Harald Welte361ed202019-02-24 21:15:39 +0100312void UART_debug_PORT_init(void)
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100313{
314
Kévin Redon4e39b012019-01-30 15:55:58 +0100315 gpio_set_pin_function(UART_TX, PINMUX_PB30C_SERCOM7_PAD0);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100316
Kévin Redon4e39b012019-01-30 15:55:58 +0100317 gpio_set_pin_function(UART_RX, PINMUX_PB31C_SERCOM7_PAD1);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100318}
319
Harald Welte361ed202019-02-24 21:15:39 +0100320void UART_debug_CLOCK_init(void)
321{
322 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
323 hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
324
325 hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);
326}
327
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100328void UART_debug_init(void)
329{
330 UART_debug_CLOCK_init();
Harald Welte361ed202019-02-24 21:15:39 +0100331 usart_sync_init(&UART_debug, SERCOM7, (void *)NULL);
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100332 UART_debug_PORT_init();
333}
334
Kévin Redon69b92d92019-01-24 16:39:20 +0100335void USB_DEVICE_INSTANCE_PORT_init(void)
336{
337
Kévin Redon4e39b012019-01-30 15:55:58 +0100338 gpio_set_pin_direction(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100339 // <y> Pin direction
340 // <id> pad_direction
341 // <GPIO_DIRECTION_OFF"> Off
342 // <GPIO_DIRECTION_IN"> In
343 // <GPIO_DIRECTION_OUT"> Out
344 GPIO_DIRECTION_OUT);
345
Kévin Redon4e39b012019-01-30 15:55:58 +0100346 gpio_set_pin_level(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100347 // <y> Initial level
348 // <id> pad_initial_level
349 // <false"> Low
350 // <true"> High
351 false);
352
Kévin Redon4e39b012019-01-30 15:55:58 +0100353 gpio_set_pin_pull_mode(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100354 // <y> Pull configuration
355 // <id> pad_pull_config
356 // <GPIO_PULL_OFF"> Off
357 // <GPIO_PULL_UP"> Pull-up
358 // <GPIO_PULL_DOWN"> Pull-down
359 GPIO_PULL_OFF);
360
Kévin Redon4e39b012019-01-30 15:55:58 +0100361 gpio_set_pin_function(USBUP_D_N,
Kévin Redon69b92d92019-01-24 16:39:20 +0100362 // <y> Pin function
363 // <id> pad_function
364 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
365 // <PINMUX_PA24H_USB_DM"> Auto
366 // <GPIO_PIN_FUNCTION_OFF"> Off
367 // <GPIO_PIN_FUNCTION_A"> A
368 // <GPIO_PIN_FUNCTION_B"> B
369 // <GPIO_PIN_FUNCTION_C"> C
370 // <GPIO_PIN_FUNCTION_D"> D
371 // <GPIO_PIN_FUNCTION_E"> E
372 // <GPIO_PIN_FUNCTION_F"> F
373 // <GPIO_PIN_FUNCTION_G"> G
374 // <GPIO_PIN_FUNCTION_H"> H
375 // <GPIO_PIN_FUNCTION_I"> I
376 // <GPIO_PIN_FUNCTION_J"> J
377 // <GPIO_PIN_FUNCTION_K"> K
378 // <GPIO_PIN_FUNCTION_L"> L
379 // <GPIO_PIN_FUNCTION_M"> M
380 // <GPIO_PIN_FUNCTION_N"> N
381 PINMUX_PA24H_USB_DM);
382
Kévin Redon4e39b012019-01-30 15:55:58 +0100383 gpio_set_pin_direction(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100384 // <y> Pin direction
385 // <id> pad_direction
386 // <GPIO_DIRECTION_OFF"> Off
387 // <GPIO_DIRECTION_IN"> In
388 // <GPIO_DIRECTION_OUT"> Out
389 GPIO_DIRECTION_OUT);
390
Kévin Redon4e39b012019-01-30 15:55:58 +0100391 gpio_set_pin_level(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100392 // <y> Initial level
393 // <id> pad_initial_level
394 // <false"> Low
395 // <true"> High
396 false);
397
Kévin Redon4e39b012019-01-30 15:55:58 +0100398 gpio_set_pin_pull_mode(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100399 // <y> Pull configuration
400 // <id> pad_pull_config
401 // <GPIO_PULL_OFF"> Off
402 // <GPIO_PULL_UP"> Pull-up
403 // <GPIO_PULL_DOWN"> Pull-down
404 GPIO_PULL_OFF);
405
Kévin Redon4e39b012019-01-30 15:55:58 +0100406 gpio_set_pin_function(USBUP_D_P,
Kévin Redon69b92d92019-01-24 16:39:20 +0100407 // <y> Pin function
408 // <id> pad_function
409 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
410 // <PINMUX_PA25H_USB_DP"> Auto
411 // <GPIO_PIN_FUNCTION_OFF"> Off
412 // <GPIO_PIN_FUNCTION_A"> A
413 // <GPIO_PIN_FUNCTION_B"> B
414 // <GPIO_PIN_FUNCTION_C"> C
415 // <GPIO_PIN_FUNCTION_D"> D
416 // <GPIO_PIN_FUNCTION_E"> E
417 // <GPIO_PIN_FUNCTION_F"> F
418 // <GPIO_PIN_FUNCTION_G"> G
419 // <GPIO_PIN_FUNCTION_H"> H
420 // <GPIO_PIN_FUNCTION_I"> I
421 // <GPIO_PIN_FUNCTION_J"> J
422 // <GPIO_PIN_FUNCTION_K"> K
423 // <GPIO_PIN_FUNCTION_L"> L
424 // <GPIO_PIN_FUNCTION_M"> M
425 // <GPIO_PIN_FUNCTION_N"> N
426 PINMUX_PA25H_USB_DP);
427}
428
429/* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
430 * for low speed and full speed operation. */
431#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || (CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
432#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
433#endif
434
435void USB_DEVICE_INSTANCE_CLOCK_init(void)
436{
437
438 hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
439 hri_mclk_set_AHBMASK_USB_bit(MCLK);
440 hri_mclk_set_APBBMASK_USB_bit(MCLK);
441}
442
443void USB_DEVICE_INSTANCE_init(void)
444{
445 USB_DEVICE_INSTANCE_CLOCK_init();
446 usb_d_init();
447 USB_DEVICE_INSTANCE_PORT_init();
448}
449
450void system_init(void)
451{
452 init_mcu();
453
Harald Welte092494e2019-02-24 10:33:40 +0100454 // GPIO on PA02
455
456 // Set pin direction to input
457 gpio_set_pin_direction(SIM4_INT, GPIO_DIRECTION_IN);
458
459 gpio_set_pin_pull_mode(SIM4_INT,
460 // <y> Pull configuration
461 // <id> pad_pull_config
462 // <GPIO_PULL_OFF"> Off
463 // <GPIO_PULL_UP"> Pull-up
464 // <GPIO_PULL_DOWN"> Pull-down
465 GPIO_PULL_OFF);
466
467 gpio_set_pin_function(SIM4_INT, GPIO_PIN_FUNCTION_OFF);
468
469 // GPIO on PA03
470
471 // Set pin direction to input
472 gpio_set_pin_direction(SIM5_INT, GPIO_DIRECTION_IN);
473
474 gpio_set_pin_pull_mode(SIM5_INT,
475 // <y> Pull configuration
476 // <id> pad_pull_config
477 // <GPIO_PULL_OFF"> Off
478 // <GPIO_PULL_UP"> Pull-up
479 // <GPIO_PULL_DOWN"> Pull-down
480 GPIO_PULL_OFF);
481
482 gpio_set_pin_function(SIM5_INT, GPIO_PIN_FUNCTION_OFF);
483
Kévin Redon6a8295c2019-01-30 18:58:44 +0100484 // GPIO on PA11
485
486 gpio_set_pin_direction(SIMCLK_20MHZ,
487 // <y> Pin direction
488 // <id> pad_direction
489 // <GPIO_DIRECTION_OFF"> Off
490 // <GPIO_DIRECTION_IN"> In
491 // <GPIO_DIRECTION_OUT"> Out
492 GPIO_DIRECTION_OUT);
493
494 gpio_set_pin_level(SIMCLK_20MHZ,
495 // <y> Initial level
496 // <id> pad_initial_level
497 // <false"> Low
498 // <true"> High
499 false);
500
501 gpio_set_pin_pull_mode(SIMCLK_20MHZ,
502 // <y> Pull configuration
503 // <id> pad_pull_config
504 // <GPIO_PULL_OFF"> Off
505 // <GPIO_PULL_UP"> Pull-up
506 // <GPIO_PULL_DOWN"> Pull-down
507 GPIO_PULL_OFF);
508
509 gpio_set_pin_function(SIMCLK_20MHZ,
510 // <y> Pin function
511 // <id> pad_function
512 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
513 // <GPIO_PIN_FUNCTION_OFF"> Auto
514 // <GPIO_PIN_FUNCTION_OFF"> Off
515 // <GPIO_PIN_FUNCTION_A"> A
516 // <GPIO_PIN_FUNCTION_B"> B
517 // <GPIO_PIN_FUNCTION_C"> C
518 // <GPIO_PIN_FUNCTION_D"> D
519 // <GPIO_PIN_FUNCTION_E"> E
520 // <GPIO_PIN_FUNCTION_F"> F
521 // <GPIO_PIN_FUNCTION_G"> G
522 // <GPIO_PIN_FUNCTION_H"> H
523 // <GPIO_PIN_FUNCTION_I"> I
524 // <GPIO_PIN_FUNCTION_J"> J
525 // <GPIO_PIN_FUNCTION_K"> K
526 // <GPIO_PIN_FUNCTION_L"> L
527 // <GPIO_PIN_FUNCTION_M"> M
528 // <GPIO_PIN_FUNCTION_N"> N
529 GPIO_PIN_FUNCTION_M);
530
531 // GPIO on PA20
532
533 // Set pin direction to input
534 gpio_set_pin_direction(VB0, GPIO_DIRECTION_IN);
535
536 gpio_set_pin_pull_mode(VB0,
537 // <y> Pull configuration
538 // <id> pad_pull_config
539 // <GPIO_PULL_OFF"> Off
540 // <GPIO_PULL_UP"> Pull-up
541 // <GPIO_PULL_DOWN"> Pull-down
542 GPIO_PULL_OFF);
543
544 gpio_set_pin_function(VB0, GPIO_PIN_FUNCTION_OFF);
545
546 // GPIO on PA21
547
548 // Set pin direction to input
549 gpio_set_pin_direction(VB1, GPIO_DIRECTION_IN);
550
551 gpio_set_pin_pull_mode(VB1,
552 // <y> Pull configuration
553 // <id> pad_pull_config
554 // <GPIO_PULL_OFF"> Off
555 // <GPIO_PULL_UP"> Pull-up
556 // <GPIO_PULL_DOWN"> Pull-down
557 GPIO_PULL_OFF);
558
559 gpio_set_pin_function(VB1, GPIO_PIN_FUNCTION_OFF);
560
561 // GPIO on PA22
562
563 // Set pin direction to input
564 gpio_set_pin_direction(VB2, GPIO_DIRECTION_IN);
565
566 gpio_set_pin_pull_mode(VB2,
567 // <y> Pull configuration
568 // <id> pad_pull_config
569 // <GPIO_PULL_OFF"> Off
570 // <GPIO_PULL_UP"> Pull-up
571 // <GPIO_PULL_DOWN"> Pull-down
572 GPIO_PULL_OFF);
573
574 gpio_set_pin_function(VB2, GPIO_PIN_FUNCTION_OFF);
575
576 // GPIO on PA23
577
578 // Set pin direction to input
579 gpio_set_pin_direction(VB3, GPIO_DIRECTION_IN);
580
581 gpio_set_pin_pull_mode(VB3,
582 // <y> Pull configuration
583 // <id> pad_pull_config
584 // <GPIO_PULL_OFF"> Off
585 // <GPIO_PULL_UP"> Pull-up
586 // <GPIO_PULL_DOWN"> Pull-down
587 GPIO_PULL_OFF);
588
589 gpio_set_pin_function(VB3, GPIO_PIN_FUNCTION_OFF);
590
Harald Welte092494e2019-02-24 10:33:40 +0100591 // GPIO on PB02
592
593 gpio_set_pin_level(SCL2,
594 // <y> Initial level
595 // <id> pad_initial_level
596 // <false"> Low
597 // <true"> High
598 false);
599
600 // Set pin direction to output
601 gpio_set_pin_direction(SCL2, GPIO_DIRECTION_OUT);
602
603 gpio_set_pin_function(SCL2, GPIO_PIN_FUNCTION_OFF);
604
605 // GPIO on PB03
606
607 gpio_set_pin_level(SDA2,
608 // <y> Initial level
609 // <id> pad_initial_level
610 // <false"> Low
611 // <true"> High
612 false);
613
614 // Set pin direction to output
615 gpio_set_pin_direction(SDA2, GPIO_DIRECTION_OUT);
616
617 gpio_set_pin_function(SDA2, GPIO_PIN_FUNCTION_OFF);
618
619 // GPIO on PB04
620
621 // Set pin direction to input
622 gpio_set_pin_direction(SIM6_INT, GPIO_DIRECTION_IN);
623
624 gpio_set_pin_pull_mode(SIM6_INT,
625 // <y> Pull configuration
626 // <id> pad_pull_config
627 // <GPIO_PULL_OFF"> Off
628 // <GPIO_PULL_UP"> Pull-up
629 // <GPIO_PULL_DOWN"> Pull-down
630 GPIO_PULL_OFF);
631
632 gpio_set_pin_function(SIM6_INT, GPIO_PIN_FUNCTION_OFF);
633
634 // GPIO on PB05
635
636 // Set pin direction to input
637 gpio_set_pin_direction(SIM7_INT, GPIO_DIRECTION_IN);
638
639 gpio_set_pin_pull_mode(SIM7_INT,
640 // <y> Pull configuration
641 // <id> pad_pull_config
642 // <GPIO_PULL_OFF"> Off
643 // <GPIO_PULL_UP"> Pull-up
644 // <GPIO_PULL_DOWN"> Pull-down
645 GPIO_PULL_OFF);
646
647 gpio_set_pin_function(SIM7_INT, GPIO_PIN_FUNCTION_OFF);
648
649 // GPIO on PB06
650
651 gpio_set_pin_level(SCL3,
652 // <y> Initial level
653 // <id> pad_initial_level
654 // <false"> Low
655 // <true"> High
656 false);
657
658 // Set pin direction to output
659 gpio_set_pin_direction(SCL3, GPIO_DIRECTION_OUT);
660
661 gpio_set_pin_function(SCL3, GPIO_PIN_FUNCTION_OFF);
662
663 // GPIO on PB07
664
665 gpio_set_pin_level(SDA3,
666 // <y> Initial level
667 // <id> pad_initial_level
668 // <false"> Low
669 // <true"> High
670 false);
671
672 // Set pin direction to output
673 gpio_set_pin_direction(SDA3, GPIO_DIRECTION_OUT);
674
675 gpio_set_pin_function(SDA3, GPIO_PIN_FUNCTION_OFF);
676
677 // GPIO on PB14
678
679 gpio_set_pin_level(SCL1,
680 // <y> Initial level
681 // <id> pad_initial_level
682 // <false"> Low
683 // <true"> High
684 false);
685
686 // Set pin direction to output
687 gpio_set_pin_direction(SCL1, GPIO_DIRECTION_OUT);
688
689 gpio_set_pin_function(SCL1, GPIO_PIN_FUNCTION_OFF);
690
691 // GPIO on PB15
692
693 gpio_set_pin_level(SDA1,
694 // <y> Initial level
695 // <id> pad_initial_level
696 // <false"> Low
697 // <true"> High
698 false);
699
700 // Set pin direction to output
701 gpio_set_pin_direction(SDA1, GPIO_DIRECTION_OUT);
702
703 gpio_set_pin_function(SDA1, GPIO_PIN_FUNCTION_OFF);
704
705 // GPIO on PC00
706
707 // Set pin direction to input
708 gpio_set_pin_direction(SIM0_INT, GPIO_DIRECTION_IN);
709
710 gpio_set_pin_pull_mode(SIM0_INT,
711 // <y> Pull configuration
712 // <id> pad_pull_config
713 // <GPIO_PULL_OFF"> Off
714 // <GPIO_PULL_UP"> Pull-up
715 // <GPIO_PULL_DOWN"> Pull-down
716 GPIO_PULL_OFF);
717
718 gpio_set_pin_function(SIM0_INT, GPIO_PIN_FUNCTION_OFF);
719
720 // GPIO on PC01
721
722 // Set pin direction to input
723 gpio_set_pin_direction(SIM1_INT, GPIO_DIRECTION_IN);
724
725 gpio_set_pin_pull_mode(SIM1_INT,
726 // <y> Pull configuration
727 // <id> pad_pull_config
728 // <GPIO_PULL_OFF"> Off
729 // <GPIO_PULL_UP"> Pull-up
730 // <GPIO_PULL_DOWN"> Pull-down
731 GPIO_PULL_OFF);
732
733 gpio_set_pin_function(SIM1_INT, GPIO_PIN_FUNCTION_OFF);
734
735 // GPIO on PC02
736
737 // Set pin direction to input
738 gpio_set_pin_direction(SIM2_INT, GPIO_DIRECTION_IN);
739
740 gpio_set_pin_pull_mode(SIM2_INT,
741 // <y> Pull configuration
742 // <id> pad_pull_config
743 // <GPIO_PULL_OFF"> Off
744 // <GPIO_PULL_UP"> Pull-up
745 // <GPIO_PULL_DOWN"> Pull-down
746 GPIO_PULL_OFF);
747
748 gpio_set_pin_function(SIM2_INT, GPIO_PIN_FUNCTION_OFF);
749
750 // GPIO on PC03
751
752 // Set pin direction to input
753 gpio_set_pin_direction(SIM3_INT, GPIO_DIRECTION_IN);
754
755 gpio_set_pin_pull_mode(SIM3_INT,
756 // <y> Pull configuration
757 // <id> pad_pull_config
758 // <GPIO_PULL_OFF"> Off
759 // <GPIO_PULL_UP"> Pull-up
760 // <GPIO_PULL_DOWN"> Pull-down
761 GPIO_PULL_OFF);
762
763 gpio_set_pin_function(SIM3_INT, GPIO_PIN_FUNCTION_OFF);
764
Kévin Redon6a8295c2019-01-30 18:58:44 +0100765 // GPIO on PC14
766
767 // Set pin direction to input
768 gpio_set_pin_direction(SWITCH, GPIO_DIRECTION_IN);
769
770 gpio_set_pin_pull_mode(SWITCH,
771 // <y> Pull configuration
772 // <id> pad_pull_config
773 // <GPIO_PULL_OFF"> Off
774 // <GPIO_PULL_UP"> Pull-up
775 // <GPIO_PULL_DOWN"> Pull-down
776 GPIO_PULL_OFF);
777
778 gpio_set_pin_function(SWITCH, GPIO_PIN_FUNCTION_OFF);
779
Harald Welte092494e2019-02-24 10:33:40 +0100780 // GPIO on PC15
781
782 // Set pin direction to input
Kévin Redon3c045b22019-02-26 19:52:02 +0100783 gpio_set_pin_direction(MUX_STAT, GPIO_DIRECTION_IN);
Harald Welte092494e2019-02-24 10:33:40 +0100784
Kévin Redon3c045b22019-02-26 19:52:02 +0100785 gpio_set_pin_pull_mode(MUX_STAT,
Harald Welte092494e2019-02-24 10:33:40 +0100786 // <y> Pull configuration
787 // <id> pad_pull_config
788 // <GPIO_PULL_OFF"> Off
789 // <GPIO_PULL_UP"> Pull-up
790 // <GPIO_PULL_DOWN"> Pull-down
791 GPIO_PULL_OFF);
792
Kévin Redon3c045b22019-02-26 19:52:02 +0100793 gpio_set_pin_function(MUX_STAT, GPIO_PIN_FUNCTION_OFF);
Harald Welte092494e2019-02-24 10:33:40 +0100794
Kévin Redon4e39b012019-01-30 15:55:58 +0100795 // GPIO on PC26
Kévin Redon5908a5c2019-01-24 18:45:23 +0100796
Kévin Redon6a8295c2019-01-30 18:58:44 +0100797 gpio_set_pin_level(USER_LED,
Kévin Redon5908a5c2019-01-24 18:45:23 +0100798 // <y> Initial level
799 // <id> pad_initial_level
800 // <false"> Low
801 // <true"> High
Kévin Redon4e39b012019-01-30 15:55:58 +0100802 false);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100803
804 // Set pin direction to output
Kévin Redon6a8295c2019-01-30 18:58:44 +0100805 gpio_set_pin_direction(USER_LED, GPIO_DIRECTION_OUT);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100806
Kévin Redon6a8295c2019-01-30 18:58:44 +0100807 gpio_set_pin_function(USER_LED, GPIO_PIN_FUNCTION_OFF);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100808
Harald Welte092494e2019-02-24 10:33:40 +0100809 // GPIO on PC27
810
811 gpio_set_pin_level(SCL4,
812 // <y> Initial level
813 // <id> pad_initial_level
814 // <false"> Low
815 // <true"> High
816 false);
817
818 // Set pin direction to output
819 gpio_set_pin_direction(SCL4, GPIO_DIRECTION_OUT);
820
821 gpio_set_pin_function(SCL4, GPIO_PIN_FUNCTION_OFF);
822
823 // GPIO on PC28
824
825 gpio_set_pin_level(SDA4,
826 // <y> Initial level
827 // <id> pad_initial_level
828 // <false"> Low
829 // <true"> High
830 false);
831
832 // Set pin direction to output
833 gpio_set_pin_direction(SDA4, GPIO_DIRECTION_OUT);
834
835 gpio_set_pin_function(SDA4, GPIO_PIN_FUNCTION_OFF);
836
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100837 SIM0_init();
838 SIM1_init();
839 SIM2_init();
840 SIM3_init();
841 SIM4_init();
842 SIM5_init();
843 SIM6_init();
Harald Welte361ed202019-02-24 21:15:39 +0100844
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100845 UART_debug_init();
846
Kévin Redon69b92d92019-01-24 16:39:20 +0100847 USB_DEVICE_INSTANCE_init();
848}