LP-500 HoTT Telemetry added device definitions
[librepilot.git] / flight / targets / boards / revolution / board_hw_defs.c
blob9e33beeb28bb2202aa9b73d602e44784887a2287
1 /**
2 ******************************************************************************
3 * @file board_hw_defs.c
4 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
5 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012
7 * @addtogroup OpenPilotSystem OpenPilot System
8 * @{
9 * @addtogroup OpenPilotCore OpenPilot Core
10 * @{
11 * @brief Defines board specific static initializers for hardware for the Revolution board.
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #if defined(PIOS_INCLUDE_LED)
31 #include <pios_led_priv.h>
32 static const struct pios_gpio pios_leds[] = {
33 [PIOS_LED_HEARTBEAT] = {
34 .pin = {
35 .gpio = GPIOB,
36 .init = {
37 .GPIO_Pin = GPIO_Pin_12,
38 .GPIO_Speed = GPIO_Speed_50MHz,
39 .GPIO_Mode = GPIO_Mode_OUT,
40 .GPIO_OType = GPIO_OType_PP,
41 .GPIO_PuPd = GPIO_PuPd_UP
44 .active_low = true
46 [PIOS_LED_ALARM] = {
47 .pin = {
48 .gpio = GPIOB,
49 .init = {
50 .GPIO_Pin = GPIO_Pin_6,
51 .GPIO_Speed = GPIO_Speed_50MHz,
52 .GPIO_Mode = GPIO_Mode_OUT,
53 .GPIO_OType = GPIO_OType_PP,
54 .GPIO_PuPd = GPIO_PuPd_UP
57 .active_low = true
59 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
60 [PIOS_LED_D1] = {
61 .pin = {
62 .gpio = GPIOC,
63 .init = {
64 .GPIO_Pin = GPIO_Pin_6,
65 .GPIO_Speed = GPIO_Speed_50MHz,
66 .GPIO_Mode = GPIO_Mode_OUT,
67 .GPIO_OType = GPIO_OType_PP,
68 .GPIO_PuPd = GPIO_PuPd_UP
72 [PIOS_LED_D2] = {
73 .pin = {
74 .gpio = GPIOC,
75 .init = {
76 .GPIO_Pin = GPIO_Pin_7,
77 .GPIO_Speed = GPIO_Speed_50MHz,
78 .GPIO_Mode = GPIO_Mode_OUT,
79 .GPIO_OType = GPIO_OType_PP,
80 .GPIO_PuPd = GPIO_PuPd_UP
84 [PIOS_LED_D3] = {
85 .pin = {
86 .gpio = GPIOC,
87 .init = {
88 .GPIO_Pin = GPIO_Pin_8,
89 .GPIO_Speed = GPIO_Speed_50MHz,
90 .GPIO_Mode = GPIO_Mode_OUT,
91 .GPIO_OType = GPIO_OType_PP,
92 .GPIO_PuPd = GPIO_PuPd_UP
96 [PIOS_LED_D4] = {
97 .pin = {
98 .gpio = GPIOC,
99 .init = {
100 .GPIO_Pin = GPIO_Pin_9,
101 .GPIO_Speed = GPIO_Speed_50MHz,
102 .GPIO_Mode = GPIO_Mode_OUT,
103 .GPIO_OType = GPIO_OType_PP,
104 .GPIO_PuPd = GPIO_PuPd_UP
108 #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
111 static const struct pios_gpio_cfg pios_led_cfg = {
112 .gpios = pios_leds,
113 .num_gpios = NELEMENTS(pios_leds),
116 static const struct pios_gpio pios_leds_v2[] = {
117 [PIOS_LED_HEARTBEAT] = {
118 .pin = {
119 .gpio = GPIOB,
120 .init = {
121 .GPIO_Pin = GPIO_Pin_5,
122 .GPIO_Speed = GPIO_Speed_50MHz,
123 .GPIO_Mode = GPIO_Mode_OUT,
124 .GPIO_OType = GPIO_OType_PP,
125 .GPIO_PuPd = GPIO_PuPd_UP
128 .active_low = true
130 [PIOS_LED_ALARM] = {
131 .pin = {
132 .gpio = GPIOB,
133 .init = {
134 .GPIO_Pin = GPIO_Pin_4,
135 .GPIO_Speed = GPIO_Speed_50MHz,
136 .GPIO_Mode = GPIO_Mode_OUT,
137 .GPIO_OType = GPIO_OType_PP,
138 .GPIO_PuPd = GPIO_PuPd_UP
141 .active_low = true
143 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
144 [PIOS_LED_D1] = {
145 .pin = {
146 .gpio = GPIOB,
147 .init = {
148 .GPIO_Pin = GPIO_Pin_13,
149 .GPIO_Speed = GPIO_Speed_50MHz,
150 .GPIO_Mode = GPIO_Mode_OUT,
151 .GPIO_OType = GPIO_OType_PP,
152 .GPIO_PuPd = GPIO_PuPd_UP
156 [PIOS_LED_D2] = {
157 .pin = {
158 .gpio = GPIOB,
159 .init = {
160 .GPIO_Pin = GPIO_Pin_14,
161 .GPIO_Speed = GPIO_Speed_50MHz,
162 .GPIO_Mode = GPIO_Mode_OUT,
163 .GPIO_OType = GPIO_OType_PP,
164 .GPIO_PuPd = GPIO_PuPd_UP
168 [PIOS_LED_D3] = {
169 .pin = {
170 .gpio = GPIOB,
171 .init = {
172 .GPIO_Pin = GPIO_Pin_15,
173 .GPIO_Speed = GPIO_Speed_50MHz,
174 .GPIO_Mode = GPIO_Mode_OUT,
175 .GPIO_OType = GPIO_OType_PP,
176 .GPIO_PuPd = GPIO_PuPd_UP
180 [PIOS_LED_D4] = {
181 .pin = {
182 .gpio = GPIOC,
183 .init = {
184 .GPIO_Pin = GPIO_Pin_6,
185 .GPIO_Speed = GPIO_Speed_50MHz,
186 .GPIO_Mode = GPIO_Mode_OUT,
187 .GPIO_OType = GPIO_OType_PP,
188 .GPIO_PuPd = GPIO_PuPd_UP
192 #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
195 static const struct pios_gpio_cfg pios_led_v2_cfg = {
196 .gpios = pios_leds_v2,
197 .num_gpios = NELEMENTS(pios_leds_v2),
200 const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(uint32_t board_revision)
202 switch (board_revision) {
203 case 2:
204 return &pios_led_cfg;
206 break;
207 case 3:
208 return &pios_led_v2_cfg;
210 break;
211 default:
212 PIOS_DEBUG_Assert(0);
214 return NULL;
217 #endif /* PIOS_INCLUDE_LED */
219 #if defined(PIOS_INCLUDE_SPI)
220 #include <pios_spi_priv.h>
222 #if defined(PIOS_OVERO_SPI)
223 /* SPI2 Interface
224 * - Used for Flexi/IO/Overo communications
225 3: PB12 = SPI2 NSS, CAN2 RX
226 4: PB13 = SPI2 SCK, CAN2 TX, USART3 CTS
227 5: PB14 = SPI2 MISO, TIM12 CH1, USART3 RTS
228 6: PB15 = SPI2 MOSI, TIM12 CH2
230 #include <pios_overo_priv.h>
231 void PIOS_OVERO_irq_handler(void);
232 void DMA1_Stream7_IRQHandler(void) __attribute__((alias("PIOS_OVERO_irq_handler")));
233 static const struct pios_overo_cfg pios_overo_cfg = {
234 .regs = SPI2,
235 .remap = GPIO_AF_SPI2,
236 .init = {
237 .SPI_Mode = SPI_Mode_Slave,
238 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
239 .SPI_DataSize = SPI_DataSize_8b,
240 .SPI_NSS = SPI_NSS_Hard,
241 .SPI_FirstBit = SPI_FirstBit_MSB,
242 .SPI_CRCPolynomial = 7,
243 .SPI_CPOL = SPI_CPOL_High,
244 .SPI_CPHA = SPI_CPHA_2Edge,
245 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
247 .use_crc = false,
248 .dma = {
249 .irq = {
250 // Note this is the stream ID that triggers interrupts (in this case TX)
251 .flags = (DMA_IT_TCIF7),
252 .init = {
253 .NVIC_IRQChannel = DMA1_Stream7_IRQn,
254 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
255 .NVIC_IRQChannelSubPriority = 0,
256 .NVIC_IRQChannelCmd = ENABLE,
260 .rx = {
261 .channel = DMA1_Stream0,
262 .init = {
263 .DMA_Channel = DMA_Channel_0,
264 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
265 .DMA_DIR = DMA_DIR_PeripheralToMemory,
266 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
267 .DMA_MemoryInc = DMA_MemoryInc_Enable,
268 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
269 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
270 .DMA_Mode = DMA_Mode_Circular,
271 .DMA_Priority = DMA_Priority_Medium,
272 // TODO: Enable FIFO
273 .DMA_FIFOMode = DMA_FIFOMode_Disable,
274 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
275 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
276 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
279 .tx = {
280 .channel = DMA1_Stream7,
281 .init = {
282 .DMA_Channel = DMA_Channel_0,
283 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
284 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
285 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
286 .DMA_MemoryInc = DMA_MemoryInc_Enable,
287 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
288 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
289 .DMA_Mode = DMA_Mode_Circular,
290 .DMA_Priority = DMA_Priority_Medium,
291 .DMA_FIFOMode = DMA_FIFOMode_Disable,
292 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
293 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
294 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
298 .sclk = {
299 .gpio = GPIOB,
300 .init = {
301 .GPIO_Pin = GPIO_Pin_13,
302 .GPIO_Speed = GPIO_Speed_100MHz,
303 .GPIO_Mode = GPIO_Mode_AF,
304 .GPIO_OType = GPIO_OType_PP,
305 .GPIO_PuPd = GPIO_PuPd_NOPULL
308 .miso = {
309 .gpio = GPIOB,
310 .init = {
311 .GPIO_Pin = GPIO_Pin_14,
312 .GPIO_Speed = GPIO_Speed_50MHz,
313 .GPIO_Mode = GPIO_Mode_AF,
314 .GPIO_OType = GPIO_OType_PP,
315 .GPIO_PuPd = GPIO_PuPd_NOPULL
318 .mosi = {
319 .gpio = GPIOB,
320 .init = {
321 .GPIO_Pin = GPIO_Pin_15,
322 .GPIO_Speed = GPIO_Speed_50MHz,
323 .GPIO_Mode = GPIO_Mode_AF,
324 .GPIO_OType = GPIO_OType_PP,
325 .GPIO_PuPd = GPIO_PuPd_NOPULL
328 .slave_count = 1,
329 .ssel = {
331 .gpio = GPIOB,
332 .init = {
333 .GPIO_Pin = GPIO_Pin_12,
334 .GPIO_Speed = GPIO_Speed_50MHz,
335 .GPIO_Mode = GPIO_Mode_OUT,
336 .GPIO_OType = GPIO_OType_PP,
337 .GPIO_PuPd = GPIO_PuPd_UP
342 uint32_t pios_overo_id = 0;
343 void PIOS_OVERO_irq_handler(void)
345 /* Call into the generic code to handle the IRQ for this specific device */
346 PIOS_OVERO_DMA_irq_handler(pios_overo_id);
349 #endif /* PIOS_OVERO_SPI */
352 * SPI1 Interface
353 * Used for MPU6000 gyro and accelerometer
355 void PIOS_SPI_gyro_irq_handler(void);
356 void DMA2_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
357 void DMA2_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
358 static const struct pios_spi_cfg pios_spi_gyro_cfg = {
359 .regs = SPI1,
360 .remap = GPIO_AF_SPI1,
361 .init = {
362 .SPI_Mode = SPI_Mode_Master,
363 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
364 .SPI_DataSize = SPI_DataSize_8b,
365 .SPI_NSS = SPI_NSS_Soft,
366 .SPI_FirstBit = SPI_FirstBit_MSB,
367 .SPI_CRCPolynomial = 7,
368 .SPI_CPOL = SPI_CPOL_High,
369 .SPI_CPHA = SPI_CPHA_2Edge,
370 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16,
372 .use_crc = false,
373 .dma = {
374 .irq = {
375 .flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
376 .init = {
377 .NVIC_IRQChannel = DMA2_Stream0_IRQn,
378 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
379 .NVIC_IRQChannelSubPriority = 0,
380 .NVIC_IRQChannelCmd = ENABLE,
384 .rx = {
385 .channel = DMA2_Stream0,
386 .init = {
387 .DMA_Channel = DMA_Channel_3,
388 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
389 .DMA_DIR = DMA_DIR_PeripheralToMemory,
390 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
391 .DMA_MemoryInc = DMA_MemoryInc_Enable,
392 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
393 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
394 .DMA_Mode = DMA_Mode_Normal,
395 .DMA_Priority = DMA_Priority_Medium,
396 .DMA_FIFOMode = DMA_FIFOMode_Disable,
397 /* .DMA_FIFOThreshold */
398 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
399 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
402 .tx = {
403 .channel = DMA2_Stream3,
404 .init = {
405 .DMA_Channel = DMA_Channel_3,
406 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
407 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
408 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
409 .DMA_MemoryInc = DMA_MemoryInc_Enable,
410 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
411 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
412 .DMA_Mode = DMA_Mode_Normal,
413 .DMA_Priority = DMA_Priority_High,
414 .DMA_FIFOMode = DMA_FIFOMode_Disable,
415 /* .DMA_FIFOThreshold */
416 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
417 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
421 .sclk = {
422 .gpio = GPIOA,
423 .init = {
424 .GPIO_Pin = GPIO_Pin_5,
425 .GPIO_Speed = GPIO_Speed_100MHz,
426 .GPIO_Mode = GPIO_Mode_AF,
427 .GPIO_OType = GPIO_OType_PP,
428 .GPIO_PuPd = GPIO_PuPd_UP
431 .miso = {
432 .gpio = GPIOA,
433 .init = {
434 .GPIO_Pin = GPIO_Pin_6,
435 .GPIO_Speed = GPIO_Speed_50MHz,
436 .GPIO_Mode = GPIO_Mode_AF,
437 .GPIO_OType = GPIO_OType_PP,
438 .GPIO_PuPd = GPIO_PuPd_UP
441 .mosi = {
442 .gpio = GPIOA,
443 .init = {
444 .GPIO_Pin = GPIO_Pin_7,
445 .GPIO_Speed = GPIO_Speed_50MHz,
446 .GPIO_Mode = GPIO_Mode_AF,
447 .GPIO_OType = GPIO_OType_PP,
448 .GPIO_PuPd = GPIO_PuPd_UP
451 .slave_count = 1,
452 .ssel = {
454 .gpio = GPIOA,
455 .init = {
456 .GPIO_Pin = GPIO_Pin_4,
457 .GPIO_Speed = GPIO_Speed_50MHz,
458 .GPIO_Mode = GPIO_Mode_OUT,
459 .GPIO_OType = GPIO_OType_PP,
460 .GPIO_PuPd = GPIO_PuPd_UP
466 static uint32_t pios_spi_gyro_id;
467 void PIOS_SPI_gyro_irq_handler(void)
469 /* Call into the generic code to handle the IRQ for this specific device */
470 PIOS_SPI_IRQ_Handler(pios_spi_gyro_id);
475 * SPI3 Interface
476 * Used for Flash and the RFM22B
478 void PIOS_SPI_telem_flash_irq_handler(void);
479 void DMA1_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_telem_flash_irq_handler")));
480 void DMA1_Stream5_IRQHandler(void) __attribute__((alias("PIOS_SPI_telem_flash_irq_handler")));
481 static const struct pios_spi_cfg pios_spi_telem_flash_cfg = {
482 .regs = SPI3,
483 .remap = GPIO_AF_SPI3,
484 .init = {
485 .SPI_Mode = SPI_Mode_Master,
486 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
487 .SPI_DataSize = SPI_DataSize_8b,
488 .SPI_NSS = SPI_NSS_Soft,
489 .SPI_FirstBit = SPI_FirstBit_MSB,
490 .SPI_CRCPolynomial = 7,
491 .SPI_CPOL = SPI_CPOL_Low,
492 .SPI_CPHA = SPI_CPHA_1Edge,
493 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8,
495 .use_crc = false,
496 .dma = {
497 .irq = {
498 // Note this is the stream ID that triggers interrupts (in this case RX)
499 .flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
500 .init = {
501 .NVIC_IRQChannel = DMA1_Stream0_IRQn,
502 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
503 .NVIC_IRQChannelSubPriority = 0,
504 .NVIC_IRQChannelCmd = ENABLE,
508 .rx = {
509 .channel = DMA1_Stream0,
510 .init = {
511 .DMA_Channel = DMA_Channel_0,
512 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
513 .DMA_DIR = DMA_DIR_PeripheralToMemory,
514 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
515 .DMA_MemoryInc = DMA_MemoryInc_Enable,
516 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
517 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
518 .DMA_Mode = DMA_Mode_Normal,
519 .DMA_Priority = DMA_Priority_Medium,
520 // TODO: Enable FIFO
521 .DMA_FIFOMode = DMA_FIFOMode_Disable,
522 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
523 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
524 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
527 .tx = {
528 .channel = DMA1_Stream5,
529 .init = {
530 .DMA_Channel = DMA_Channel_0,
531 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
532 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
533 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
534 .DMA_MemoryInc = DMA_MemoryInc_Enable,
535 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
536 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
537 .DMA_Mode = DMA_Mode_Normal,
538 .DMA_Priority = DMA_Priority_Medium,
539 .DMA_FIFOMode = DMA_FIFOMode_Disable,
540 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
541 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
542 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
546 .sclk = {
547 .gpio = GPIOC,
548 .init = {
549 .GPIO_Pin = GPIO_Pin_10,
550 .GPIO_Speed = GPIO_Speed_100MHz,
551 .GPIO_Mode = GPIO_Mode_AF,
552 .GPIO_OType = GPIO_OType_PP,
553 .GPIO_PuPd = GPIO_PuPd_NOPULL
556 .miso = {
557 .gpio = GPIOC,
558 .init = {
559 .GPIO_Pin = GPIO_Pin_11,
560 .GPIO_Speed = GPIO_Speed_50MHz,
561 .GPIO_Mode = GPIO_Mode_AF,
562 .GPIO_OType = GPIO_OType_PP,
563 .GPIO_PuPd = GPIO_PuPd_NOPULL
566 .mosi = {
567 .gpio = GPIOC,
568 .init = {
569 .GPIO_Pin = GPIO_Pin_12,
570 .GPIO_Speed = GPIO_Speed_50MHz,
571 .GPIO_Mode = GPIO_Mode_AF,
572 .GPIO_OType = GPIO_OType_PP,
573 .GPIO_PuPd = GPIO_PuPd_NOPULL
576 .slave_count = 2,
577 .ssel = {
578 { // RFM22b
579 .gpio = GPIOA,
580 .init = {
581 .GPIO_Pin = GPIO_Pin_15,
582 .GPIO_Speed = GPIO_Speed_50MHz,
583 .GPIO_Mode = GPIO_Mode_OUT,
584 .GPIO_OType = GPIO_OType_PP,
585 .GPIO_PuPd = GPIO_PuPd_UP
588 { // Flash
589 .gpio = GPIOB,
590 .init = {
591 .GPIO_Pin = GPIO_Pin_3,
592 .GPIO_Speed = GPIO_Speed_50MHz,
593 .GPIO_Mode = GPIO_Mode_OUT,
594 .GPIO_OType = GPIO_OType_PP,
595 .GPIO_PuPd = GPIO_PuPd_UP
601 uint32_t pios_spi_telem_flash_id;
602 void PIOS_SPI_telem_flash_irq_handler(void)
604 /* Call into the generic code to handle the IRQ for this specific device */
605 PIOS_SPI_IRQ_Handler(pios_spi_telem_flash_id);
609 #if defined(PIOS_INCLUDE_RFM22B)
610 #include <pios_rfm22b_priv.h>
612 static const struct pios_exti_cfg pios_exti_rfm22b_cfg __exti_config = {
613 .vector = PIOS_RFM22_EXT_Int,
614 .line = EXTI_Line2,
615 .pin = {
616 .gpio = GPIOD,
617 .init = {
618 .GPIO_Pin = GPIO_Pin_2,
619 .GPIO_Speed = GPIO_Speed_100MHz,
620 .GPIO_Mode = GPIO_Mode_IN,
621 .GPIO_OType = GPIO_OType_OD,
622 .GPIO_PuPd = GPIO_PuPd_NOPULL,
625 .irq = {
626 .init = {
627 .NVIC_IRQChannel = EXTI2_IRQn,
628 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
629 .NVIC_IRQChannelSubPriority = 0,
630 .NVIC_IRQChannelCmd = ENABLE,
633 .exti = {
634 .init = {
635 .EXTI_Line = EXTI_Line2, // matches above GPIO pin
636 .EXTI_Mode = EXTI_Mode_Interrupt,
637 .EXTI_Trigger = EXTI_Trigger_Falling,
638 .EXTI_LineCmd = ENABLE,
643 const struct pios_rfm22b_cfg pios_rfm22b_rm1_cfg = {
644 .spi_cfg = &pios_spi_telem_flash_cfg,
645 .exti_cfg = &pios_exti_rfm22b_cfg,
646 .RFXtalCap = 0x7f,
647 .slave_num = 0,
648 .gpio_direction = GPIO0_RX_GPIO1_TX,
651 const struct pios_rfm22b_cfg pios_rfm22b_rm2_cfg = {
652 .spi_cfg = &pios_spi_telem_flash_cfg,
653 .exti_cfg = &pios_exti_rfm22b_cfg,
654 .RFXtalCap = 0x7f,
655 .slave_num = 0,
656 .gpio_direction = GPIO0_TX_GPIO1_RX,
659 const struct pios_rfm22b_cfg *PIOS_BOARD_HW_DEFS_GetRfm22Cfg(uint32_t board_revision)
661 switch (board_revision) {
662 case 2:
663 return &pios_rfm22b_rm1_cfg;
665 break;
666 case 3:
667 return &pios_rfm22b_rm2_cfg;
669 break;
670 default:
671 PIOS_DEBUG_Assert(0);
673 return NULL;
676 #endif /* PIOS_INCLUDE_RFM22B */
678 #if defined(PIOS_INCLUDE_OPENLRS)
680 #include <pios_openlrs_priv.h>
682 static const struct pios_exti_cfg pios_exti_openlrs_cfg __exti_config = {
683 .vector = PIOS_OpenLRS_EXT_Int,
684 .line = EXTI_Line2,
685 .pin = {
686 .gpio = GPIOD,
687 .init = {
688 .GPIO_Pin = GPIO_Pin_2,
689 .GPIO_Speed = GPIO_Speed_100MHz,
690 .GPIO_Mode = GPIO_Mode_IN,
691 .GPIO_OType = GPIO_OType_OD,
692 .GPIO_PuPd = GPIO_PuPd_NOPULL,
695 .irq = {
696 .init = {
697 .NVIC_IRQChannel = EXTI2_IRQn,
698 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
699 .NVIC_IRQChannelSubPriority = 0,
700 .NVIC_IRQChannelCmd = ENABLE,
703 .exti = {
704 .init = {
705 .EXTI_Line = EXTI_Line2, // matches above GPIO pin
706 .EXTI_Mode = EXTI_Mode_Interrupt,
707 .EXTI_Trigger = EXTI_Trigger_Falling,
708 .EXTI_LineCmd = ENABLE,
713 const struct pios_openlrs_cfg pios_openlrs_rm1_cfg = {
714 .spi_cfg = &pios_spi_telem_flash_cfg,
715 .exti_cfg = &pios_exti_openlrs_cfg,
716 .gpio_direction = GPIO0_RX_GPIO1_TX,
719 const struct pios_openlrs_cfg pios_openlrs_rm2_cfg = {
720 .spi_cfg = &pios_spi_telem_flash_cfg,
721 .exti_cfg = &pios_exti_openlrs_cfg,
722 .gpio_direction = GPIO0_TX_GPIO1_RX,
725 const struct pios_openlrs_cfg *PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(uint32_t board_revision)
727 switch (board_revision) {
728 case 2:
729 return &pios_openlrs_rm1_cfg;
731 break;
732 case 3:
733 return &pios_openlrs_rm2_cfg;
735 break;
736 default:
737 PIOS_DEBUG_Assert(0);
739 return NULL;
742 #endif /* PIOS_INCLUDE_OPENLRS */
744 #endif /* PIOS_INCLUDE_SPI */
746 #if defined(PIOS_INCLUDE_FLASH)
747 #include "pios_flashfs_logfs_priv.h"
748 #include "pios_flash_jedec_priv.h"
749 #include "pios_flash_internal_priv.h"
751 static const struct flashfs_logfs_cfg flashfs_external_user_cfg = {
752 .fs_magic = 0x99abceff,
753 .total_fs_size = 0x001C0000, /* 2M bytes (32 sectors = entire chip) */
754 .arena_size = 0x000E0000, /* biggest possible arena size fssize/2 */
755 .slot_size = 0x00000100, /* 256 bytes */
757 .start_offset = 0x00040000, /* start offset */
758 .sector_size = 0x00010000, /* 64K bytes */
759 .page_size = 0x00000100, /* 256 bytes */
762 static const struct flashfs_logfs_cfg flashfs_external_system_cfg = {
763 .fs_magic = 0x99bbcdef,
764 .total_fs_size = 0x00040000, /* 2M bytes (32 sectors = entire chip) */
765 .arena_size = 0x00010000, /* 256 * slot size */
766 .slot_size = 0x00000100, /* 256 bytes */
768 .start_offset = 0, /* start at the beginning of the chip */
769 .sector_size = 0x00010000, /* 64K bytes */
770 .page_size = 0x00000100, /* 256 bytes */
774 static const struct pios_flash_internal_cfg flash_internal_cfg = {};
776 static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
777 .fs_magic = 0x99abcfef,
778 .total_fs_size = EE_BANK_SIZE, /* 32K bytes (2x16KB sectors) */
779 .arena_size = 0x00004000, /* 64 * slot size = 16K bytes = 1 sector */
780 .slot_size = 0x00000100, /* 256 bytes */
782 .start_offset = EE_BANK_BASE, /* start after the bootloader */
783 .sector_size = 0x00004000, /* 16K bytes */
784 .page_size = 0x00004000, /* 16K bytes */
787 #endif /* PIOS_INCLUDE_FLASH */
789 #include <pios_usart_priv.h>
791 #ifdef PIOS_INCLUDE_COM_TELEM
794 * MAIN USART
796 static const struct pios_usart_cfg pios_usart_main_cfg = {
797 .regs = USART1,
798 .remap = GPIO_AF_USART1,
799 .init = {
800 .USART_BaudRate = 57600,
801 .USART_WordLength = USART_WordLength_8b,
802 .USART_Parity = USART_Parity_No,
803 .USART_StopBits = USART_StopBits_1,
804 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
805 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
807 .irq = {
808 .init = {
809 .NVIC_IRQChannel = USART1_IRQn,
810 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
811 .NVIC_IRQChannelSubPriority = 0,
812 .NVIC_IRQChannelCmd = ENABLE,
815 .rx = {
816 .gpio = GPIOA,
817 .init = {
818 .GPIO_Pin = GPIO_Pin_10,
819 .GPIO_Speed = GPIO_Speed_2MHz,
820 .GPIO_Mode = GPIO_Mode_AF,
821 .GPIO_OType = GPIO_OType_PP,
822 .GPIO_PuPd = GPIO_PuPd_UP
825 .tx = {
826 .gpio = GPIOA,
827 .init = {
828 .GPIO_Pin = GPIO_Pin_9,
829 .GPIO_Speed = GPIO_Speed_2MHz,
830 .GPIO_Mode = GPIO_Mode_AF,
831 .GPIO_OType = GPIO_OType_PP,
832 .GPIO_PuPd = GPIO_PuPd_UP
836 #endif /* PIOS_INCLUDE_COM_TELEM */
838 #ifdef PIOS_INCLUDE_DSM
840 #include "pios_dsm_priv.h"
841 static const struct pios_usart_cfg pios_usart_dsm_main_cfg = {
842 .regs = USART1,
843 .remap = GPIO_AF_USART1,
844 .init = {
845 .USART_BaudRate = 115200,
846 .USART_WordLength = USART_WordLength_8b,
847 .USART_Parity = USART_Parity_No,
848 .USART_StopBits = USART_StopBits_1,
849 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
850 .USART_Mode = USART_Mode_Rx,
852 .irq = {
853 .init = {
854 .NVIC_IRQChannel = USART1_IRQn,
855 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
856 .NVIC_IRQChannelSubPriority = 0,
857 .NVIC_IRQChannelCmd = ENABLE,
860 .rx = {
861 .gpio = GPIOA,
862 .init = {
863 .GPIO_Pin = GPIO_Pin_10,
864 .GPIO_Speed = GPIO_Speed_2MHz,
865 .GPIO_Mode = GPIO_Mode_AF,
866 .GPIO_OType = GPIO_OType_PP,
867 .GPIO_PuPd = GPIO_PuPd_UP
870 .tx = {
871 .gpio = GPIOA,
872 .init = {
873 .GPIO_Pin = GPIO_Pin_9,
874 .GPIO_Speed = GPIO_Speed_2MHz,
875 .GPIO_Mode = GPIO_Mode_AF,
876 .GPIO_OType = GPIO_OType_PP,
877 .GPIO_PuPd = GPIO_PuPd_UP
882 // Because of the inverter on the main port this will not
883 // work. Notice the mode is set to IN to maintain API
884 // compatibility but protect the pins
885 static const struct pios_dsm_cfg pios_dsm_main_cfg = {
886 .bind = {
887 .gpio = GPIOA,
888 .init = {
889 .GPIO_Pin = GPIO_Pin_10,
890 .GPIO_Speed = GPIO_Speed_2MHz,
891 .GPIO_Mode = GPIO_Mode_IN,
892 .GPIO_OType = GPIO_OType_PP,
893 .GPIO_PuPd = GPIO_PuPd_NOPULL
898 #endif /* PIOS_INCLUDE_DSM */
900 #include <pios_sbus_priv.h>
901 #if defined(PIOS_INCLUDE_SBUS)
903 * S.Bus USART
905 #include <pios_sbus_priv.h>
907 static const struct pios_usart_cfg pios_usart_sbus_main_cfg = {
908 .regs = USART1,
909 .remap = GPIO_AF_USART1,
910 .init = {
911 .USART_BaudRate = 100000,
912 .USART_WordLength = USART_WordLength_8b,
913 .USART_Parity = USART_Parity_Even,
914 .USART_StopBits = USART_StopBits_2,
915 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
916 .USART_Mode = USART_Mode_Rx,
918 .irq = {
919 .init = {
920 .NVIC_IRQChannel = USART1_IRQn,
921 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
922 .NVIC_IRQChannelSubPriority = 0,
923 .NVIC_IRQChannelCmd = ENABLE,
926 .rx = {
927 .gpio = GPIOA,
928 .init = {
929 .GPIO_Pin = GPIO_Pin_10,
930 .GPIO_Speed = GPIO_Speed_2MHz,
931 .GPIO_Mode = GPIO_Mode_AF,
932 .GPIO_OType = GPIO_OType_PP,
933 .GPIO_PuPd = GPIO_PuPd_UP
936 .tx = {
937 .gpio = GPIOA,
938 .init = {
939 .GPIO_Pin = GPIO_Pin_9,
940 .GPIO_Speed = GPIO_Speed_2MHz,
941 .GPIO_Mode = GPIO_Mode_OUT,
942 .GPIO_OType = GPIO_OType_PP,
943 .GPIO_PuPd = GPIO_PuPd_NOPULL
948 #endif /* PIOS_INCLUDE_SBUS */
950 // Need this defined regardless to be able to turn it off
951 static const struct pios_sbus_cfg pios_sbus_cfg = {
952 /* Inverter configuration */
953 .inv = {
954 .gpio = GPIOC,
955 .init = {
956 .GPIO_Pin = GPIO_Pin_0,
957 .GPIO_Speed = GPIO_Speed_2MHz,
958 .GPIO_Mode = GPIO_Mode_OUT,
959 .GPIO_OType = GPIO_OType_PP,
960 .GPIO_PuPd = GPIO_PuPd_UP
963 .gpio_inv_enable = Bit_SET,
964 .gpio_inv_disable = Bit_RESET,
965 .gpio_clk_func = RCC_AHB1PeriphClockCmd,
966 .gpio_clk_periph = RCC_AHB1Periph_GPIOC,
969 #ifdef PIOS_INCLUDE_COM_FLEXI
971 * FLEXI PORT
973 static const struct pios_usart_cfg pios_usart_flexi_cfg = {
974 .regs = USART3,
975 .remap = GPIO_AF_USART3,
976 .init = {
977 .USART_BaudRate = 57600,
978 .USART_WordLength = USART_WordLength_8b,
979 .USART_Parity = USART_Parity_No,
980 .USART_StopBits = USART_StopBits_1,
981 .USART_HardwareFlowControl =
982 USART_HardwareFlowControl_None,
983 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
985 .irq = {
986 .init = {
987 .NVIC_IRQChannel = USART3_IRQn,
988 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
989 .NVIC_IRQChannelSubPriority = 0,
990 .NVIC_IRQChannelCmd = ENABLE,
993 .rx = {
994 .gpio = GPIOB,
995 .init = {
996 .GPIO_Pin = GPIO_Pin_11,
997 .GPIO_Speed = GPIO_Speed_2MHz,
998 .GPIO_Mode = GPIO_Mode_AF,
999 .GPIO_OType = GPIO_OType_PP,
1000 .GPIO_PuPd = GPIO_PuPd_UP
1003 .tx = {
1004 .gpio = GPIOB,
1005 .init = {
1006 .GPIO_Pin = GPIO_Pin_10,
1007 .GPIO_Speed = GPIO_Speed_2MHz,
1008 .GPIO_Mode = GPIO_Mode_AF,
1009 .GPIO_OType = GPIO_OType_PP,
1010 .GPIO_PuPd = GPIO_PuPd_UP
1015 #endif /* PIOS_INCLUDE_COM_FLEXI */
1017 #ifdef PIOS_INCLUDE_DSM
1019 #include "pios_dsm_priv.h"
1020 static const struct pios_usart_cfg pios_usart_dsm_flexi_cfg = {
1021 .regs = USART3,
1022 .remap = GPIO_AF_USART3,
1023 .init = {
1024 .USART_BaudRate = 115200,
1025 .USART_WordLength = USART_WordLength_8b,
1026 .USART_Parity = USART_Parity_No,
1027 .USART_StopBits = USART_StopBits_1,
1028 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1029 .USART_Mode = USART_Mode_Rx,
1031 .irq = {
1032 .init = {
1033 .NVIC_IRQChannel = USART3_IRQn,
1034 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1035 .NVIC_IRQChannelSubPriority = 0,
1036 .NVIC_IRQChannelCmd = ENABLE,
1039 .rx = {
1040 .gpio = GPIOB,
1041 .init = {
1042 .GPIO_Pin = GPIO_Pin_11,
1043 .GPIO_Speed = GPIO_Speed_2MHz,
1044 .GPIO_Mode = GPIO_Mode_AF,
1045 .GPIO_OType = GPIO_OType_PP,
1046 .GPIO_PuPd = GPIO_PuPd_UP
1049 .tx = {
1050 .gpio = GPIOB,
1051 .init = {
1052 .GPIO_Pin = GPIO_Pin_10,
1053 .GPIO_Speed = GPIO_Speed_2MHz,
1054 .GPIO_Mode = GPIO_Mode_AF,
1055 .GPIO_OType = GPIO_OType_PP,
1056 .GPIO_PuPd = GPIO_PuPd_UP
1061 static const struct pios_dsm_cfg pios_dsm_flexi_cfg = {
1062 .bind = {
1063 .gpio = GPIOB,
1064 .init = {
1065 .GPIO_Pin = GPIO_Pin_11,
1066 .GPIO_Speed = GPIO_Speed_2MHz,
1067 .GPIO_Mode = GPIO_Mode_OUT,
1068 .GPIO_OType = GPIO_OType_PP,
1069 .GPIO_PuPd = GPIO_PuPd_NOPULL
1074 #endif /* PIOS_INCLUDE_DSM */
1076 #if defined(PIOS_INCLUDE_SRXL)
1078 * SRXL USART
1080 #include <pios_srxl_priv.h>
1082 static const struct pios_usart_cfg pios_usart_srxl_flexi_cfg = {
1083 .regs = USART3,
1084 .remap = GPIO_AF_USART3,
1085 .init = {
1086 .USART_BaudRate = 115200,
1087 .USART_WordLength = USART_WordLength_8b,
1088 .USART_Parity = USART_Parity_No,
1089 .USART_StopBits = USART_StopBits_1,
1090 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1091 .USART_Mode = USART_Mode_Rx,
1093 .irq = {
1094 .init = {
1095 .NVIC_IRQChannel = USART3_IRQn,
1096 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1097 .NVIC_IRQChannelSubPriority = 0,
1098 .NVIC_IRQChannelCmd = ENABLE,
1101 .rx = {
1102 .gpio = GPIOB,
1103 .init = {
1104 .GPIO_Pin = GPIO_Pin_11,
1105 .GPIO_Speed = GPIO_Speed_2MHz,
1106 .GPIO_Mode = GPIO_Mode_AF,
1107 .GPIO_OType = GPIO_OType_PP,
1108 .GPIO_PuPd = GPIO_PuPd_UP
1111 .tx = {
1112 .gpio = GPIOB,
1113 .init = {
1114 .GPIO_Pin = GPIO_Pin_10,
1115 .GPIO_Speed = GPIO_Speed_2MHz,
1116 .GPIO_Mode = GPIO_Mode_OUT,
1117 .GPIO_OType = GPIO_OType_PP,
1118 .GPIO_PuPd = GPIO_PuPd_UP
1123 #endif /* PIOS_INCLUDE_SRXL */
1125 #if defined(PIOS_INCLUDE_HOTT)
1127 * HOTT USART
1129 #include <pios_hott_priv.h>
1131 static const struct pios_usart_cfg pios_usart_hott_flexi_cfg = {
1132 .regs = USART3,
1133 .remap = GPIO_AF_USART3,
1134 .init = {
1135 .USART_BaudRate = 115200,
1136 .USART_WordLength = USART_WordLength_8b,
1137 .USART_Parity = USART_Parity_No,
1138 .USART_StopBits = USART_StopBits_1,
1139 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1140 .USART_Mode = USART_Mode_Rx,
1142 .irq = {
1143 .init = {
1144 .NVIC_IRQChannel = USART3_IRQn,
1145 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1146 .NVIC_IRQChannelSubPriority = 0,
1147 .NVIC_IRQChannelCmd = ENABLE,
1150 .rx = {
1151 .gpio = GPIOB,
1152 .init = {
1153 .GPIO_Pin = GPIO_Pin_11,
1154 .GPIO_Speed = GPIO_Speed_2MHz,
1155 .GPIO_Mode = GPIO_Mode_AF,
1156 .GPIO_OType = GPIO_OType_PP,
1157 .GPIO_PuPd = GPIO_PuPd_UP
1160 .tx = {
1161 .gpio = GPIOB,
1162 .init = {
1163 .GPIO_Pin = GPIO_Pin_10,
1164 .GPIO_Speed = GPIO_Speed_2MHz,
1165 .GPIO_Mode = GPIO_Mode_OUT,
1166 .GPIO_OType = GPIO_OType_PP,
1167 .GPIO_PuPd = GPIO_PuPd_UP
1172 #endif /* PIOS_INCLUDE_HOTT */
1174 #if defined(PIOS_INCLUDE_IBUS)
1176 * IBUS USART
1178 #include <pios_ibus_priv.h>
1180 static const struct pios_usart_cfg pios_usart_ibus_flexi_cfg = {
1181 .regs = USART3,
1182 .remap = GPIO_AF_USART3,
1183 .init = {
1184 .USART_BaudRate = 115200,
1185 .USART_WordLength = USART_WordLength_8b,
1186 .USART_Parity = USART_Parity_No,
1187 .USART_StopBits = USART_StopBits_1,
1188 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1189 .USART_Mode = USART_Mode_Rx,
1191 .irq = {
1192 .init = {
1193 .NVIC_IRQChannel = USART3_IRQn,
1194 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1195 .NVIC_IRQChannelSubPriority = 0,
1196 .NVIC_IRQChannelCmd = ENABLE,
1199 .rx = {
1200 .gpio = GPIOB,
1201 .init = {
1202 .GPIO_Pin = GPIO_Pin_11,
1203 .GPIO_Speed = GPIO_Speed_2MHz,
1204 .GPIO_Mode = GPIO_Mode_AF,
1205 .GPIO_OType = GPIO_OType_PP,
1206 .GPIO_PuPd = GPIO_PuPd_UP
1209 .tx = {
1210 .gpio = GPIOB,
1211 .init = {
1212 .GPIO_Pin = GPIO_Pin_10,
1213 .GPIO_Speed = GPIO_Speed_2MHz,
1214 .GPIO_Mode = GPIO_Mode_OUT,
1215 .GPIO_OType = GPIO_OType_PP,
1216 .GPIO_PuPd = GPIO_PuPd_UP
1221 static const struct pios_usart_cfg pios_usart_ibus_rcvr_cfg = {
1222 .regs = USART6,
1223 .remap = GPIO_AF_USART6,
1224 .init = {
1225 .USART_BaudRate = 115200,
1226 .USART_WordLength = USART_WordLength_8b,
1227 .USART_Parity = USART_Parity_No,
1228 .USART_StopBits = USART_StopBits_1,
1229 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1230 .USART_Mode = USART_Mode_Rx,
1232 .irq = {
1233 .init = {
1234 .NVIC_IRQChannel = USART6_IRQn,
1235 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1236 .NVIC_IRQChannelSubPriority = 0,
1237 .NVIC_IRQChannelCmd = ENABLE,
1240 .rx = {
1241 .gpio = GPIOC,
1242 .init = {
1243 .GPIO_Pin = GPIO_Pin_7,
1244 .GPIO_Speed = GPIO_Speed_2MHz,
1245 .GPIO_Mode = GPIO_Mode_AF,
1246 .GPIO_OType = GPIO_OType_PP,
1247 .GPIO_PuPd = GPIO_PuPd_UP
1252 #endif /* PIOS_INCLUDE_IBUS */
1254 #if defined(PIOS_INCLUDE_EXBUS)
1256 * EXBUS USART
1258 #include <pios_exbus_priv.h>
1260 static const struct pios_usart_cfg pios_usart_exbus_flexi_cfg = {
1261 .regs = USART3,
1262 .remap = GPIO_AF_USART3,
1263 .init = {
1264 .USART_BaudRate = 125000,
1265 .USART_WordLength = USART_WordLength_8b,
1266 .USART_Parity = USART_Parity_No,
1267 .USART_StopBits = USART_StopBits_1,
1268 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1269 .USART_Mode = USART_Mode_Rx,
1271 .irq = {
1272 .init = {
1273 .NVIC_IRQChannel = USART3_IRQn,
1274 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1275 .NVIC_IRQChannelSubPriority = 0,
1276 .NVIC_IRQChannelCmd = ENABLE,
1279 .rx = {
1280 .gpio = GPIOB,
1281 .init = {
1282 .GPIO_Pin = GPIO_Pin_11,
1283 .GPIO_Speed = GPIO_Speed_2MHz,
1284 .GPIO_Mode = GPIO_Mode_AF,
1285 .GPIO_OType = GPIO_OType_PP,
1286 .GPIO_PuPd = GPIO_PuPd_UP
1289 .tx = {
1290 .gpio = GPIOB,
1291 .init = {
1292 .GPIO_Pin = GPIO_Pin_10,
1293 .GPIO_Speed = GPIO_Speed_2MHz,
1294 .GPIO_Mode = GPIO_Mode_OUT,
1295 .GPIO_OType = GPIO_OType_PP,
1296 .GPIO_PuPd = GPIO_PuPd_UP
1301 #endif /* PIOS_INCLUDE_EXBUS */
1304 * HK OSD
1306 static const struct pios_usart_cfg pios_usart_hkosd_main_cfg = {
1307 .regs = USART1,
1308 .remap = GPIO_AF_USART1,
1309 .init = {
1310 .USART_BaudRate = 57600,
1311 .USART_WordLength = USART_WordLength_8b,
1312 .USART_Parity = USART_Parity_No,
1313 .USART_StopBits = USART_StopBits_1,
1314 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1315 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
1317 .irq = {
1318 .init = {
1319 .NVIC_IRQChannel = USART1_IRQn,
1320 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1321 .NVIC_IRQChannelSubPriority = 0,
1322 .NVIC_IRQChannelCmd = ENABLE,
1325 .rx = {
1326 .gpio = GPIOA,
1327 .init = {
1328 .GPIO_Pin = GPIO_Pin_10,
1329 .GPIO_Speed = GPIO_Speed_2MHz,
1330 .GPIO_Mode = GPIO_Mode_AF,
1331 .GPIO_OType = GPIO_OType_PP,
1332 .GPIO_PuPd = GPIO_PuPd_UP
1335 .tx = {
1336 .gpio = GPIOA,
1337 .init = {
1338 .GPIO_Pin = GPIO_Pin_9,
1339 .GPIO_Speed = GPIO_Speed_2MHz,
1340 .GPIO_Mode = GPIO_Mode_AF,
1341 .GPIO_OType = GPIO_OType_PP,
1342 .GPIO_PuPd = GPIO_PuPd_UP
1347 static const struct pios_usart_cfg pios_usart_hkosd_flexi_cfg = {
1348 .regs = USART3,
1349 .remap = GPIO_AF_USART3,
1350 .init = {
1351 .USART_BaudRate = 57600,
1352 .USART_WordLength = USART_WordLength_8b,
1353 .USART_Parity = USART_Parity_No,
1354 .USART_StopBits = USART_StopBits_1,
1355 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1356 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
1358 .irq = {
1359 .init = {
1360 .NVIC_IRQChannel = USART3_IRQn,
1361 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1362 .NVIC_IRQChannelSubPriority = 0,
1363 .NVIC_IRQChannelCmd = ENABLE,
1366 .rx = {
1367 .gpio = GPIOB,
1368 .init = {
1369 .GPIO_Pin = GPIO_Pin_11,
1370 .GPIO_Speed = GPIO_Speed_2MHz,
1371 .GPIO_Mode = GPIO_Mode_AF,
1372 .GPIO_OType = GPIO_OType_PP,
1373 .GPIO_PuPd = GPIO_PuPd_UP
1376 .tx = {
1377 .gpio = GPIOB,
1378 .init = {
1379 .GPIO_Pin = GPIO_Pin_10,
1380 .GPIO_Speed = GPIO_Speed_2MHz,
1381 .GPIO_Mode = GPIO_Mode_AF,
1382 .GPIO_OType = GPIO_OType_PP,
1383 .GPIO_PuPd = GPIO_PuPd_UP
1388 static const struct pios_usart_cfg pios_usart_rcvrport_cfg = {
1389 .regs = USART6,
1390 .remap = GPIO_AF_USART6,
1391 .init = {
1392 .USART_BaudRate = 57600,
1393 .USART_WordLength = USART_WordLength_8b,
1394 .USART_Parity = USART_Parity_No,
1395 .USART_StopBits = USART_StopBits_1,
1396 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1397 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
1399 .irq = {
1400 .init = {
1401 .NVIC_IRQChannel = USART6_IRQn,
1402 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1403 .NVIC_IRQChannelSubPriority = 0,
1404 .NVIC_IRQChannelCmd = ENABLE,
1408 .dtr = {
1409 // FlexIO pin 9
1410 .gpio = GPIOC,
1411 .init = {
1412 .GPIO_Pin = GPIO_Pin_8,
1413 .GPIO_Speed = GPIO_Speed_25MHz,
1414 .GPIO_Mode = GPIO_Mode_OUT,
1415 .GPIO_OType = GPIO_OType_PP,
1419 .tx = {
1420 // * 7: PC6 = TIM8 CH1, USART6 TX
1421 .gpio = GPIOC,
1422 .init = {
1423 .GPIO_Pin = GPIO_Pin_6,
1424 .GPIO_Speed = GPIO_Speed_2MHz,
1425 .GPIO_Mode = GPIO_Mode_AF,
1426 .GPIO_OType = GPIO_OType_PP,
1427 .GPIO_PuPd = GPIO_PuPd_UP
1429 .pin_source = GPIO_PinSource6,
1432 .rx = {
1433 // * 8: PC7 = TIM8 CH2, USART6 RX
1434 .gpio = GPIOC,
1435 .init = {
1436 .GPIO_Pin = GPIO_Pin_7,
1437 .GPIO_Speed = GPIO_Speed_2MHz,
1438 .GPIO_Mode = GPIO_Mode_AF,
1439 .GPIO_OType = GPIO_OType_PP,
1440 .GPIO_PuPd = GPIO_PuPd_UP
1442 .pin_source = GPIO_PinSource7,
1446 #if defined(PIOS_INCLUDE_COM)
1448 #include <pios_com_priv.h>
1450 #endif /* PIOS_INCLUDE_COM */
1452 #if defined(PIOS_INCLUDE_I2C)
1454 #include <pios_i2c_priv.h>
1457 * I2C Adapters
1459 void PIOS_I2C_mag_pressure_adapter_ev_irq_handler(void);
1460 void PIOS_I2C_mag_pressureadapter_er_irq_handler(void);
1461 void I2C1_EV_IRQHandler()
1462 __attribute__((alias("PIOS_I2C_mag_pressure_adapter_ev_irq_handler")));
1463 void I2C1_ER_IRQHandler()
1464 __attribute__((alias("PIOS_I2C_mag_pressure_adapter_er_irq_handler")));
1466 static const struct pios_i2c_adapter_cfg pios_i2c_mag_pressure_adapter_cfg = {
1467 .regs = I2C1,
1468 .remapSCL = GPIO_AF_I2C1,
1469 .remapSDA = GPIO_AF_I2C1,
1470 .init = {
1471 .I2C_Mode = I2C_Mode_I2C,
1472 .I2C_OwnAddress1 = 0,
1473 .I2C_Ack = I2C_Ack_Enable,
1474 .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
1475 .I2C_DutyCycle = I2C_DutyCycle_2,
1476 .I2C_ClockSpeed = 400000, /* bits/s */
1478 .transfer_timeout_ms = 50,
1479 .scl = {
1480 .gpio = GPIOB,
1481 .init = {
1482 .GPIO_Pin = GPIO_Pin_8,
1483 .GPIO_Mode = GPIO_Mode_AF,
1484 .GPIO_Speed = GPIO_Speed_50MHz,
1485 .GPIO_OType = GPIO_OType_OD,
1486 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1489 .sda = {
1490 .gpio = GPIOB,
1491 .init = {
1492 .GPIO_Pin = GPIO_Pin_9,
1493 .GPIO_Mode = GPIO_Mode_AF,
1494 .GPIO_Speed = GPIO_Speed_50MHz,
1495 .GPIO_OType = GPIO_OType_OD,
1496 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1499 .event = {
1500 .flags = 0, /* FIXME: check this */
1501 .init = {
1502 .NVIC_IRQChannel = I2C1_EV_IRQn,
1503 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1504 .NVIC_IRQChannelSubPriority = 0,
1505 .NVIC_IRQChannelCmd = ENABLE,
1508 .error = {
1509 .flags = 0, /* FIXME: check this */
1510 .init = {
1511 .NVIC_IRQChannel = I2C1_ER_IRQn,
1512 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1513 .NVIC_IRQChannelSubPriority = 0,
1514 .NVIC_IRQChannelCmd = ENABLE,
1519 uint32_t pios_i2c_mag_pressure_adapter_id;
1520 void PIOS_I2C_mag_pressure_adapter_ev_irq_handler(void)
1522 /* Call into the generic code to handle the IRQ for this specific device */
1523 PIOS_I2C_EV_IRQ_Handler(pios_i2c_mag_pressure_adapter_id);
1526 void PIOS_I2C_mag_pressure_adapter_er_irq_handler(void)
1528 /* Call into the generic code to handle the IRQ for this specific device */
1529 PIOS_I2C_ER_IRQ_Handler(pios_i2c_mag_pressure_adapter_id);
1533 void PIOS_I2C_flexiport_adapter_ev_irq_handler(void);
1534 void PIOS_I2C_flexiport_adapter_er_irq_handler(void);
1535 void I2C2_EV_IRQHandler() __attribute__((alias("PIOS_I2C_flexiport_adapter_ev_irq_handler")));
1536 void I2C2_ER_IRQHandler() __attribute__((alias("PIOS_I2C_flexiport_adapter_er_irq_handler")));
1538 static const struct pios_i2c_adapter_cfg pios_i2c_flexiport_adapter_cfg = {
1539 .regs = I2C2,
1540 .remapSCL = GPIO_AF_I2C2,
1541 .remapSDA = GPIO_AF_I2C2,
1542 .init = {
1543 .I2C_Mode = I2C_Mode_I2C,
1544 .I2C_OwnAddress1 = 0,
1545 .I2C_Ack = I2C_Ack_Enable,
1546 .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
1547 .I2C_DutyCycle = I2C_DutyCycle_2,
1548 .I2C_ClockSpeed = 400000, /* bits/s */
1550 .transfer_timeout_ms = 50,
1551 .scl = {
1552 .gpio = GPIOB,
1553 .init = {
1554 .GPIO_Pin = GPIO_Pin_10,
1555 .GPIO_Mode = GPIO_Mode_AF,
1556 .GPIO_Speed = GPIO_Speed_50MHz,
1557 .GPIO_OType = GPIO_OType_OD,
1558 .GPIO_PuPd = GPIO_PuPd_UP,
1561 .sda = {
1562 .gpio = GPIOB,
1563 .init = {
1564 .GPIO_Pin = GPIO_Pin_11,
1565 .GPIO_Mode = GPIO_Mode_AF,
1566 .GPIO_Speed = GPIO_Speed_50MHz,
1567 .GPIO_OType = GPIO_OType_OD,
1568 .GPIO_PuPd = GPIO_PuPd_UP,
1571 .event = {
1572 .flags = 0, /* FIXME: check this */
1573 .init = {
1574 .NVIC_IRQChannel = I2C2_EV_IRQn,
1575 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1576 .NVIC_IRQChannelSubPriority = 0,
1577 .NVIC_IRQChannelCmd = ENABLE,
1580 .error = {
1581 .flags = 0, /* FIXME: check this */
1582 .init = {
1583 .NVIC_IRQChannel = I2C2_ER_IRQn,
1584 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1585 .NVIC_IRQChannelSubPriority = 0,
1586 .NVIC_IRQChannelCmd = ENABLE,
1591 uint32_t pios_i2c_flexiport_adapter_id;
1592 void PIOS_I2C_flexiport_adapter_ev_irq_handler(void)
1594 /* Call into the generic code to handle the IRQ for this specific device */
1595 PIOS_I2C_EV_IRQ_Handler(pios_i2c_flexiport_adapter_id);
1598 void PIOS_I2C_flexiport_adapter_er_irq_handler(void)
1600 /* Call into the generic code to handle the IRQ for this specific device */
1601 PIOS_I2C_ER_IRQ_Handler(pios_i2c_flexiport_adapter_id);
1605 void PIOS_I2C_pressure_adapter_ev_irq_handler(void);
1606 void PIOS_I2C_pressure_adapter_er_irq_handler(void);
1608 #endif /* PIOS_INCLUDE_I2C */
1610 #if defined(PIOS_INCLUDE_RTC)
1612 * Realtime Clock (RTC)
1614 #include <pios_rtc_priv.h>
1616 void PIOS_RTC_IRQ_Handler(void);
1617 void RTC_WKUP_IRQHandler() __attribute__((alias("PIOS_RTC_IRQ_Handler")));
1618 static const struct pios_rtc_cfg pios_rtc_main_cfg = {
1619 .clksrc = RCC_RTCCLKSource_HSE_Div8, // Divide 8 Mhz crystal down to 1
1620 // For some reason it's acting like crystal is 16 Mhz. This clock is then divided
1621 // by another 16 to give a nominal 62.5 khz clock
1622 .prescaler = 100, // Every 100 cycles gives 625 Hz
1623 .irq = {
1624 .init = {
1625 .NVIC_IRQChannel = RTC_WKUP_IRQn,
1626 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1627 .NVIC_IRQChannelSubPriority = 0,
1628 .NVIC_IRQChannelCmd = ENABLE,
1633 void PIOS_RTC_IRQ_Handler(void)
1635 PIOS_RTC_irq_handler();
1638 #endif /* if defined(PIOS_INCLUDE_RTC) */
1640 #include "pios_tim_priv.h"
1642 static const TIM_TimeBaseInitTypeDef tim_3_5_time_base = {
1643 .TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
1644 .TIM_ClockDivision = TIM_CKD_DIV1,
1645 .TIM_CounterMode = TIM_CounterMode_Up,
1646 .TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
1647 .TIM_RepetitionCounter = 0x0000,
1649 static const TIM_TimeBaseInitTypeDef tim_9_10_11_time_base = {
1650 .TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
1651 .TIM_ClockDivision = TIM_CKD_DIV1,
1652 .TIM_CounterMode = TIM_CounterMode_Up,
1653 .TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
1654 .TIM_RepetitionCounter = 0x0000,
1657 static const struct pios_tim_clock_cfg tim_3_cfg = {
1658 .timer = TIM3,
1659 .time_base_init = &tim_3_5_time_base,
1660 .irq = {
1661 .init = {
1662 .NVIC_IRQChannel = TIM3_IRQn,
1663 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1664 .NVIC_IRQChannelSubPriority = 0,
1665 .NVIC_IRQChannelCmd = ENABLE,
1670 static const struct pios_tim_clock_cfg tim_5_cfg = {
1671 .timer = TIM5,
1672 .time_base_init = &tim_3_5_time_base,
1673 .irq = {
1674 .init = {
1675 .NVIC_IRQChannel = TIM5_IRQn,
1676 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1677 .NVIC_IRQChannelSubPriority = 0,
1678 .NVIC_IRQChannelCmd = ENABLE,
1683 static const struct pios_tim_clock_cfg tim_9_cfg = {
1684 .timer = TIM9,
1685 .time_base_init = &tim_9_10_11_time_base,
1686 .irq = {
1687 .init = {
1688 .NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn,
1689 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1690 .NVIC_IRQChannelSubPriority = 0,
1691 .NVIC_IRQChannelCmd = ENABLE,
1696 static const struct pios_tim_clock_cfg tim_10_cfg = {
1697 .timer = TIM10,
1698 .time_base_init = &tim_9_10_11_time_base,
1699 .irq = {
1700 .init = {
1701 .NVIC_IRQChannel = TIM1_UP_TIM10_IRQn,
1702 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1703 .NVIC_IRQChannelSubPriority = 0,
1704 .NVIC_IRQChannelCmd = ENABLE,
1709 static const struct pios_tim_clock_cfg tim_11_cfg = {
1710 .timer = TIM11,
1711 .time_base_init = &tim_9_10_11_time_base,
1712 .irq = {
1713 .init = {
1714 .NVIC_IRQChannel = TIM1_TRG_COM_TIM11_IRQn,
1715 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1716 .NVIC_IRQChannelSubPriority = 0,
1717 .NVIC_IRQChannelCmd = ENABLE,
1722 // Set up timers that only have inputs on APB1
1723 // TIM2,3,4,5,6,7,12,13,14
1724 static const TIM_TimeBaseInitTypeDef tim_apb1_time_base = {
1725 .TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
1726 .TIM_ClockDivision = TIM_CKD_DIV1,
1727 .TIM_CounterMode = TIM_CounterMode_Up,
1728 .TIM_Period = 0xFFFF,
1729 .TIM_RepetitionCounter = 0x0000,
1733 // Set up timers that only have inputs on APB2
1734 // TIM1,8,9,10,11
1735 static const TIM_TimeBaseInitTypeDef tim_apb2_time_base = {
1736 .TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
1737 .TIM_ClockDivision = TIM_CKD_DIV1,
1738 .TIM_CounterMode = TIM_CounterMode_Up,
1739 .TIM_Period = 0xFFFF,
1740 .TIM_RepetitionCounter = 0x0000,
1743 static const struct pios_tim_clock_cfg tim_1_cfg = {
1744 .timer = TIM1,
1745 .time_base_init = &tim_apb2_time_base,
1746 .irq = {
1747 .init = {
1748 .NVIC_IRQChannel = TIM1_CC_IRQn,
1749 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1750 .NVIC_IRQChannelSubPriority = 0,
1751 .NVIC_IRQChannelCmd = ENABLE,
1756 static const struct pios_tim_clock_cfg tim_4_cfg = {
1757 .timer = TIM4,
1758 .time_base_init = &tim_apb1_time_base,
1759 .irq = {
1760 .init = {
1761 .NVIC_IRQChannel = TIM4_IRQn,
1762 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1763 .NVIC_IRQChannelSubPriority = 0,
1764 .NVIC_IRQChannelCmd = ENABLE,
1768 static const struct pios_tim_clock_cfg tim_8_cfg = {
1769 .timer = TIM8,
1770 .time_base_init = &tim_apb2_time_base,
1771 .irq = {
1772 .init = {
1773 .NVIC_IRQChannel = TIM8_CC_IRQn,
1774 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1775 .NVIC_IRQChannelSubPriority = 0,
1776 .NVIC_IRQChannelCmd = ENABLE,
1781 static const struct pios_tim_clock_cfg tim_12_cfg = {
1782 .timer = TIM12,
1783 .time_base_init = &tim_apb1_time_base,
1784 .irq = {
1785 .init = {
1786 .NVIC_IRQChannel = TIM8_BRK_TIM12_IRQn,
1787 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1788 .NVIC_IRQChannelSubPriority = 0,
1789 .NVIC_IRQChannelCmd = ENABLE,
1796 * Pios servo configuration structures
1797 * Using TIM3, TIM9, TIM2, TIM5
1799 #include <pios_servo_priv.h>
1800 static const struct pios_tim_channel pios_tim_servoport_all_pins[] = {
1802 .timer = TIM3,
1803 .timer_chan = TIM_Channel_3,
1804 .pin = {
1805 .gpio = GPIOB,
1806 .init = {
1807 .GPIO_Pin = GPIO_Pin_0,
1808 .GPIO_Speed = GPIO_Speed_2MHz,
1809 .GPIO_Mode = GPIO_Mode_AF,
1810 .GPIO_OType = GPIO_OType_PP,
1811 .GPIO_PuPd = GPIO_PuPd_UP
1813 .pin_source = GPIO_PinSource0,
1815 .remap = GPIO_AF_TIM3,
1818 .timer = TIM3,
1819 .timer_chan = TIM_Channel_4,
1820 .pin = {
1821 .gpio = GPIOB,
1822 .init = {
1823 .GPIO_Pin = GPIO_Pin_1,
1824 .GPIO_Speed = GPIO_Speed_2MHz,
1825 .GPIO_Mode = GPIO_Mode_AF,
1826 .GPIO_OType = GPIO_OType_PP,
1827 .GPIO_PuPd = GPIO_PuPd_UP
1829 .pin_source = GPIO_PinSource1,
1831 .remap = GPIO_AF_TIM3,
1834 .timer = TIM9,
1835 .timer_chan = TIM_Channel_2,
1836 .pin = {
1837 .gpio = GPIOA,
1838 .init = {
1839 .GPIO_Pin = GPIO_Pin_3,
1840 .GPIO_Speed = GPIO_Speed_2MHz,
1841 .GPIO_Mode = GPIO_Mode_AF,
1842 .GPIO_OType = GPIO_OType_PP,
1843 .GPIO_PuPd = GPIO_PuPd_UP
1845 .pin_source = GPIO_PinSource3,
1847 .remap = GPIO_AF_TIM9,
1850 .timer = TIM2,
1851 .timer_chan = TIM_Channel_3,
1852 .pin = {
1853 .gpio = GPIOA,
1854 .init = {
1855 .GPIO_Pin = GPIO_Pin_2,
1856 .GPIO_Speed = GPIO_Speed_2MHz,
1857 .GPIO_Mode = GPIO_Mode_AF,
1858 .GPIO_OType = GPIO_OType_PP,
1859 .GPIO_PuPd = GPIO_PuPd_UP
1861 .pin_source = GPIO_PinSource2,
1863 .remap = GPIO_AF_TIM2,
1866 .timer = TIM5,
1867 .timer_chan = TIM_Channel_2,
1868 .pin = {
1869 .gpio = GPIOA,
1870 .init = {
1871 .GPIO_Pin = GPIO_Pin_1,
1872 .GPIO_Speed = GPIO_Speed_2MHz,
1873 .GPIO_Mode = GPIO_Mode_AF,
1874 .GPIO_OType = GPIO_OType_PP,
1875 .GPIO_PuPd = GPIO_PuPd_UP
1877 .pin_source = GPIO_PinSource1,
1879 .remap = GPIO_AF_TIM5,
1882 .timer = TIM5,
1883 .timer_chan = TIM_Channel_1,
1884 .pin = {
1885 .gpio = GPIOA,
1886 .init = {
1887 .GPIO_Pin = GPIO_Pin_0,
1888 .GPIO_Speed = GPIO_Speed_2MHz,
1889 .GPIO_Mode = GPIO_Mode_AF,
1890 .GPIO_OType = GPIO_OType_PP,
1891 .GPIO_PuPd = GPIO_PuPd_UP
1893 .pin_source = GPIO_PinSource0,
1895 .remap = GPIO_AF_TIM5,
1897 // PWM pins on FlexiIO(receiver) port
1899 // * 6: PB15 = SPI2 MOSI, TIM12 CH2
1901 .timer = TIM12,
1902 .timer_chan = TIM_Channel_2,
1903 .pin = {
1904 .gpio = GPIOB,
1905 .init = {
1906 .GPIO_Pin = GPIO_Pin_15,
1907 .GPIO_Speed = GPIO_Speed_2MHz,
1908 .GPIO_Mode = GPIO_Mode_AF,
1909 .GPIO_OType = GPIO_OType_PP,
1910 .GPIO_PuPd = GPIO_PuPd_UP
1912 .pin_source = GPIO_PinSource15,
1914 .remap = GPIO_AF_TIM12,
1917 // * 7: PC6 = TIM8 CH1, USART6 TX
1918 .timer = TIM8,
1919 .timer_chan = TIM_Channel_1,
1920 .pin = {
1921 .gpio = GPIOC,
1922 .init = {
1923 .GPIO_Pin = GPIO_Pin_6,
1924 .GPIO_Speed = GPIO_Speed_2MHz,
1925 .GPIO_Mode = GPIO_Mode_AF,
1926 .GPIO_OType = GPIO_OType_PP,
1927 .GPIO_PuPd = GPIO_PuPd_UP
1929 .pin_source = GPIO_PinSource6,
1931 .remap = GPIO_AF_TIM8,
1935 // * 8: PC7 = TIM8 CH2, USART6 RX
1936 .timer = TIM8,
1937 .timer_chan = TIM_Channel_2,
1938 .pin = {
1939 .gpio = GPIOC,
1940 .init = {
1941 .GPIO_Pin = GPIO_Pin_7,
1942 .GPIO_Speed = GPIO_Speed_2MHz,
1943 .GPIO_Mode = GPIO_Mode_AF,
1944 .GPIO_OType = GPIO_OType_PP,
1945 .GPIO_PuPd = GPIO_PuPd_UP
1947 .pin_source = GPIO_PinSource7,
1949 .remap = GPIO_AF_TIM8,
1953 // * 9: PC8 = TIM8 CH3
1954 .timer = TIM8,
1955 .timer_chan = TIM_Channel_3,
1956 .pin = {
1957 .gpio = GPIOC,
1958 .init = {
1959 .GPIO_Pin = GPIO_Pin_8,
1960 .GPIO_Speed = GPIO_Speed_2MHz,
1961 .GPIO_Mode = GPIO_Mode_AF,
1962 .GPIO_OType = GPIO_OType_PP,
1963 .GPIO_PuPd = GPIO_PuPd_UP
1965 .pin_source = GPIO_PinSource8,
1967 .remap = GPIO_AF_TIM8,
1971 // * 10: PC9 = TIM8 CH4
1972 .timer = TIM8,
1973 .timer_chan = TIM_Channel_4,
1974 .pin = {
1975 .gpio = GPIOC,
1976 .init = {
1977 .GPIO_Pin = GPIO_Pin_9,
1978 .GPIO_Speed = GPIO_Speed_2MHz,
1979 .GPIO_Mode = GPIO_Mode_AF,
1980 .GPIO_OType = GPIO_OType_PP,
1981 .GPIO_PuPd = GPIO_PuPd_UP
1983 .pin_source = GPIO_PinSource9,
1985 .remap = GPIO_AF_TIM8,
1989 // * 5: PB14 = SPI2 MISO, TIM12 CH1, USART3 RTS
1990 .timer = TIM12,
1991 .timer_chan = TIM_Channel_1,
1992 .pin = {
1993 .gpio = GPIOB,
1994 .init = {
1995 .GPIO_Pin = GPIO_Pin_14,
1996 .GPIO_Speed = GPIO_Speed_2MHz,
1997 .GPIO_Mode = GPIO_Mode_AF,
1998 .GPIO_OType = GPIO_OType_PP,
1999 .GPIO_PuPd = GPIO_PuPd_UP
2001 .pin_source = GPIO_PinSource14,
2003 .remap = GPIO_AF_TIM12,
2006 #define PIOS_SERVOPORT_ALL_PINS_PWMOUT 6
2007 #define PIOS_SERVOPORT_ALL_PINS_PWMOUT_IN_PPM 11
2008 #define PIOS_SERVOPORT_ALL_PINS_PWMOUT_IN 12
2010 const struct pios_servo_cfg pios_servo_cfg_out = {
2011 .tim_oc_init = {
2012 .TIM_OCMode = TIM_OCMode_PWM1,
2013 .TIM_OutputState = TIM_OutputState_Enable,
2014 .TIM_OutputNState = TIM_OutputNState_Disable,
2015 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
2016 .TIM_OCPolarity = TIM_OCPolarity_High,
2017 .TIM_OCNPolarity = TIM_OCPolarity_High,
2018 .TIM_OCIdleState = TIM_OCIdleState_Reset,
2019 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
2021 .channels = pios_tim_servoport_all_pins,
2022 .num_channels = PIOS_SERVOPORT_ALL_PINS_PWMOUT,
2024 // All servo outputs, servo input ch1 ppm, ch2-6 outputs
2025 const struct pios_servo_cfg pios_servo_cfg_out_in_ppm = {
2026 .tim_oc_init = {
2027 .TIM_OCMode = TIM_OCMode_PWM1,
2028 .TIM_OutputState = TIM_OutputState_Enable,
2029 .TIM_OutputNState = TIM_OutputNState_Disable,
2030 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
2031 .TIM_OCPolarity = TIM_OCPolarity_High,
2032 .TIM_OCNPolarity = TIM_OCPolarity_High,
2033 .TIM_OCIdleState = TIM_OCIdleState_Reset,
2034 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
2036 .channels = pios_tim_servoport_all_pins,
2037 .num_channels = PIOS_SERVOPORT_ALL_PINS_PWMOUT_IN_PPM,
2039 // All servo outputs, servo inputs ch1-6 Outputs
2040 const struct pios_servo_cfg pios_servo_cfg_out_in = {
2041 .tim_oc_init = {
2042 .TIM_OCMode = TIM_OCMode_PWM1,
2043 .TIM_OutputState = TIM_OutputState_Enable,
2044 .TIM_OutputNState = TIM_OutputNState_Disable,
2045 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
2046 .TIM_OCPolarity = TIM_OCPolarity_High,
2047 .TIM_OCNPolarity = TIM_OCPolarity_High,
2048 .TIM_OCIdleState = TIM_OCIdleState_Reset,
2049 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
2051 .channels = pios_tim_servoport_all_pins,
2052 .num_channels = PIOS_SERVOPORT_ALL_PINS_PWMOUT_IN,
2057 * PWM Inputs
2058 * TIM1, TIM8, TIM12
2060 #if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM)
2061 #include <pios_pwm_priv.h>
2062 static const struct pios_tim_channel pios_tim_rcvrport_all_channels[] = {
2064 .timer = TIM12,
2065 .timer_chan = TIM_Channel_1,
2066 .pin = {
2067 .gpio = GPIOB,
2068 .init = {
2069 .GPIO_Pin = GPIO_Pin_14,
2070 .GPIO_Speed = GPIO_Speed_2MHz,
2071 .GPIO_Mode = GPIO_Mode_AF,
2072 .GPIO_OType = GPIO_OType_PP,
2073 .GPIO_PuPd = GPIO_PuPd_UP
2075 .pin_source = GPIO_PinSource14,
2077 .remap = GPIO_AF_TIM12,
2080 .timer = TIM12,
2081 .timer_chan = TIM_Channel_2,
2082 .pin = {
2083 .gpio = GPIOB,
2084 .init = {
2085 .GPIO_Pin = GPIO_Pin_15,
2086 .GPIO_Speed = GPIO_Speed_2MHz,
2087 .GPIO_Mode = GPIO_Mode_AF,
2088 .GPIO_OType = GPIO_OType_PP,
2089 .GPIO_PuPd = GPIO_PuPd_UP
2091 .pin_source = GPIO_PinSource15,
2093 .remap = GPIO_AF_TIM12,
2096 .timer = TIM8,
2097 .timer_chan = TIM_Channel_1,
2098 .pin = {
2099 .gpio = GPIOC,
2100 .init = {
2101 .GPIO_Pin = GPIO_Pin_6,
2102 .GPIO_Speed = GPIO_Speed_2MHz,
2103 .GPIO_Mode = GPIO_Mode_AF,
2104 .GPIO_OType = GPIO_OType_PP,
2105 .GPIO_PuPd = GPIO_PuPd_UP
2107 .pin_source = GPIO_PinSource6,
2109 .remap = GPIO_AF_TIM8,
2112 .timer = TIM8,
2113 .timer_chan = TIM_Channel_2,
2114 .pin = {
2115 .gpio = GPIOC,
2116 .init = {
2117 .GPIO_Pin = GPIO_Pin_7,
2118 .GPIO_Speed = GPIO_Speed_2MHz,
2119 .GPIO_Mode = GPIO_Mode_AF,
2120 .GPIO_OType = GPIO_OType_PP,
2121 .GPIO_PuPd = GPIO_PuPd_UP
2123 .pin_source = GPIO_PinSource7,
2125 .remap = GPIO_AF_TIM8,
2128 .timer = TIM8,
2129 .timer_chan = TIM_Channel_3,
2130 .pin = {
2131 .gpio = GPIOC,
2132 .init = {
2133 .GPIO_Pin = GPIO_Pin_8,
2134 .GPIO_Speed = GPIO_Speed_2MHz,
2135 .GPIO_Mode = GPIO_Mode_AF,
2136 .GPIO_OType = GPIO_OType_PP,
2137 .GPIO_PuPd = GPIO_PuPd_UP
2139 .pin_source = GPIO_PinSource8,
2141 .remap = GPIO_AF_TIM8,
2144 .timer = TIM8,
2145 .timer_chan = TIM_Channel_4,
2146 .pin = {
2147 .gpio = GPIOC,
2148 .init = {
2149 .GPIO_Pin = GPIO_Pin_9,
2150 .GPIO_Speed = GPIO_Speed_2MHz,
2151 .GPIO_Mode = GPIO_Mode_AF,
2152 .GPIO_OType = GPIO_OType_PP,
2153 .GPIO_PuPd = GPIO_PuPd_UP
2155 .pin_source = GPIO_PinSource9,
2157 .remap = GPIO_AF_TIM8,
2161 const struct pios_pwm_cfg pios_pwm_cfg = {
2162 .tim_ic_init = {
2163 .TIM_ICPolarity = TIM_ICPolarity_Rising,
2164 .TIM_ICSelection = TIM_ICSelection_DirectTI,
2165 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
2166 .TIM_ICFilter = 0x0,
2168 .channels = pios_tim_rcvrport_all_channels,
2169 .num_channels = NELEMENTS(pios_tim_rcvrport_all_channels),
2171 // this configures outputs 2-6 as pwm inputs
2172 const struct pios_pwm_cfg pios_pwm_ppm_cfg = {
2173 .tim_ic_init = {
2174 .TIM_ICPolarity = TIM_ICPolarity_Rising,
2175 .TIM_ICSelection = TIM_ICSelection_DirectTI,
2176 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
2177 .TIM_ICFilter = 0x0,
2179 .channels = &pios_tim_rcvrport_all_channels[1],
2180 .num_channels = NELEMENTS(pios_tim_rcvrport_all_channels) - 1,
2183 #endif /* if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM) */
2186 * PPM Input
2188 #if defined(PIOS_INCLUDE_PPM)
2189 #include <pios_ppm_priv.h>
2190 static const struct pios_ppm_cfg pios_ppm_cfg = {
2191 .tim_ic_init = {
2192 .TIM_ICPolarity = TIM_ICPolarity_Rising,
2193 .TIM_ICSelection = TIM_ICSelection_DirectTI,
2194 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
2195 .TIM_ICFilter = 0x0,
2196 .TIM_Channel = TIM_Channel_1,
2198 /* Use only the first channel for ppm */
2199 .channels = &pios_tim_rcvrport_all_channels[0],
2200 .num_channels = 1,
2203 #endif // PPM
2205 #if defined(PIOS_INCLUDE_GCSRCVR)
2206 #include "pios_gcsrcvr_priv.h"
2207 #endif /* PIOS_INCLUDE_GCSRCVR */
2209 #if defined(PIOS_INCLUDE_RCVR)
2210 #include "pios_rcvr_priv.h"
2211 #endif /* PIOS_INCLUDE_RCVR */
2213 #if defined(PIOS_INCLUDE_USB)
2214 #include "pios_usb_priv.h"
2216 static const struct pios_usb_cfg pios_usb_main_rm1_cfg = {
2217 .irq = {
2218 .init = {
2219 .NVIC_IRQChannel = OTG_FS_IRQn,
2220 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
2221 .NVIC_IRQChannelSubPriority = 0, // PriorityGroup=4
2222 .NVIC_IRQChannelCmd = ENABLE,
2225 .vsense = {
2226 .gpio = GPIOB,
2227 .init = {
2228 .GPIO_Pin = GPIO_Pin_13,
2229 .GPIO_Speed = GPIO_Speed_25MHz,
2230 .GPIO_Mode = GPIO_Mode_IN,
2231 .GPIO_OType = GPIO_OType_OD,
2234 .vsense_active_low = false
2237 static const struct pios_usb_cfg pios_usb_main_rm2_cfg = {
2238 .irq = {
2239 .init = {
2240 .NVIC_IRQChannel = OTG_FS_IRQn,
2241 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
2242 .NVIC_IRQChannelSubPriority = 0, // PriorityGroup=4
2243 .NVIC_IRQChannelCmd = ENABLE,
2246 .vsense = {
2247 .gpio = GPIOC,
2248 .init = {
2249 .GPIO_Pin = GPIO_Pin_5,
2250 .GPIO_Speed = GPIO_Speed_25MHz,
2251 .GPIO_Mode = GPIO_Mode_IN,
2252 .GPIO_OType = GPIO_OType_OD,
2255 .vsense_active_low = false
2258 const struct pios_usb_cfg *PIOS_BOARD_HW_DEFS_GetUsbCfg(uint32_t board_revision)
2260 switch (board_revision) {
2261 case 2:
2262 return &pios_usb_main_rm1_cfg;
2264 break;
2265 case 3:
2266 return &pios_usb_main_rm2_cfg;
2268 break;
2269 default:
2270 PIOS_DEBUG_Assert(0);
2272 return NULL;
2275 #include "pios_usb_board_data_priv.h"
2276 #include "pios_usb_desc_hid_cdc_priv.h"
2277 #include "pios_usb_desc_hid_only_priv.h"
2278 #include "pios_usbhook.h"
2280 #endif /* PIOS_INCLUDE_USB */
2282 #if defined(PIOS_INCLUDE_COM_MSG)
2284 #include <pios_com_msg_priv.h>
2286 #endif /* PIOS_INCLUDE_COM_MSG */
2288 #if defined(PIOS_INCLUDE_USB_HID) && !defined(PIOS_INCLUDE_USB_CDC)
2289 #include <pios_usb_hid_priv.h>
2291 const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
2292 .data_if = 0,
2293 .data_rx_ep = 1,
2294 .data_tx_ep = 1,
2296 #endif /* PIOS_INCLUDE_USB_HID && !PIOS_INCLUDE_USB_CDC */
2298 #if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_USB_CDC)
2299 #include <pios_usb_cdc_priv.h>
2301 const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
2302 .ctrl_if = 0,
2303 .ctrl_tx_ep = 2,
2305 .data_if = 1,
2306 .data_rx_ep = 3,
2307 .data_tx_ep = 3,
2310 #include <pios_usb_hid_priv.h>
2312 const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
2313 .data_if = 2,
2314 .data_rx_ep = 1,
2315 .data_tx_ep = 1,
2317 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_USB_CDC */
2319 #ifdef PIOS_INCLUDE_WS2811
2320 #include <pios_ws2811_cfg.h>
2321 #include <hwsettings.h>
2322 #define PIOS_WS2811_TIM_DIVIDER (PIOS_PERIPHERAL_APB2_CLOCK / (800000 * PIOS_WS2811_TIM_PERIOD))
2324 void DMA2_Stream1_IRQHandler(void) __attribute__((alias("PIOS_WS2811_irq_handler")));
2325 // list of pin configurable as ws281x outputs.
2326 // this will not clash with PWM in or servo output as
2327 // pins will be reconfigured as _OUT so the alternate function is disabled.
2328 const struct pios_ws2811_pin_cfg pios_ws2811_pin_cfg[] = {
2329 [HWSETTINGS_WS2811LED_OUT_SERVOOUT1] = {
2330 .gpio = GPIOB,
2331 .gpioInit = {
2332 .GPIO_Pin = GPIO_Pin_0,
2333 .GPIO_Speed = GPIO_Speed_25MHz,
2334 .GPIO_Mode = GPIO_Mode_OUT,
2335 .GPIO_OType = GPIO_OType_PP,
2338 [HWSETTINGS_WS2811LED_OUT_SERVOOUT2] = {
2339 .gpio = GPIOB,
2340 .gpioInit = {
2341 .GPIO_Pin = GPIO_Pin_1,
2342 .GPIO_Speed = GPIO_Speed_25MHz,
2343 .GPIO_Mode = GPIO_Mode_OUT,
2344 .GPIO_OType = GPIO_OType_PP,
2347 [HWSETTINGS_WS2811LED_OUT_SERVOOUT3] = {
2348 .gpio = GPIOA,
2349 .gpioInit = {
2350 .GPIO_Pin = GPIO_Pin_3,
2351 .GPIO_Speed = GPIO_Speed_25MHz,
2352 .GPIO_Mode = GPIO_Mode_OUT,
2353 .GPIO_OType = GPIO_OType_PP,
2356 [HWSETTINGS_WS2811LED_OUT_SERVOOUT4] = {
2357 .gpio = GPIOA,
2358 .gpioInit = {
2359 .GPIO_Pin = GPIO_Pin_2,
2360 .GPIO_Speed = GPIO_Speed_25MHz,
2361 .GPIO_Mode = GPIO_Mode_OUT,
2362 .GPIO_OType = GPIO_OType_PP,
2365 [HWSETTINGS_WS2811LED_OUT_SERVOOUT5] = {
2366 .gpio = GPIOA,
2367 .gpioInit = {
2368 .GPIO_Pin = GPIO_Pin_1,
2369 .GPIO_Speed = GPIO_Speed_25MHz,
2370 .GPIO_Mode = GPIO_Mode_OUT,
2371 .GPIO_OType = GPIO_OType_PP,
2374 [HWSETTINGS_WS2811LED_OUT_SERVOOUT6] = {
2375 .gpio = GPIOA,
2376 .gpioInit = {
2377 .GPIO_Pin = GPIO_Pin_0,
2378 .GPIO_Speed = GPIO_Speed_25MHz,
2379 .GPIO_Mode = GPIO_Mode_OUT,
2380 .GPIO_OType = GPIO_OType_PP,
2383 [HWSETTINGS_WS2811LED_OUT_FLEXIIOPIN3] = {
2384 .gpio = GPIOB,
2385 .gpioInit = {
2386 .GPIO_Pin = GPIO_Pin_12,
2387 .GPIO_Speed = GPIO_Speed_25MHz,
2388 .GPIO_Mode = GPIO_Mode_OUT,
2389 .GPIO_OType = GPIO_OType_PP,
2392 [HWSETTINGS_WS2811LED_OUT_FLEXIIOPIN4] = {
2393 .gpio = GPIOB,
2394 .gpioInit = {
2395 .GPIO_Pin = GPIO_Pin_13,
2396 .GPIO_Speed = GPIO_Speed_25MHz,
2397 .GPIO_Mode = GPIO_Mode_OUT,
2398 .GPIO_OType = GPIO_OType_PP,
2403 const struct pios_ws2811_cfg pios_ws2811_cfg = {
2404 .timer = TIM1,
2405 .timerInit = {
2406 .TIM_Prescaler = PIOS_WS2811_TIM_DIVIDER - 1,
2407 .TIM_ClockDivision = TIM_CKD_DIV1,
2408 .TIM_CounterMode = TIM_CounterMode_Up,
2409 // period (1.25 uS per period
2410 .TIM_Period = PIOS_WS2811_TIM_PERIOD,
2411 .TIM_RepetitionCounter = 0x0000,
2414 .timerCh1 = 1,
2415 .streamCh1 = DMA2_Stream1,
2416 .timerCh2 = 3,
2417 .streamCh2 = DMA2_Stream6,
2418 .streamUpdate = DMA2_Stream5,
2420 // DMA streamCh1, triggered by timerCh1 pwm signal.
2421 // if FrameBuffer indicates, reset output value early to indicate "0" bit to ws2812
2422 .dmaInitCh1 = PIOS_WS2811_DMA_CH1_CONFIG(DMA_Channel_6),
2423 .dmaItCh1 = DMA_IT_TEIF1 | DMA_IT_TCIF1,
2425 // DMA streamCh2, triggered by timerCh2 pwm signal.
2426 // Reset output value late to indicate "1" bit to ws2812.
2427 .dmaInitCh2 = PIOS_WS2811_DMA_CH2_CONFIG(DMA_Channel_6),
2428 .dmaItCh2 = DMA_IT_TEIF6 | DMA_IT_TCIF6,
2430 // DMA streamUpdate Triggered by timer update event
2431 // Outputs a high logic level at beginning of a cycle
2432 .dmaInitUpdate = PIOS_WS2811_DMA_UPDATE_CONFIG(DMA_Channel_6),
2433 .dmaItUpdate = DMA_IT_TEIF5 | DMA_IT_TCIF5,
2434 .dmaSource = TIM_DMA_CC1 | TIM_DMA_CC3 | TIM_DMA_Update,
2436 // DMAInitCh1 interrupt vector, used to block timer at end of framebuffer transfer
2437 .irq = {
2438 .flags = (DMA_IT_TCIF1),
2439 .init = {
2440 .NVIC_IRQChannel = DMA2_Stream1_IRQn,
2441 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
2442 .NVIC_IRQChannelSubPriority = 0,
2443 .NVIC_IRQChannelCmd = ENABLE,
2448 void PIOS_WS2811_irq_handler(void)
2450 PIOS_WS2811_DMA_irq_handler();
2452 #endif // PIOS_INCLUDE_WS2811