blob: 1233d0281ccbbf3ff37fd43eb3db81f1b62ecd24 [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 Redonf53d3662019-04-25 13:55:06 +0200506 // GPIO on PA10
507
508 gpio_set_pin_direction(RMII_CLOCK,
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(RMII_CLOCK,
517 // <y> Initial level
518 // <id> pad_initial_level
519 // <false"> Low
520 // <true"> High
521 false);
522
523 gpio_set_pin_pull_mode(RMII_CLOCK,
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(RMII_CLOCK,
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
Kévin Redon6a8295c2019-01-30 18:58:44 +0100553 // GPIO on PA11
554
555 gpio_set_pin_direction(SIMCLK_20MHZ,
556 // <y> Pin direction
557 // <id> pad_direction
558 // <GPIO_DIRECTION_OFF"> Off
559 // <GPIO_DIRECTION_IN"> In
560 // <GPIO_DIRECTION_OUT"> Out
561 GPIO_DIRECTION_OUT);
562
563 gpio_set_pin_level(SIMCLK_20MHZ,
564 // <y> Initial level
565 // <id> pad_initial_level
566 // <false"> Low
567 // <true"> High
568 false);
569
570 gpio_set_pin_pull_mode(SIMCLK_20MHZ,
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(SIMCLK_20MHZ,
579 // <y> Pin function
580 // <id> pad_function
581 // <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
582 // <GPIO_PIN_FUNCTION_OFF"> Auto
583 // <GPIO_PIN_FUNCTION_OFF"> Off
584 // <GPIO_PIN_FUNCTION_A"> A
585 // <GPIO_PIN_FUNCTION_B"> B
586 // <GPIO_PIN_FUNCTION_C"> C
587 // <GPIO_PIN_FUNCTION_D"> D
588 // <GPIO_PIN_FUNCTION_E"> E
589 // <GPIO_PIN_FUNCTION_F"> F
590 // <GPIO_PIN_FUNCTION_G"> G
591 // <GPIO_PIN_FUNCTION_H"> H
592 // <GPIO_PIN_FUNCTION_I"> I
593 // <GPIO_PIN_FUNCTION_J"> J
594 // <GPIO_PIN_FUNCTION_K"> K
595 // <GPIO_PIN_FUNCTION_L"> L
596 // <GPIO_PIN_FUNCTION_M"> M
597 // <GPIO_PIN_FUNCTION_N"> N
598 GPIO_PIN_FUNCTION_M);
599
600 // GPIO on PA20
601
602 // Set pin direction to input
603 gpio_set_pin_direction(VB0, GPIO_DIRECTION_IN);
604
605 gpio_set_pin_pull_mode(VB0,
606 // <y> Pull configuration
607 // <id> pad_pull_config
608 // <GPIO_PULL_OFF"> Off
609 // <GPIO_PULL_UP"> Pull-up
610 // <GPIO_PULL_DOWN"> Pull-down
611 GPIO_PULL_OFF);
612
613 gpio_set_pin_function(VB0, GPIO_PIN_FUNCTION_OFF);
614
615 // GPIO on PA21
616
617 // Set pin direction to input
618 gpio_set_pin_direction(VB1, GPIO_DIRECTION_IN);
619
620 gpio_set_pin_pull_mode(VB1,
621 // <y> Pull configuration
622 // <id> pad_pull_config
623 // <GPIO_PULL_OFF"> Off
624 // <GPIO_PULL_UP"> Pull-up
625 // <GPIO_PULL_DOWN"> Pull-down
626 GPIO_PULL_OFF);
627
628 gpio_set_pin_function(VB1, GPIO_PIN_FUNCTION_OFF);
629
630 // GPIO on PA22
631
632 // Set pin direction to input
633 gpio_set_pin_direction(VB2, GPIO_DIRECTION_IN);
634
635 gpio_set_pin_pull_mode(VB2,
636 // <y> Pull configuration
637 // <id> pad_pull_config
638 // <GPIO_PULL_OFF"> Off
639 // <GPIO_PULL_UP"> Pull-up
640 // <GPIO_PULL_DOWN"> Pull-down
641 GPIO_PULL_OFF);
642
643 gpio_set_pin_function(VB2, GPIO_PIN_FUNCTION_OFF);
644
645 // GPIO on PA23
646
647 // Set pin direction to input
648 gpio_set_pin_direction(VB3, GPIO_DIRECTION_IN);
649
650 gpio_set_pin_pull_mode(VB3,
651 // <y> Pull configuration
652 // <id> pad_pull_config
653 // <GPIO_PULL_OFF"> Off
654 // <GPIO_PULL_UP"> Pull-up
655 // <GPIO_PULL_DOWN"> Pull-down
656 GPIO_PULL_OFF);
657
658 gpio_set_pin_function(VB3, GPIO_PIN_FUNCTION_OFF);
659
Harald Welte092494e2019-02-24 10:33:40 +0100660 // GPIO on PB02
661
662 gpio_set_pin_level(SCL2,
663 // <y> Initial level
664 // <id> pad_initial_level
665 // <false"> Low
666 // <true"> High
667 false);
668
669 // Set pin direction to output
670 gpio_set_pin_direction(SCL2, GPIO_DIRECTION_OUT);
671
672 gpio_set_pin_function(SCL2, GPIO_PIN_FUNCTION_OFF);
673
674 // GPIO on PB03
675
676 gpio_set_pin_level(SDA2,
677 // <y> Initial level
678 // <id> pad_initial_level
679 // <false"> Low
680 // <true"> High
681 false);
682
683 // Set pin direction to output
684 gpio_set_pin_direction(SDA2, GPIO_DIRECTION_OUT);
685
686 gpio_set_pin_function(SDA2, GPIO_PIN_FUNCTION_OFF);
687
688 // GPIO on PB04
689
690 // Set pin direction to input
691 gpio_set_pin_direction(SIM6_INT, GPIO_DIRECTION_IN);
692
693 gpio_set_pin_pull_mode(SIM6_INT,
694 // <y> Pull configuration
695 // <id> pad_pull_config
696 // <GPIO_PULL_OFF"> Off
697 // <GPIO_PULL_UP"> Pull-up
698 // <GPIO_PULL_DOWN"> Pull-down
699 GPIO_PULL_OFF);
700
701 gpio_set_pin_function(SIM6_INT, GPIO_PIN_FUNCTION_OFF);
702
703 // GPIO on PB05
704
705 // Set pin direction to input
706 gpio_set_pin_direction(SIM7_INT, GPIO_DIRECTION_IN);
707
708 gpio_set_pin_pull_mode(SIM7_INT,
709 // <y> Pull configuration
710 // <id> pad_pull_config
711 // <GPIO_PULL_OFF"> Off
712 // <GPIO_PULL_UP"> Pull-up
713 // <GPIO_PULL_DOWN"> Pull-down
714 GPIO_PULL_OFF);
715
716 gpio_set_pin_function(SIM7_INT, GPIO_PIN_FUNCTION_OFF);
717
718 // GPIO on PB06
719
720 gpio_set_pin_level(SCL3,
721 // <y> Initial level
722 // <id> pad_initial_level
723 // <false"> Low
724 // <true"> High
725 false);
726
727 // Set pin direction to output
728 gpio_set_pin_direction(SCL3, GPIO_DIRECTION_OUT);
729
730 gpio_set_pin_function(SCL3, GPIO_PIN_FUNCTION_OFF);
731
732 // GPIO on PB07
733
734 gpio_set_pin_level(SDA3,
735 // <y> Initial level
736 // <id> pad_initial_level
737 // <false"> Low
738 // <true"> High
739 false);
740
741 // Set pin direction to output
742 gpio_set_pin_direction(SDA3, GPIO_DIRECTION_OUT);
743
744 gpio_set_pin_function(SDA3, GPIO_PIN_FUNCTION_OFF);
745
746 // GPIO on PB14
747
748 gpio_set_pin_level(SCL1,
749 // <y> Initial level
750 // <id> pad_initial_level
751 // <false"> Low
752 // <true"> High
753 false);
754
755 // Set pin direction to output
756 gpio_set_pin_direction(SCL1, GPIO_DIRECTION_OUT);
757
758 gpio_set_pin_function(SCL1, GPIO_PIN_FUNCTION_OFF);
759
760 // GPIO on PB15
761
762 gpio_set_pin_level(SDA1,
763 // <y> Initial level
764 // <id> pad_initial_level
765 // <false"> Low
766 // <true"> High
767 false);
768
769 // Set pin direction to output
770 gpio_set_pin_direction(SDA1, GPIO_DIRECTION_OUT);
771
772 gpio_set_pin_function(SDA1, GPIO_PIN_FUNCTION_OFF);
773
774 // GPIO on PC00
775
776 // Set pin direction to input
777 gpio_set_pin_direction(SIM0_INT, GPIO_DIRECTION_IN);
778
779 gpio_set_pin_pull_mode(SIM0_INT,
780 // <y> Pull configuration
781 // <id> pad_pull_config
782 // <GPIO_PULL_OFF"> Off
783 // <GPIO_PULL_UP"> Pull-up
784 // <GPIO_PULL_DOWN"> Pull-down
785 GPIO_PULL_OFF);
786
787 gpio_set_pin_function(SIM0_INT, GPIO_PIN_FUNCTION_OFF);
788
789 // GPIO on PC01
790
791 // Set pin direction to input
792 gpio_set_pin_direction(SIM1_INT, GPIO_DIRECTION_IN);
793
794 gpio_set_pin_pull_mode(SIM1_INT,
795 // <y> Pull configuration
796 // <id> pad_pull_config
797 // <GPIO_PULL_OFF"> Off
798 // <GPIO_PULL_UP"> Pull-up
799 // <GPIO_PULL_DOWN"> Pull-down
800 GPIO_PULL_OFF);
801
802 gpio_set_pin_function(SIM1_INT, GPIO_PIN_FUNCTION_OFF);
803
804 // GPIO on PC02
805
806 // Set pin direction to input
807 gpio_set_pin_direction(SIM2_INT, GPIO_DIRECTION_IN);
808
809 gpio_set_pin_pull_mode(SIM2_INT,
810 // <y> Pull configuration
811 // <id> pad_pull_config
812 // <GPIO_PULL_OFF"> Off
813 // <GPIO_PULL_UP"> Pull-up
814 // <GPIO_PULL_DOWN"> Pull-down
815 GPIO_PULL_OFF);
816
817 gpio_set_pin_function(SIM2_INT, GPIO_PIN_FUNCTION_OFF);
818
819 // GPIO on PC03
820
821 // Set pin direction to input
822 gpio_set_pin_direction(SIM3_INT, GPIO_DIRECTION_IN);
823
824 gpio_set_pin_pull_mode(SIM3_INT,
825 // <y> Pull configuration
826 // <id> pad_pull_config
827 // <GPIO_PULL_OFF"> Off
828 // <GPIO_PULL_UP"> Pull-up
829 // <GPIO_PULL_DOWN"> Pull-down
830 GPIO_PULL_OFF);
831
832 gpio_set_pin_function(SIM3_INT, GPIO_PIN_FUNCTION_OFF);
833
Kévin Redon6a8295c2019-01-30 18:58:44 +0100834 // GPIO on PC14
835
836 // Set pin direction to input
837 gpio_set_pin_direction(SWITCH, GPIO_DIRECTION_IN);
838
839 gpio_set_pin_pull_mode(SWITCH,
840 // <y> Pull configuration
841 // <id> pad_pull_config
842 // <GPIO_PULL_OFF"> Off
843 // <GPIO_PULL_UP"> Pull-up
844 // <GPIO_PULL_DOWN"> Pull-down
845 GPIO_PULL_OFF);
846
847 gpio_set_pin_function(SWITCH, GPIO_PIN_FUNCTION_OFF);
848
Harald Welte092494e2019-02-24 10:33:40 +0100849 // GPIO on PC15
850
851 // Set pin direction to input
Kévin Redon3c045b22019-02-26 19:52:02 +0100852 gpio_set_pin_direction(MUX_STAT, GPIO_DIRECTION_IN);
Harald Welte092494e2019-02-24 10:33:40 +0100853
Kévin Redon3c045b22019-02-26 19:52:02 +0100854 gpio_set_pin_pull_mode(MUX_STAT,
Harald Welte092494e2019-02-24 10:33:40 +0100855 // <y> Pull configuration
856 // <id> pad_pull_config
857 // <GPIO_PULL_OFF"> Off
858 // <GPIO_PULL_UP"> Pull-up
859 // <GPIO_PULL_DOWN"> Pull-down
860 GPIO_PULL_OFF);
861
Kévin Redon3c045b22019-02-26 19:52:02 +0100862 gpio_set_pin_function(MUX_STAT, GPIO_PIN_FUNCTION_OFF);
Harald Welte092494e2019-02-24 10:33:40 +0100863
Kévin Redon4e39b012019-01-30 15:55:58 +0100864 // GPIO on PC26
Kévin Redon5908a5c2019-01-24 18:45:23 +0100865
Kévin Redon6a8295c2019-01-30 18:58:44 +0100866 gpio_set_pin_level(USER_LED,
Kévin Redon5908a5c2019-01-24 18:45:23 +0100867 // <y> Initial level
868 // <id> pad_initial_level
869 // <false"> Low
870 // <true"> High
Kévin Redon4e39b012019-01-30 15:55:58 +0100871 false);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100872
873 // Set pin direction to output
Kévin Redon6a8295c2019-01-30 18:58:44 +0100874 gpio_set_pin_direction(USER_LED, GPIO_DIRECTION_OUT);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100875
Kévin Redon6a8295c2019-01-30 18:58:44 +0100876 gpio_set_pin_function(USER_LED, GPIO_PIN_FUNCTION_OFF);
Kévin Redon5908a5c2019-01-24 18:45:23 +0100877
Harald Welte092494e2019-02-24 10:33:40 +0100878 // GPIO on PC27
879
880 gpio_set_pin_level(SCL4,
881 // <y> Initial level
882 // <id> pad_initial_level
883 // <false"> Low
884 // <true"> High
885 false);
886
887 // Set pin direction to output
888 gpio_set_pin_direction(SCL4, GPIO_DIRECTION_OUT);
889
890 gpio_set_pin_function(SCL4, GPIO_PIN_FUNCTION_OFF);
891
892 // GPIO on PC28
893
894 gpio_set_pin_level(SDA4,
895 // <y> Initial level
896 // <id> pad_initial_level
897 // <false"> Low
898 // <true"> High
899 false);
900
901 // Set pin direction to output
902 gpio_set_pin_direction(SDA4, GPIO_DIRECTION_OUT);
903
904 gpio_set_pin_function(SDA4, GPIO_PIN_FUNCTION_OFF);
905
Kévin Redon1f8ecef2019-01-31 13:36:12 +0100906 SIM0_init();
907 SIM1_init();
908 SIM2_init();
909 SIM3_init();
910 SIM4_init();
911 SIM5_init();
912 SIM6_init();
Harald Welte361ed202019-02-24 21:15:39 +0100913
Kévin Redon4cd3f7d2019-01-24 17:57:13 +0100914 UART_debug_init();
915
Kévin Redon69b92d92019-01-24 16:39:20 +0100916 USB_DEVICE_INSTANCE_init();
917}