LP-500 HoTT Telemetry added device definitions
[librepilot.git] / flight / targets / boards / revoproto / board_hw_defs.c
blobbda92eb18cd7224c16e1bcbcc03c0e5208db3177
1 /**
2 ******************************************************************************
3 * @file board_hw_defs.c
4 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
5 * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012
6 * @addtogroup OpenPilotSystem OpenPilot System
7 * @{
8 * @addtogroup OpenPilotCore OpenPilot Core
9 * @{
10 * @brief Defines board specific static initializers for hardware for the Revolution board.
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #if defined(PIOS_INCLUDE_LED)
30 #include <pios_led_priv.h>
31 static const struct pios_gpio pios_leds[] = {
32 [PIOS_LED_HEARTBEAT] = {
33 .pin = {
34 .gpio = GPIOE,
35 .init = {
36 .GPIO_Pin = GPIO_Pin_2,
37 .GPIO_Speed = GPIO_Speed_50MHz,
38 .GPIO_Mode = GPIO_Mode_OUT,
39 .GPIO_OType = GPIO_OType_PP,
40 .GPIO_PuPd = GPIO_PuPd_UP
43 .active_low = true
45 [PIOS_LED_ALARM] = {
46 .pin = {
47 .gpio = GPIOE,
48 .init = {
49 .GPIO_Pin = GPIO_Pin_3,
50 .GPIO_Speed = GPIO_Speed_50MHz,
51 .GPIO_Mode = GPIO_Mode_OUT,
52 .GPIO_OType = GPIO_OType_PP,
53 .GPIO_PuPd = GPIO_PuPd_UP
56 .active_low = true
60 static const struct pios_gpio_cfg pios_led_cfg = {
61 .gpios = pios_leds,
62 .num_gpios = NELEMENTS(pios_leds),
65 const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision)
67 return &pios_led_cfg;
70 #endif /* PIOS_INCLUDE_LED */
72 #if defined(PIOS_INCLUDE_SPI)
73 #include <pios_spi_priv.h>
74 /* SPI1 Interface
75 * - Used for BMA180 accelerometer
77 void PIOS_SPI_accel_irq_handler(void);
78 void DMA2_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_accel_irq_handler")));
79 void DMA2_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_accel_irq_handler")));
80 static const struct pios_spi_cfg pios_spi_accel_cfg = {
81 .regs = SPI1,
82 .remap = GPIO_AF_SPI1,
83 .init = {
84 .SPI_Mode = SPI_Mode_Master,
85 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
86 .SPI_DataSize = SPI_DataSize_8b,
87 .SPI_NSS = SPI_NSS_Soft,
88 .SPI_FirstBit = SPI_FirstBit_MSB,
89 .SPI_CRCPolynomial = 7,
90 .SPI_CPOL = SPI_CPOL_High,
91 .SPI_CPHA = SPI_CPHA_2Edge,
92 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16,
94 .use_crc = false,
95 .dma = {
96 .irq = {
97 .flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
98 .init = {
99 .NVIC_IRQChannel = DMA2_Stream0_IRQn,
100 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
101 .NVIC_IRQChannelSubPriority = 0,
102 .NVIC_IRQChannelCmd = ENABLE,
106 .rx = {
107 .channel = DMA2_Stream0,
108 .init = {
109 .DMA_Channel = DMA_Channel_3,
110 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
111 .DMA_DIR = DMA_DIR_PeripheralToMemory,
112 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
113 .DMA_MemoryInc = DMA_MemoryInc_Enable,
114 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
115 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
116 .DMA_Mode = DMA_Mode_Normal,
117 .DMA_Priority = DMA_Priority_Medium,
118 .DMA_FIFOMode = DMA_FIFOMode_Disable,
119 /* .DMA_FIFOThreshold */
120 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
121 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
124 .tx = {
125 .channel = DMA2_Stream3,
126 .init = {
127 .DMA_Channel = DMA_Channel_3,
128 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
129 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
130 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
131 .DMA_MemoryInc = DMA_MemoryInc_Enable,
132 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
133 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
134 .DMA_Mode = DMA_Mode_Normal,
135 .DMA_Priority = DMA_Priority_High,
136 .DMA_FIFOMode = DMA_FIFOMode_Disable,
137 /* .DMA_FIFOThreshold */
138 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
139 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
143 .sclk = {
144 .gpio = GPIOA,
145 .init = {
146 .GPIO_Pin = GPIO_Pin_5,
147 .GPIO_Speed = GPIO_Speed_100MHz,
148 .GPIO_Mode = GPIO_Mode_AF,
149 .GPIO_OType = GPIO_OType_PP,
150 .GPIO_PuPd = GPIO_PuPd_UP
153 .miso = {
154 .gpio = GPIOA,
155 .init = {
156 .GPIO_Pin = GPIO_Pin_6,
157 .GPIO_Speed = GPIO_Speed_50MHz,
158 .GPIO_Mode = GPIO_Mode_AF,
159 .GPIO_OType = GPIO_OType_PP,
160 .GPIO_PuPd = GPIO_PuPd_UP
163 .mosi = {
164 .gpio = GPIOA,
165 .init = {
166 .GPIO_Pin = GPIO_Pin_7,
167 .GPIO_Speed = GPIO_Speed_50MHz,
168 .GPIO_Mode = GPIO_Mode_AF,
169 .GPIO_OType = GPIO_OType_PP,
170 .GPIO_PuPd = GPIO_PuPd_UP
173 .slave_count = 2,
174 .ssel = {
176 .gpio = GPIOA,
177 .init = {
178 .GPIO_Pin = GPIO_Pin_4,
179 .GPIO_Speed = GPIO_Speed_50MHz,
180 .GPIO_Mode = GPIO_Mode_OUT,
181 .GPIO_OType = GPIO_OType_PP,
182 .GPIO_PuPd = GPIO_PuPd_UP
186 .gpio = GPIOC,
187 .init = {
188 .GPIO_Pin = GPIO_Pin_5,
189 .GPIO_Speed = GPIO_Speed_50MHz,
190 .GPIO_Mode = GPIO_Mode_OUT,
191 .GPIO_OType = GPIO_OType_PP,
192 .GPIO_PuPd = GPIO_PuPd_UP
198 static uint32_t pios_spi_accel_id;
199 void PIOS_SPI_accel_irq_handler(void)
201 /* Call into the generic code to handle the IRQ for this specific device */
202 PIOS_SPI_IRQ_Handler(pios_spi_accel_id);
206 /* SPI2 Interface
207 * - Used for gyro communications
209 void PIOS_SPI_GYRO_irq_handler(void);
210 void DMA1_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
211 void DMA1_Stream4_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
212 static const struct pios_spi_cfg pios_spi_gyro_cfg = {
213 .regs = SPI2,
214 .remap = GPIO_AF_SPI2,
215 .init = {
216 .SPI_Mode = SPI_Mode_Master,
217 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
218 .SPI_DataSize = SPI_DataSize_8b,
219 .SPI_NSS = SPI_NSS_Soft,
220 .SPI_FirstBit = SPI_FirstBit_MSB,
221 .SPI_CRCPolynomial = 7,
222 .SPI_CPOL = SPI_CPOL_High,
223 .SPI_CPHA = SPI_CPHA_2Edge,
224 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8,
226 .use_crc = false,
227 .dma = {
228 .irq = {
229 // Note this is the stream ID that triggers interrupts (in this case RX)
230 .flags = (DMA_IT_TCIF3 | DMA_IT_TEIF3 | DMA_IT_HTIF3),
231 .init = {
232 .NVIC_IRQChannel = DMA1_Stream3_IRQn,
233 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
234 .NVIC_IRQChannelSubPriority = 0,
235 .NVIC_IRQChannelCmd = ENABLE,
239 .rx = {
240 .channel = DMA1_Stream3,
241 .init = {
242 .DMA_Channel = DMA_Channel_0,
243 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
244 .DMA_DIR = DMA_DIR_PeripheralToMemory,
245 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
246 .DMA_MemoryInc = DMA_MemoryInc_Enable,
247 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
248 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
249 .DMA_Mode = DMA_Mode_Normal,
250 .DMA_Priority = DMA_Priority_Medium,
251 // TODO: Enable FIFO
252 .DMA_FIFOMode = DMA_FIFOMode_Disable,
253 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
254 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
255 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
258 .tx = {
259 .channel = DMA1_Stream4,
260 .init = {
261 .DMA_Channel = DMA_Channel_0,
262 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->DR),
263 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
264 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
265 .DMA_MemoryInc = DMA_MemoryInc_Enable,
266 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
267 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
268 .DMA_Mode = DMA_Mode_Normal,
269 .DMA_Priority = DMA_Priority_Medium,
270 .DMA_FIFOMode = DMA_FIFOMode_Disable,
271 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
272 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
273 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
277 .sclk = {
278 .gpio = GPIOB,
279 .init = {
280 .GPIO_Pin = GPIO_Pin_13,
281 .GPIO_Speed = GPIO_Speed_100MHz,
282 .GPIO_Mode = GPIO_Mode_AF,
283 .GPIO_OType = GPIO_OType_PP,
284 .GPIO_PuPd = GPIO_PuPd_NOPULL
287 .miso = {
288 .gpio = GPIOB,
289 .init = {
290 .GPIO_Pin = GPIO_Pin_14,
291 .GPIO_Speed = GPIO_Speed_50MHz,
292 .GPIO_Mode = GPIO_Mode_AF,
293 .GPIO_OType = GPIO_OType_PP,
294 .GPIO_PuPd = GPIO_PuPd_NOPULL
297 .mosi = {
298 .gpio = GPIOB,
299 .init = {
300 .GPIO_Pin = GPIO_Pin_15,
301 .GPIO_Speed = GPIO_Speed_50MHz,
302 .GPIO_Mode = GPIO_Mode_AF,
303 .GPIO_OType = GPIO_OType_PP,
304 .GPIO_PuPd = GPIO_PuPd_NOPULL
307 .slave_count = 1,
308 .ssel = {
310 .gpio = GPIOB,
311 .init = {
312 .GPIO_Pin = GPIO_Pin_12,
313 .GPIO_Speed = GPIO_Speed_50MHz,
314 .GPIO_Mode = GPIO_Mode_OUT,
315 .GPIO_OType = GPIO_OType_PP,
316 .GPIO_PuPd = GPIO_PuPd_UP
322 uint32_t pios_spi_gyro_id;
323 void PIOS_SPI_gyro_irq_handler(void)
325 /* Call into the generic code to handle the IRQ for this specific device */
326 PIOS_SPI_IRQ_Handler(pios_spi_gyro_id);
330 #if !defined(PIOS_FLASH_ON_ACCEL)
331 /* SPI3 Interface
332 * - Used for flash communications
334 void PIOS_SPI_flash_irq_handler(void);
335 void DMA1_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_flash_irq_handler")));
336 void DMA1_Stream5_IRQHandler(void) __attribute__((alias("PIOS_SPI_flash_irq_handler")));
337 static const struct pios_spi_cfg pios_spi_flash_cfg = {
338 .regs = SPI3,
339 .remap = GPIO_AF_SPI3,
340 .init = {
341 .SPI_Mode = SPI_Mode_Master,
342 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
343 .SPI_DataSize = SPI_DataSize_8b,
344 .SPI_NSS = SPI_NSS_Soft,
345 .SPI_FirstBit = SPI_FirstBit_MSB,
346 .SPI_CRCPolynomial = 7,
347 .SPI_CPOL = SPI_CPOL_High,
348 .SPI_CPHA = SPI_CPHA_2Edge,
349 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
351 .use_crc = false,
352 .dma = {
353 .irq = {
354 // Note this is the stream ID that triggers interrupts (in this case RX)
355 .flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
356 .init = {
357 .NVIC_IRQChannel = DMA1_Stream0_IRQn,
358 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
359 .NVIC_IRQChannelSubPriority = 0,
360 .NVIC_IRQChannelCmd = ENABLE,
364 .rx = {
365 .channel = DMA1_Stream0,
366 .init = {
367 .DMA_Channel = DMA_Channel_0,
368 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
369 .DMA_DIR = DMA_DIR_PeripheralToMemory,
370 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
371 .DMA_MemoryInc = DMA_MemoryInc_Enable,
372 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
373 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
374 .DMA_Mode = DMA_Mode_Normal,
375 .DMA_Priority = DMA_Priority_Medium,
376 // TODO: Enable FIFO
377 .DMA_FIFOMode = DMA_FIFOMode_Disable,
378 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
379 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
380 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
383 .tx = {
384 .channel = DMA1_Stream5,
385 .init = {
386 .DMA_Channel = DMA_Channel_0,
387 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
388 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
389 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
390 .DMA_MemoryInc = DMA_MemoryInc_Enable,
391 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
392 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
393 .DMA_Mode = DMA_Mode_Normal,
394 .DMA_Priority = DMA_Priority_Medium,
395 .DMA_FIFOMode = DMA_FIFOMode_Disable,
396 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
397 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
398 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
402 .sclk = {
403 .gpio = GPIOC,
404 .init = {
405 .GPIO_Pin = GPIO_Pin_10,
406 .GPIO_Speed = GPIO_Speed_100MHz,
407 .GPIO_Mode = GPIO_Mode_AF,
408 .GPIO_OType = GPIO_OType_PP,
409 .GPIO_PuPd = GPIO_PuPd_NOPULL
412 .miso = {
413 .gpio = GPIOC,
414 .init = {
415 .GPIO_Pin = GPIO_Pin_11,
416 .GPIO_Speed = GPIO_Speed_50MHz,
417 .GPIO_Mode = GPIO_Mode_AF,
418 .GPIO_OType = GPIO_OType_PP,
419 .GPIO_PuPd = GPIO_PuPd_NOPULL
422 .mosi = {
423 .gpio = GPIOC,
424 .init = {
425 .GPIO_Pin = GPIO_Pin_12,
426 .GPIO_Speed = GPIO_Speed_50MHz,
427 .GPIO_Mode = GPIO_Mode_AF,
428 .GPIO_OType = GPIO_OType_PP,
429 .GPIO_PuPd = GPIO_PuPd_NOPULL
432 .slave_count = 1,
433 .ssel = {
435 .gpio = GPIOD,
436 .init = {
437 .GPIO_Pin = GPIO_Pin_2,
438 .GPIO_Speed = GPIO_Speed_50MHz,
439 .GPIO_Mode = GPIO_Mode_OUT,
440 .GPIO_OType = GPIO_OType_PP,
441 .GPIO_PuPd = GPIO_PuPd_UP
447 uint32_t pios_spi_flash_id;
448 void PIOS_SPI_flash_irq_handler(void)
450 /* Call into the generic code to handle the IRQ for this specific device */
451 PIOS_SPI_IRQ_Handler(pios_spi_flash_id);
453 #endif /* PIOS_FLASH_ON_ACCEL */
455 #endif /* PIOS_INCLUDE_SPI */
457 #if defined(PIOS_INCLUDE_FLASH)
458 #include "pios_flashfs_logfs_priv.h"
459 #include "pios_flash_jedec_priv.h"
460 #include "pios_flash_internal_priv.h"
462 static const struct flashfs_logfs_cfg flashfs_external_cfg = {
463 .fs_magic = 0x99abceef,
464 .total_fs_size = 0x00200000, /* 2M bytes (32 sectors = entire chip) */
465 .arena_size = 0x00010000, /* 256 * slot size */
466 .slot_size = 0x00000100, /* 256 bytes */
468 .start_offset = 0, /* start at the beginning of the chip */
469 .sector_size = 0x00010000, /* 64K bytes */
470 .page_size = 0x00000100, /* 256 bytes */
474 static const struct pios_flash_internal_cfg flash_internal_cfg = {};
476 static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
477 .fs_magic = 0x99abcfef,
478 .total_fs_size = EE_BANK_SIZE, /* 32K bytes (2x16KB sectors) */
479 .arena_size = 0x00004000, /* 64 * slot size = 16K bytes = 1 sector */
480 .slot_size = 0x00000100, /* 256 bytes */
482 .start_offset = EE_BANK_BASE, /* start after the bootloader */
483 .sector_size = 0x00004000, /* 16K bytes */
484 .page_size = 0x00004000, /* 16K bytes */
487 #endif /* PIOS_INCLUDE_FLASH */
489 #if defined(PIOS_OVERO_SPI)
490 /* SPI3 Interface
491 * - Used for flash communications
493 #include <pios_overo_priv.h>
494 void PIOS_OVERO_irq_handler(void);
495 void DMA1_Stream7_IRQHandler(void) __attribute__((alias("PIOS_OVERO_irq_handler")));
496 static const struct pios_overo_cfg pios_overo_cfg = {
497 .regs = SPI3,
498 .remap = GPIO_AF_SPI3,
499 .init = {
500 .SPI_Mode = SPI_Mode_Slave,
501 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
502 .SPI_DataSize = SPI_DataSize_8b,
503 .SPI_NSS = SPI_NSS_Hard,
504 .SPI_FirstBit = SPI_FirstBit_MSB,
505 .SPI_CRCPolynomial = 7,
506 .SPI_CPOL = SPI_CPOL_High,
507 .SPI_CPHA = SPI_CPHA_2Edge,
508 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
510 .use_crc = false,
511 .dma = {
512 .irq = {
513 // Note this is the stream ID that triggers interrupts (in this case TX)
514 .flags = (DMA_IT_TCIF7),
515 .init = {
516 .NVIC_IRQChannel = DMA1_Stream7_IRQn,
517 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
518 .NVIC_IRQChannelSubPriority = 0,
519 .NVIC_IRQChannelCmd = ENABLE,
523 .rx = {
524 .channel = DMA1_Stream0,
525 .init = {
526 .DMA_Channel = DMA_Channel_0,
527 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
528 .DMA_DIR = DMA_DIR_PeripheralToMemory,
529 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
530 .DMA_MemoryInc = DMA_MemoryInc_Enable,
531 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
532 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
533 .DMA_Mode = DMA_Mode_Circular,
534 .DMA_Priority = DMA_Priority_Medium,
535 // TODO: Enable FIFO
536 .DMA_FIFOMode = DMA_FIFOMode_Disable,
537 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
538 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
539 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
542 .tx = {
543 .channel = DMA1_Stream7,
544 .init = {
545 .DMA_Channel = DMA_Channel_0,
546 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI3->DR),
547 .DMA_DIR = DMA_DIR_MemoryToPeripheral,
548 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
549 .DMA_MemoryInc = DMA_MemoryInc_Enable,
550 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
551 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
552 .DMA_Mode = DMA_Mode_Circular,
553 .DMA_Priority = DMA_Priority_Medium,
554 .DMA_FIFOMode = DMA_FIFOMode_Disable,
555 .DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
556 .DMA_MemoryBurst = DMA_MemoryBurst_Single,
557 .DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
561 .sclk = {
562 .gpio = GPIOC,
563 .init = {
564 .GPIO_Pin = GPIO_Pin_10,
565 .GPIO_Speed = GPIO_Speed_100MHz,
566 .GPIO_Mode = GPIO_Mode_AF,
567 .GPIO_OType = GPIO_OType_PP,
568 .GPIO_PuPd = GPIO_PuPd_NOPULL
571 .miso = {
572 .gpio = GPIOC,
573 .init = {
574 .GPIO_Pin = GPIO_Pin_11,
575 .GPIO_Speed = GPIO_Speed_50MHz,
576 .GPIO_Mode = GPIO_Mode_AF,
577 .GPIO_OType = GPIO_OType_PP,
578 .GPIO_PuPd = GPIO_PuPd_NOPULL
581 .mosi = {
582 .gpio = GPIOC,
583 .init = {
584 .GPIO_Pin = GPIO_Pin_12,
585 .GPIO_Speed = GPIO_Speed_50MHz,
586 .GPIO_Mode = GPIO_Mode_AF,
587 .GPIO_OType = GPIO_OType_PP,
588 .GPIO_PuPd = GPIO_PuPd_NOPULL
591 .slave_count = 1,
592 .ssel = {
594 .gpio = GPIOA,
595 .init = {
596 .GPIO_Pin = GPIO_Pin_15,
597 .GPIO_Speed = GPIO_Speed_50MHz,
598 .GPIO_Mode = GPIO_Mode_OUT,
599 .GPIO_OType = GPIO_OType_PP,
600 .GPIO_PuPd = GPIO_PuPd_UP
605 uint32_t pios_overo_id = 0;
606 void PIOS_OVERO_irq_handler(void)
608 /* Call into the generic code to handle the IRQ for this specific device */
609 PIOS_OVERO_DMA_irq_handler(pios_overo_id);
611 #else /* if defined(PIOS_OVERO_SPI) */
613 #endif /* PIOS_OVERO_SPI */
616 #include <pios_usart_priv.h>
618 #ifdef PIOS_INCLUDE_COM_TELEM
620 * Telemetry on main USART
622 static const struct pios_usart_cfg pios_usart_telem_cfg = {
623 .regs = USART2,
624 .remap = GPIO_AF_USART2,
625 .init = {
626 .USART_BaudRate = 57600,
627 .USART_WordLength = USART_WordLength_8b,
628 .USART_Parity = USART_Parity_No,
629 .USART_StopBits = USART_StopBits_1,
630 .USART_HardwareFlowControl =
631 USART_HardwareFlowControl_None,
632 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
634 .irq = {
635 .init = {
636 .NVIC_IRQChannel = USART2_IRQn,
637 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
638 .NVIC_IRQChannelSubPriority = 0,
639 .NVIC_IRQChannelCmd = ENABLE,
642 .rx = {
643 .gpio = GPIOD,
644 .init = {
645 .GPIO_Pin = GPIO_Pin_6,
646 .GPIO_Speed = GPIO_Speed_2MHz,
647 .GPIO_Mode = GPIO_Mode_AF,
648 .GPIO_OType = GPIO_OType_PP,
649 .GPIO_PuPd = GPIO_PuPd_UP
652 .tx = {
653 .gpio = GPIOD,
654 .init = {
655 .GPIO_Pin = GPIO_Pin_5,
656 .GPIO_Speed = GPIO_Speed_2MHz,
657 .GPIO_Mode = GPIO_Mode_AF,
658 .GPIO_OType = GPIO_OType_PP,
659 .GPIO_PuPd = GPIO_PuPd_UP
664 #endif /* PIOS_COM_TELEM */
666 #ifdef PIOS_INCLUDE_GPS
668 * GPS USART
670 static const struct pios_usart_cfg pios_usart_gps_cfg = {
671 .regs = USART1,
672 .remap = GPIO_AF_USART1,
673 .init = {
674 .USART_BaudRate = 57600,
675 .USART_WordLength = USART_WordLength_8b,
676 .USART_Parity = USART_Parity_No,
677 .USART_StopBits = USART_StopBits_1,
678 .USART_HardwareFlowControl =
679 USART_HardwareFlowControl_None,
680 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
682 .irq = {
683 .init = {
684 .NVIC_IRQChannel = USART1_IRQn,
685 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
686 .NVIC_IRQChannelSubPriority = 0,
687 .NVIC_IRQChannelCmd = ENABLE,
690 .rx = {
691 .gpio = GPIOA,
692 .init = {
693 .GPIO_Pin = GPIO_Pin_10,
694 .GPIO_Speed = GPIO_Speed_2MHz,
695 .GPIO_Mode = GPIO_Mode_AF,
696 .GPIO_OType = GPIO_OType_PP,
697 .GPIO_PuPd = GPIO_PuPd_UP
700 .tx = {
701 .gpio = GPIOA,
702 .init = {
703 .GPIO_Pin = GPIO_Pin_9,
704 .GPIO_Speed = GPIO_Speed_2MHz,
705 .GPIO_Mode = GPIO_Mode_AF,
706 .GPIO_OType = GPIO_OType_PP,
707 .GPIO_PuPd = GPIO_PuPd_UP
712 #endif /* PIOS_INCLUDE_GPS */
714 #ifdef PIOS_INCLUDE_COM_AUX
716 * AUX USART (UART label on rev2)
718 static const struct pios_usart_cfg pios_usart_aux_cfg = {
719 .regs = USART6,
720 .remap = GPIO_AF_USART6,
721 .init = {
722 .USART_BaudRate = 57600,
723 .USART_WordLength = USART_WordLength_8b,
724 .USART_Parity = USART_Parity_No,
725 .USART_StopBits = USART_StopBits_1,
726 .USART_HardwareFlowControl =
727 USART_HardwareFlowControl_None,
728 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
730 .irq = {
731 .init = {
732 .NVIC_IRQChannel = USART6_IRQn,
733 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
734 .NVIC_IRQChannelSubPriority = 0,
735 .NVIC_IRQChannelCmd = ENABLE,
738 .rx = {
739 .gpio = GPIOC,
740 .init = {
741 .GPIO_Pin = GPIO_Pin_7,
742 .GPIO_Speed = GPIO_Speed_2MHz,
743 .GPIO_Mode = GPIO_Mode_AF,
744 .GPIO_OType = GPIO_OType_PP,
745 .GPIO_PuPd = GPIO_PuPd_UP
748 .tx = {
749 .gpio = GPIOC,
750 .init = {
751 .GPIO_Pin = GPIO_Pin_6,
752 .GPIO_Speed = GPIO_Speed_2MHz,
753 .GPIO_Mode = GPIO_Mode_AF,
754 .GPIO_OType = GPIO_OType_PP,
755 .GPIO_PuPd = GPIO_PuPd_UP
760 #endif /* PIOS_COM_AUX */
762 #ifdef PIOS_INCLUDE_COM_AUXSBUS
764 * AUX USART SBUS ( UART/ S Bus label on rev2)
766 static const struct pios_usart_cfg pios_usart_auxsbus_cfg = {
767 .regs = UART4,
768 .remap = GPIO_AF_UART4,
769 .init = {
770 .USART_BaudRate = 57600,
771 .USART_WordLength = USART_WordLength_8b,
772 .USART_Parity = USART_Parity_No,
773 .USART_StopBits = USART_StopBits_1,
774 .USART_HardwareFlowControl =
775 USART_HardwareFlowControl_None,
776 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
778 .irq = {
779 .init = {
780 .NVIC_IRQChannel = UART4_IRQn,
781 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
782 .NVIC_IRQChannelSubPriority = 0,
783 .NVIC_IRQChannelCmd = ENABLE,
786 .rx = {
787 .gpio = GPIOA,
788 .init = {
789 .GPIO_Pin = GPIO_Pin_1,
790 .GPIO_Speed = GPIO_Speed_2MHz,
791 .GPIO_Mode = GPIO_Mode_AF,
792 .GPIO_OType = GPIO_OType_PP,
793 .GPIO_PuPd = GPIO_PuPd_UP
796 .tx = {
797 .gpio = GPIOA,
798 .init = {
799 .GPIO_Pin = GPIO_Pin_0,
800 .GPIO_Speed = GPIO_Speed_2MHz,
801 .GPIO_Mode = GPIO_Mode_AF,
802 .GPIO_OType = GPIO_OType_PP,
803 .GPIO_PuPd = GPIO_PuPd_UP
808 #endif /* PIOS_INCLUDE_COM_AUXSBUS */
810 #ifdef PIOS_INCLUDE_COM_FLEXI
812 * FLEXI PORT
814 static const struct pios_usart_cfg pios_usart_flexi_cfg = {
815 .regs = USART3,
816 .remap = GPIO_AF_USART3,
817 .init = {
818 .USART_BaudRate = 57600,
819 .USART_WordLength = USART_WordLength_8b,
820 .USART_Parity = USART_Parity_No,
821 .USART_StopBits = USART_StopBits_1,
822 .USART_HardwareFlowControl =
823 USART_HardwareFlowControl_None,
824 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
826 .irq = {
827 .init = {
828 .NVIC_IRQChannel = USART3_IRQn,
829 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
830 .NVIC_IRQChannelSubPriority = 0,
831 .NVIC_IRQChannelCmd = ENABLE,
834 .rx = {
835 .gpio = GPIOB,
836 .init = {
837 .GPIO_Pin = GPIO_Pin_10,
838 .GPIO_Speed = GPIO_Speed_2MHz,
839 .GPIO_Mode = GPIO_Mode_AF,
840 .GPIO_OType = GPIO_OType_PP,
841 .GPIO_PuPd = GPIO_PuPd_UP
844 .tx = {
845 .gpio = GPIOB,
846 .init = {
847 .GPIO_Pin = GPIO_Pin_11,
848 .GPIO_Speed = GPIO_Speed_2MHz,
849 .GPIO_Mode = GPIO_Mode_AF,
850 .GPIO_OType = GPIO_OType_PP,
851 .GPIO_PuPd = GPIO_PuPd_UP
856 #endif /* PIOS_INCLUDE_COM_FLEXI */
858 #if defined(PIOS_INCLUDE_DSM)
860 * Spektrum/JR DSM USART
862 #include <pios_dsm_priv.h>
864 static const struct pios_usart_cfg pios_usart_dsm_aux_cfg = {
865 .regs = USART6,
866 .remap = GPIO_AF_USART6,
867 .init = {
868 .USART_BaudRate = 115200,
869 .USART_WordLength = USART_WordLength_8b,
870 .USART_Parity = USART_Parity_No,
871 .USART_StopBits = USART_StopBits_1,
872 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
873 .USART_Mode = USART_Mode_Rx,
875 .irq = {
876 .init = {
877 .NVIC_IRQChannel = USART6_IRQn,
878 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
879 .NVIC_IRQChannelSubPriority = 0,
880 .NVIC_IRQChannelCmd = ENABLE,
883 .rx = {
884 .gpio = GPIOC,
885 .init = {
886 .GPIO_Pin = GPIO_Pin_7,
887 .GPIO_Speed = GPIO_Speed_2MHz,
888 .GPIO_Mode = GPIO_Mode_AF,
889 .GPIO_OType = GPIO_OType_PP,
890 .GPIO_PuPd = GPIO_PuPd_UP
893 .tx = {
894 .gpio = GPIOC,
895 .init = {
896 .GPIO_Pin = GPIO_Pin_6,
897 .GPIO_Speed = GPIO_Speed_2MHz,
898 .GPIO_Mode = GPIO_Mode_AF,
899 .GPIO_OType = GPIO_OType_PP,
900 .GPIO_PuPd = GPIO_PuPd_UP
905 static const struct pios_dsm_cfg pios_dsm_aux_cfg = {
906 .bind = {
907 .gpio = GPIOC,
908 .init = {
909 .GPIO_Pin = GPIO_Pin_7,
910 .GPIO_Speed = GPIO_Speed_2MHz,
911 .GPIO_Mode = GPIO_Mode_OUT,
912 .GPIO_OType = GPIO_OType_PP,
913 .GPIO_PuPd = GPIO_PuPd_NOPULL
918 static const struct pios_usart_cfg pios_usart_dsm_auxsbus_cfg = {
919 .regs = UART4,
920 .remap = GPIO_AF_UART4,
921 .init = {
922 .USART_BaudRate = 115200,
923 .USART_WordLength = USART_WordLength_8b,
924 .USART_Parity = USART_Parity_No,
925 .USART_StopBits = USART_StopBits_1,
926 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
927 .USART_Mode = USART_Mode_Rx,
929 .irq = {
930 .init = {
931 .NVIC_IRQChannel = UART4_IRQn,
932 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
933 .NVIC_IRQChannelSubPriority = 0,
934 .NVIC_IRQChannelCmd = ENABLE,
937 .rx = {
938 .gpio = GPIOA,
939 .init = {
940 .GPIO_Pin = GPIO_Pin_1,
941 .GPIO_Speed = GPIO_Speed_2MHz,
942 .GPIO_Mode = GPIO_Mode_AF,
943 .GPIO_OType = GPIO_OType_PP,
944 .GPIO_PuPd = GPIO_PuPd_UP
947 .tx = {
948 .gpio = GPIOA,
949 .init = {
950 .GPIO_Pin = GPIO_Pin_0,
951 .GPIO_Speed = GPIO_Speed_2MHz,
952 .GPIO_Mode = GPIO_Mode_AF,
953 .GPIO_OType = GPIO_OType_PP,
954 .GPIO_PuPd = GPIO_PuPd_UP
959 static const struct pios_dsm_cfg pios_dsm_auxsbus_cfg = {
960 .bind = {
961 .gpio = GPIOA,
962 .init = {
963 .GPIO_Pin = GPIO_Pin_1,
964 .GPIO_Speed = GPIO_Speed_2MHz,
965 .GPIO_Mode = GPIO_Mode_OUT,
966 .GPIO_OType = GPIO_OType_PP,
967 .GPIO_PuPd = GPIO_PuPd_NOPULL
972 static const struct pios_usart_cfg pios_usart_dsm_flexi_cfg = {
973 .regs = USART3,
974 .remap = GPIO_AF_USART3,
975 .init = {
976 .USART_BaudRate = 115200,
977 .USART_WordLength = USART_WordLength_8b,
978 .USART_Parity = USART_Parity_No,
979 .USART_StopBits = USART_StopBits_1,
980 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
981 .USART_Mode = USART_Mode_Rx,
983 .irq = {
984 .init = {
985 .NVIC_IRQChannel = USART3_IRQn,
986 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
987 .NVIC_IRQChannelSubPriority = 0,
988 .NVIC_IRQChannelCmd = ENABLE,
991 .rx = {
992 .gpio = GPIOB,
993 .init = {
994 .GPIO_Pin = GPIO_Pin_11,
995 .GPIO_Speed = GPIO_Speed_2MHz,
996 .GPIO_Mode = GPIO_Mode_AF,
997 .GPIO_OType = GPIO_OType_PP,
998 .GPIO_PuPd = GPIO_PuPd_UP
1001 .tx = {
1002 .gpio = GPIOB,
1003 .init = {
1004 .GPIO_Pin = GPIO_Pin_10,
1005 .GPIO_Speed = GPIO_Speed_2MHz,
1006 .GPIO_Mode = GPIO_Mode_AF,
1007 .GPIO_OType = GPIO_OType_PP,
1008 .GPIO_PuPd = GPIO_PuPd_UP
1013 static const struct pios_dsm_cfg pios_dsm_flexi_cfg = {
1014 .bind = {
1015 .gpio = GPIOB,
1016 .init = {
1017 .GPIO_Pin = GPIO_Pin_11,
1018 .GPIO_Speed = GPIO_Speed_2MHz,
1019 .GPIO_Mode = GPIO_Mode_OUT,
1020 .GPIO_OType = GPIO_OType_PP,
1021 .GPIO_PuPd = GPIO_PuPd_NOPULL
1026 #endif /* PIOS_INCLUDE_DSM */
1028 #if defined(PIOS_INCLUDE_SBUS)
1030 * S.Bus USART
1032 #include <pios_sbus_priv.h>
1034 static const struct pios_usart_cfg pios_usart_sbus_auxsbus_cfg = {
1035 .regs = UART4,
1036 .remap = GPIO_AF_UART4,
1037 .init = {
1038 .USART_BaudRate = 100000,
1039 .USART_WordLength = USART_WordLength_8b,
1040 .USART_Parity = USART_Parity_Even,
1041 .USART_StopBits = USART_StopBits_2,
1042 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1043 .USART_Mode = USART_Mode_Rx,
1045 .irq = {
1046 .init = {
1047 .NVIC_IRQChannel = UART4_IRQn,
1048 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
1049 .NVIC_IRQChannelSubPriority = 0,
1050 .NVIC_IRQChannelCmd = ENABLE,
1053 .rx = {
1054 .gpio = GPIOA,
1055 .init = {
1056 .GPIO_Pin = GPIO_Pin_1,
1057 .GPIO_Speed = GPIO_Speed_2MHz,
1058 .GPIO_Mode = GPIO_Mode_AF,
1059 .GPIO_OType = GPIO_OType_PP,
1060 .GPIO_PuPd = GPIO_PuPd_UP
1063 .tx = {
1064 .gpio = GPIOA,
1065 .init = {
1066 .GPIO_Pin = GPIO_Pin_0,
1067 .GPIO_Speed = GPIO_Speed_2MHz,
1068 .GPIO_Mode = GPIO_Mode_OUT,
1069 .GPIO_OType = GPIO_OType_PP,
1070 .GPIO_PuPd = GPIO_PuPd_NOPULL
1075 static const struct pios_sbus_cfg pios_sbus_cfg = {
1076 /* Inverter configuration */
1077 .inv = {
1078 .gpio = GPIOC,
1079 .init = {
1080 .GPIO_Pin = GPIO_Pin_3,
1081 .GPIO_Mode = GPIO_Mode_OUT,
1082 .GPIO_OType = GPIO_OType_PP,
1083 .GPIO_Speed = GPIO_Speed_2MHz,
1086 .gpio_inv_enable = Bit_SET,
1087 .gpio_inv_disable = Bit_RESET,
1088 .gpio_clk_func = RCC_AHB1PeriphClockCmd,
1089 .gpio_clk_periph = RCC_AHB1Periph_GPIOC,
1092 #endif /* PIOS_INCLUDE_SBUS */
1095 * HK OSD
1097 static const struct pios_usart_cfg pios_usart_hkosd_auxsbus_cfg = {
1098 .regs = UART4,
1099 .remap = GPIO_AF_UART4,
1100 .init = {
1101 .USART_BaudRate = 57600,
1102 .USART_WordLength = USART_WordLength_8b,
1103 .USART_Parity = USART_Parity_No,
1104 .USART_StopBits = USART_StopBits_1,
1105 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1106 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
1108 .irq = {
1109 .init = {
1110 .NVIC_IRQChannel = UART4_IRQn,
1111 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1112 .NVIC_IRQChannelSubPriority = 0,
1113 .NVIC_IRQChannelCmd = ENABLE,
1116 .rx = {
1117 .gpio = GPIOA,
1118 .init = {
1119 .GPIO_Pin = GPIO_Pin_1,
1120 .GPIO_Speed = GPIO_Speed_2MHz,
1121 .GPIO_Mode = GPIO_Mode_AF,
1122 .GPIO_OType = GPIO_OType_PP,
1123 .GPIO_PuPd = GPIO_PuPd_UP
1126 .tx = {
1127 .gpio = GPIOA,
1128 .init = {
1129 .GPIO_Pin = GPIO_Pin_0,
1130 .GPIO_Speed = GPIO_Speed_2MHz,
1131 .GPIO_Mode = GPIO_Mode_AF,
1132 .GPIO_OType = GPIO_OType_PP,
1133 .GPIO_PuPd = GPIO_PuPd_UP
1138 static const struct pios_usart_cfg pios_usart_hkosd_aux_cfg = {
1139 .regs = USART6,
1140 .remap = GPIO_AF_USART6,
1141 .init = {
1142 .USART_BaudRate = 57600,
1143 .USART_WordLength = USART_WordLength_8b,
1144 .USART_Parity = USART_Parity_No,
1145 .USART_StopBits = USART_StopBits_1,
1146 .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
1147 .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
1149 .irq = {
1150 .init = {
1151 .NVIC_IRQChannel = USART6_IRQn,
1152 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1153 .NVIC_IRQChannelSubPriority = 0,
1154 .NVIC_IRQChannelCmd = ENABLE,
1157 .rx = {
1158 .gpio = GPIOC,
1159 .init = {
1160 .GPIO_Pin = GPIO_Pin_7,
1161 .GPIO_Speed = GPIO_Speed_2MHz,
1162 .GPIO_Mode = GPIO_Mode_AF,
1163 .GPIO_OType = GPIO_OType_PP,
1164 .GPIO_PuPd = GPIO_PuPd_UP
1167 .tx = {
1168 .gpio = GPIOC,
1169 .init = {
1170 .GPIO_Pin = GPIO_Pin_6,
1171 .GPIO_Speed = GPIO_Speed_2MHz,
1172 .GPIO_Mode = GPIO_Mode_AF,
1173 .GPIO_OType = GPIO_OType_PP,
1174 .GPIO_PuPd = GPIO_PuPd_UP
1179 #if defined(PIOS_INCLUDE_COM)
1181 #include <pios_com_priv.h>
1183 #endif /* PIOS_INCLUDE_COM */
1185 #if defined(PIOS_INCLUDE_I2C)
1187 #include <pios_i2c_priv.h>
1190 * I2C Adapters
1192 void PIOS_I2C_mag_adapter_ev_irq_handler(void);
1193 void PIOS_I2C_mag_adapter_er_irq_handler(void);
1194 void I2C1_EV_IRQHandler()
1195 __attribute__((alias("PIOS_I2C_mag_adapter_ev_irq_handler")));
1196 void I2C1_ER_IRQHandler()
1197 __attribute__((alias("PIOS_I2C_mag_adapter_er_irq_handler")));
1199 static const struct pios_i2c_adapter_cfg pios_i2c_mag_adapter_cfg = {
1200 .regs = I2C1,
1201 .remapSCL = GPIO_AF_I2C1,
1202 .remapSDA = GPIO_AF_I2C1,
1203 .init = {
1204 .I2C_Mode = I2C_Mode_I2C,
1205 .I2C_OwnAddress1 = 0,
1206 .I2C_Ack = I2C_Ack_Enable,
1207 .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
1208 .I2C_DutyCycle = I2C_DutyCycle_2,
1209 .I2C_ClockSpeed = 400000, /* bits/s */
1211 .transfer_timeout_ms = 50,
1212 .scl = {
1213 .gpio = GPIOB,
1214 .init = {
1215 .GPIO_Pin = GPIO_Pin_6,
1216 .GPIO_Mode = GPIO_Mode_AF,
1217 .GPIO_Speed = GPIO_Speed_50MHz,
1218 .GPIO_OType = GPIO_OType_OD,
1219 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1222 .sda = {
1223 .gpio = GPIOB,
1224 .init = {
1225 .GPIO_Pin = GPIO_Pin_7,
1226 .GPIO_Mode = GPIO_Mode_AF,
1227 .GPIO_Speed = GPIO_Speed_50MHz,
1228 .GPIO_OType = GPIO_OType_OD,
1229 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1232 .event = {
1233 .flags = 0, /* FIXME: check this */
1234 .init = {
1235 .NVIC_IRQChannel = I2C1_EV_IRQn,
1236 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1237 .NVIC_IRQChannelSubPriority = 0,
1238 .NVIC_IRQChannelCmd = ENABLE,
1241 .error = {
1242 .flags = 0, /* FIXME: check this */
1243 .init = {
1244 .NVIC_IRQChannel = I2C1_ER_IRQn,
1245 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1246 .NVIC_IRQChannelSubPriority = 0,
1247 .NVIC_IRQChannelCmd = ENABLE,
1252 uint32_t pios_i2c_mag_adapter_id;
1253 void PIOS_I2C_mag_adapter_ev_irq_handler(void)
1255 /* Call into the generic code to handle the IRQ for this specific device */
1256 PIOS_I2C_EV_IRQ_Handler(pios_i2c_mag_adapter_id);
1259 void PIOS_I2C_mag_adapter_er_irq_handler(void)
1261 /* Call into the generic code to handle the IRQ for this specific device */
1262 PIOS_I2C_ER_IRQ_Handler(pios_i2c_mag_adapter_id);
1266 void PIOS_I2C_flexiport_adapter_ev_irq_handler(void);
1267 void PIOS_I2C_flexiport_adapter_er_irq_handler(void);
1268 void I2C2_EV_IRQHandler() __attribute__((alias("PIOS_I2C_flexiport_adapter_ev_irq_handler")));
1269 void I2C2_ER_IRQHandler() __attribute__((alias("PIOS_I2C_flexiport_adapter_er_irq_handler")));
1271 static const struct pios_i2c_adapter_cfg pios_i2c_flexiport_adapter_cfg = {
1272 .regs = I2C2,
1273 .remapSCL = GPIO_AF_I2C2,
1274 .remapSDA = GPIO_AF_I2C2,
1275 .init = {
1276 .I2C_Mode = I2C_Mode_I2C,
1277 .I2C_OwnAddress1 = 0,
1278 .I2C_Ack = I2C_Ack_Enable,
1279 .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
1280 .I2C_DutyCycle = I2C_DutyCycle_2,
1281 .I2C_ClockSpeed = 400000, /* bits/s */
1283 .transfer_timeout_ms = 50,
1284 .scl = {
1285 .gpio = GPIOB,
1286 .init = {
1287 .GPIO_Pin = GPIO_Pin_10,
1288 .GPIO_Mode = GPIO_Mode_AF,
1289 .GPIO_Speed = GPIO_Speed_50MHz,
1290 .GPIO_OType = GPIO_OType_OD,
1291 .GPIO_PuPd = GPIO_PuPd_UP,
1294 .sda = {
1295 .gpio = GPIOB,
1296 .init = {
1297 .GPIO_Pin = GPIO_Pin_11,
1298 .GPIO_Mode = GPIO_Mode_AF,
1299 .GPIO_Speed = GPIO_Speed_50MHz,
1300 .GPIO_OType = GPIO_OType_OD,
1301 .GPIO_PuPd = GPIO_PuPd_UP,
1304 .event = {
1305 .flags = 0, /* FIXME: check this */
1306 .init = {
1307 .NVIC_IRQChannel = I2C2_EV_IRQn,
1308 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1309 .NVIC_IRQChannelSubPriority = 0,
1310 .NVIC_IRQChannelCmd = ENABLE,
1313 .error = {
1314 .flags = 0, /* FIXME: check this */
1315 .init = {
1316 .NVIC_IRQChannel = I2C2_ER_IRQn,
1317 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1318 .NVIC_IRQChannelSubPriority = 0,
1319 .NVIC_IRQChannelCmd = ENABLE,
1324 uint32_t pios_i2c_flexiport_adapter_id;
1325 void PIOS_I2C_flexiport_adapter_ev_irq_handler(void)
1327 /* Call into the generic code to handle the IRQ for this specific device */
1328 PIOS_I2C_EV_IRQ_Handler(pios_i2c_flexiport_adapter_id);
1331 void PIOS_I2C_flexiport_adapter_er_irq_handler(void)
1333 /* Call into the generic code to handle the IRQ for this specific device */
1334 PIOS_I2C_ER_IRQ_Handler(pios_i2c_flexiport_adapter_id);
1338 void PIOS_I2C_pressure_adapter_ev_irq_handler(void);
1339 void PIOS_I2C_pressure_adapter_er_irq_handler(void);
1340 void I2C3_EV_IRQHandler() __attribute__((alias("PIOS_I2C_pressure_adapter_ev_irq_handler")));
1341 void I2C3_ER_IRQHandler() __attribute__((alias("PIOS_I2C_pressure_adapter_er_irq_handler")));
1343 static const struct pios_i2c_adapter_cfg pios_i2c_pressure_adapter_cfg = {
1344 .regs = I2C3,
1345 .remapSCL = GPIO_AF_I2C3,
1346 .remapSDA = GPIO_AF_I2C3,
1347 .init = {
1348 .I2C_Mode = I2C_Mode_I2C,
1349 .I2C_OwnAddress1 = 0,
1350 .I2C_Ack = I2C_Ack_Enable,
1351 .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
1352 .I2C_DutyCycle = I2C_DutyCycle_2,
1353 .I2C_ClockSpeed = 400000, /* bits/s */
1355 .transfer_timeout_ms = 50,
1356 .scl = {
1357 .gpio = GPIOA,
1358 .init = {
1359 .GPIO_Pin = GPIO_Pin_8,
1360 .GPIO_Mode = GPIO_Mode_AF,
1361 .GPIO_Speed = GPIO_Speed_50MHz,
1362 .GPIO_OType = GPIO_OType_OD,
1363 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1366 .sda = {
1367 .gpio = GPIOC,
1368 .init = {
1369 .GPIO_Pin = GPIO_Pin_9,
1370 .GPIO_Mode = GPIO_Mode_AF,
1371 .GPIO_Speed = GPIO_Speed_50MHz,
1372 .GPIO_OType = GPIO_OType_OD,
1373 .GPIO_PuPd = GPIO_PuPd_NOPULL,
1376 .event = {
1377 .flags = 0, /* FIXME: check this */
1378 .init = {
1379 .NVIC_IRQChannel = I2C3_EV_IRQn,
1380 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1381 .NVIC_IRQChannelSubPriority = 0,
1382 .NVIC_IRQChannelCmd = ENABLE,
1385 .error = {
1386 .flags = 0, /* FIXME: check this */
1387 .init = {
1388 .NVIC_IRQChannel = I2C3_ER_IRQn,
1389 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
1390 .NVIC_IRQChannelSubPriority = 0,
1391 .NVIC_IRQChannelCmd = ENABLE,
1396 uint32_t pios_i2c_pressure_adapter_id;
1397 void PIOS_I2C_pressure_adapter_ev_irq_handler(void)
1399 /* Call into the generic code to handle the IRQ for this specific device */
1400 PIOS_I2C_EV_IRQ_Handler(pios_i2c_pressure_adapter_id);
1403 void PIOS_I2C_pressure_adapter_er_irq_handler(void)
1405 /* Call into the generic code to handle the IRQ for this specific device */
1406 PIOS_I2C_ER_IRQ_Handler(pios_i2c_pressure_adapter_id);
1408 #endif /* PIOS_INCLUDE_I2C */
1410 #if defined(PIOS_INCLUDE_RTC)
1412 * Realtime Clock (RTC)
1414 #include <pios_rtc_priv.h>
1416 void PIOS_RTC_IRQ_Handler(void);
1417 void RTC_WKUP_IRQHandler() __attribute__((alias("PIOS_RTC_IRQ_Handler")));
1418 static const struct pios_rtc_cfg pios_rtc_main_cfg = {
1419 .clksrc = RCC_RTCCLKSource_HSE_Div16, // Divide 8 Mhz crystal down to 1
1420 // For some reason it's acting like crystal is 16 Mhz. This clock is then divided
1421 // by another 16 to give a nominal 62.5 khz clock
1422 .prescaler = 100, // Every 100 cycles gives 625 Hz
1423 .irq = {
1424 .init = {
1425 .NVIC_IRQChannel = RTC_WKUP_IRQn,
1426 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1427 .NVIC_IRQChannelSubPriority = 0,
1428 .NVIC_IRQChannelCmd = ENABLE,
1433 void PIOS_RTC_IRQ_Handler(void)
1435 PIOS_RTC_irq_handler();
1438 #endif /* if defined(PIOS_INCLUDE_RTC) */
1440 #include "pios_tim_priv.h"
1442 static const TIM_TimeBaseInitTypeDef tim_2_3_5_time_base = {
1443 .TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
1444 .TIM_ClockDivision = TIM_CKD_DIV1,
1445 .TIM_CounterMode = TIM_CounterMode_Up,
1446 .TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
1447 .TIM_RepetitionCounter = 0x0000,
1450 static const TIM_TimeBaseInitTypeDef tim_9_10_11_time_base = {
1451 .TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
1452 .TIM_ClockDivision = TIM_CKD_DIV1,
1453 .TIM_CounterMode = TIM_CounterMode_Up,
1454 .TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
1455 .TIM_RepetitionCounter = 0x0000,
1458 // Set up timers that only have inputs on APB2
1459 static const TIM_TimeBaseInitTypeDef tim_1_time_base = {
1460 .TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
1461 .TIM_ClockDivision = TIM_CKD_DIV1,
1462 .TIM_CounterMode = TIM_CounterMode_Up,
1463 .TIM_Period = 0xFFFF,
1464 .TIM_RepetitionCounter = 0x0000,
1467 static const TIM_TimeBaseInitTypeDef tim_8_time_base = {
1468 .TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
1469 .TIM_ClockDivision = TIM_CKD_DIV1,
1470 .TIM_CounterMode = TIM_CounterMode_Up,
1471 .TIM_Period = 0xFFFF,
1472 .TIM_RepetitionCounter = 0x0000,
1475 // Set up timers that only have inputs on APB1
1476 static const TIM_TimeBaseInitTypeDef tim_4_time_base = {
1477 .TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
1478 .TIM_ClockDivision = TIM_CKD_DIV1,
1479 .TIM_CounterMode = TIM_CounterMode_Up,
1480 .TIM_Period = 0xFFFF,
1481 .TIM_RepetitionCounter = 0x0000,
1485 static const struct pios_tim_clock_cfg tim_2_cfg = {
1486 .timer = TIM2,
1487 .time_base_init = &tim_2_3_5_time_base,
1488 .irq = {
1489 .init = {
1490 .NVIC_IRQChannel = TIM2_IRQn,
1491 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1492 .NVIC_IRQChannelSubPriority = 0,
1493 .NVIC_IRQChannelCmd = ENABLE,
1499 static const struct pios_tim_clock_cfg tim_3_cfg = {
1500 .timer = TIM3,
1501 .time_base_init = &tim_2_3_5_time_base,
1502 .irq = {
1503 .init = {
1504 .NVIC_IRQChannel = TIM3_IRQn,
1505 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1506 .NVIC_IRQChannelSubPriority = 0,
1507 .NVIC_IRQChannelCmd = ENABLE,
1513 static const struct pios_tim_clock_cfg tim_5_cfg = {
1514 .timer = TIM5,
1515 .time_base_init = &tim_2_3_5_time_base,
1516 .irq = {
1517 .init = {
1518 .NVIC_IRQChannel = TIM5_IRQn,
1519 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1520 .NVIC_IRQChannelSubPriority = 0,
1521 .NVIC_IRQChannelCmd = ENABLE,
1526 static const struct pios_tim_clock_cfg tim_8_cfg = {
1527 .timer = TIM8,
1528 .time_base_init = &tim_8_time_base,
1529 .irq = {
1530 .init = {
1531 .NVIC_IRQChannel = TIM8_CC_IRQn,
1532 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1533 .NVIC_IRQChannelSubPriority = 0,
1534 .NVIC_IRQChannelCmd = ENABLE,
1539 static const struct pios_tim_clock_cfg tim_9_cfg = {
1540 .timer = TIM9,
1541 .time_base_init = &tim_9_10_11_time_base,
1542 .irq = {
1543 .init = {
1544 .NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn,
1545 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1546 .NVIC_IRQChannelSubPriority = 0,
1547 .NVIC_IRQChannelCmd = ENABLE,
1552 static const struct pios_tim_clock_cfg tim_10_cfg = {
1553 .timer = TIM10,
1554 .time_base_init = &tim_9_10_11_time_base,
1555 .irq = {
1556 .init = {
1557 .NVIC_IRQChannel = TIM1_UP_TIM10_IRQn,
1558 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1559 .NVIC_IRQChannelSubPriority = 0,
1560 .NVIC_IRQChannelCmd = ENABLE,
1565 static const struct pios_tim_clock_cfg tim_11_cfg = {
1566 .timer = TIM11,
1567 .time_base_init = &tim_9_10_11_time_base,
1568 .irq = {
1569 .init = {
1570 .NVIC_IRQChannel = TIM1_TRG_COM_TIM11_IRQn,
1571 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1572 .NVIC_IRQChannelSubPriority = 0,
1573 .NVIC_IRQChannelCmd = ENABLE,
1578 static const struct pios_tim_clock_cfg tim_1_cfg = {
1579 .timer = TIM1,
1580 .time_base_init = &tim_1_time_base,
1581 .irq = {
1582 .init = {
1583 .NVIC_IRQChannel = TIM1_CC_IRQn,
1584 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1585 .NVIC_IRQChannelSubPriority = 0,
1586 .NVIC_IRQChannelCmd = ENABLE,
1591 static const struct pios_tim_clock_cfg tim_4_cfg = {
1592 .timer = TIM4,
1593 .time_base_init = &tim_4_time_base,
1594 .irq = {
1595 .init = {
1596 .NVIC_IRQChannel = TIM4_IRQn,
1597 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
1598 .NVIC_IRQChannelSubPriority = 0,
1599 .NVIC_IRQChannelCmd = ENABLE,
1605 * Pios servo configuration structures
1607 #include <pios_servo_priv.h>
1608 static const struct pios_tim_channel pios_tim_servoport_all_pins[] = {
1610 .timer = TIM9,
1611 .timer_chan = TIM_Channel_1,
1612 .pin = {
1613 .gpio = GPIOE,
1614 .init = {
1615 .GPIO_Pin = GPIO_Pin_5,
1616 .GPIO_Speed = GPIO_Speed_2MHz,
1617 .GPIO_Mode = GPIO_Mode_AF,
1618 .GPIO_OType = GPIO_OType_PP,
1619 .GPIO_PuPd = GPIO_PuPd_UP
1621 .pin_source = GPIO_PinSource5,
1623 .remap = GPIO_AF_TIM9,
1626 .timer = TIM9,
1627 .timer_chan = TIM_Channel_2,
1628 .pin = {
1629 .gpio = GPIOE,
1630 .init = {
1631 .GPIO_Pin = GPIO_Pin_6,
1632 .GPIO_Speed = GPIO_Speed_2MHz,
1633 .GPIO_Mode = GPIO_Mode_AF,
1634 .GPIO_OType = GPIO_OType_PP,
1635 .GPIO_PuPd = GPIO_PuPd_UP
1637 .pin_source = GPIO_PinSource6,
1639 .remap = GPIO_AF_TIM9,
1642 .timer = TIM11,
1643 .timer_chan = TIM_Channel_1,
1644 .pin = {
1645 .gpio = GPIOB,
1646 .init = {
1647 .GPIO_Pin = GPIO_Pin_9,
1648 .GPIO_Speed = GPIO_Speed_2MHz,
1649 .GPIO_Mode = GPIO_Mode_AF,
1650 .GPIO_OType = GPIO_OType_PP,
1651 .GPIO_PuPd = GPIO_PuPd_UP
1653 .pin_source = GPIO_PinSource9,
1655 .remap = GPIO_AF_TIM11,
1658 .timer = TIM10,
1659 .timer_chan = TIM_Channel_1,
1660 .pin = {
1661 .gpio = GPIOB,
1662 .init = {
1663 .GPIO_Pin = GPIO_Pin_8,
1664 .GPIO_Speed = GPIO_Speed_2MHz,
1665 .GPIO_Mode = GPIO_Mode_AF,
1666 .GPIO_OType = GPIO_OType_PP,
1667 .GPIO_PuPd = GPIO_PuPd_UP
1669 .pin_source = GPIO_PinSource8,
1671 .remap = GPIO_AF_TIM10,
1674 .timer = TIM5,
1675 .timer_chan = TIM_Channel_3,
1676 .pin = {
1677 .gpio = GPIOA,
1678 .init = {
1679 .GPIO_Pin = GPIO_Pin_2,
1680 .GPIO_Speed = GPIO_Speed_2MHz,
1681 .GPIO_Mode = GPIO_Mode_AF,
1682 .GPIO_OType = GPIO_OType_PP,
1683 .GPIO_PuPd = GPIO_PuPd_UP
1685 .pin_source = GPIO_PinSource2,
1687 .remap = GPIO_AF_TIM5,
1690 .timer = TIM5,
1691 .timer_chan = TIM_Channel_4,
1692 .pin = {
1693 .gpio = GPIOA,
1694 .init = {
1695 .GPIO_Pin = GPIO_Pin_3,
1696 .GPIO_Speed = GPIO_Speed_2MHz,
1697 .GPIO_Mode = GPIO_Mode_AF,
1698 .GPIO_OType = GPIO_OType_PP,
1699 .GPIO_PuPd = GPIO_PuPd_UP
1701 .pin_source = GPIO_PinSource3,
1703 .remap = GPIO_AF_TIM5,
1706 .timer = TIM3,
1707 .timer_chan = TIM_Channel_3,
1708 .pin = {
1709 .gpio = GPIOB,
1710 .init = {
1711 .GPIO_Pin = GPIO_Pin_0,
1712 .GPIO_Speed = GPIO_Speed_2MHz,
1713 .GPIO_Mode = GPIO_Mode_AF,
1714 .GPIO_OType = GPIO_OType_PP,
1715 .GPIO_PuPd = GPIO_PuPd_UP
1717 .pin_source = GPIO_PinSource0,
1719 .remap = GPIO_AF_TIM3,
1722 .timer = TIM3,
1723 .timer_chan = TIM_Channel_4,
1724 .pin = {
1725 .gpio = GPIOB,
1726 .init = {
1727 .GPIO_Pin = GPIO_Pin_1,
1728 .GPIO_Speed = GPIO_Speed_2MHz,
1729 .GPIO_Mode = GPIO_Mode_AF,
1730 .GPIO_OType = GPIO_OType_PP,
1731 .GPIO_PuPd = GPIO_PuPd_UP
1733 .pin_source = GPIO_PinSource1,
1735 .remap = GPIO_AF_TIM3,
1737 // PB3 - TIM2 CH2 LED1
1739 .timer = TIM2,
1740 .timer_chan = TIM_Channel_2,
1741 .pin = {
1742 .gpio = GPIOB,
1743 .init = {
1744 .GPIO_Pin = GPIO_Pin_3,
1745 .GPIO_Speed = GPIO_Speed_2MHz,
1746 .GPIO_Mode = GPIO_Mode_AF,
1747 .GPIO_OType = GPIO_OType_PP,
1748 .GPIO_PuPd = GPIO_PuPd_UP
1750 .pin_source = GPIO_PinSource3,
1752 .remap = GPIO_AF_TIM2,
1754 // PB4 - TIM3 CH1 LED2
1756 .timer = TIM3,
1757 .timer_chan = TIM_Channel_1,
1758 .pin = {
1759 .gpio = GPIOB,
1760 .init = {
1761 .GPIO_Pin = GPIO_Pin_4,
1762 .GPIO_Speed = GPIO_Speed_2MHz,
1763 .GPIO_Mode = GPIO_Mode_AF,
1764 .GPIO_OType = GPIO_OType_PP,
1765 .GPIO_PuPd = GPIO_PuPd_UP
1767 .pin_source = GPIO_PinSource4,
1769 .remap = GPIO_AF_TIM3,
1773 const struct pios_servo_cfg pios_servo_cfg = {
1774 .tim_oc_init = {
1775 .TIM_OCMode = TIM_OCMode_PWM1,
1776 .TIM_OutputState = TIM_OutputState_Enable,
1777 .TIM_OutputNState = TIM_OutputNState_Disable,
1778 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
1779 .TIM_OCPolarity = TIM_OCPolarity_High,
1780 .TIM_OCNPolarity = TIM_OCPolarity_High,
1781 .TIM_OCIdleState = TIM_OCIdleState_Reset,
1782 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
1784 .channels = pios_tim_servoport_all_pins,
1785 .num_channels = NELEMENTS(pios_tim_servoport_all_pins),
1790 * PWM Inputs
1792 #if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM)
1793 #include <pios_pwm_priv.h>
1794 static const struct pios_tim_channel pios_tim_rcvrport_all_channels[] = {
1796 .timer = TIM4,
1797 .timer_chan = TIM_Channel_4,
1798 .pin = {
1799 .gpio = GPIOD,
1800 .init = {
1801 .GPIO_Pin = GPIO_Pin_15,
1802 .GPIO_Speed = GPIO_Speed_2MHz,
1803 .GPIO_Mode = GPIO_Mode_AF,
1804 .GPIO_OType = GPIO_OType_PP,
1805 .GPIO_PuPd = GPIO_PuPd_UP
1807 .pin_source = GPIO_PinSource15,
1809 .remap = GPIO_AF_TIM4,
1812 .timer = TIM4,
1813 .timer_chan = TIM_Channel_3,
1814 .pin = {
1815 .gpio = GPIOD,
1816 .init = {
1817 .GPIO_Pin = GPIO_Pin_14,
1818 .GPIO_Speed = GPIO_Speed_2MHz,
1819 .GPIO_Mode = GPIO_Mode_AF,
1820 .GPIO_OType = GPIO_OType_PP,
1821 .GPIO_PuPd = GPIO_PuPd_UP
1823 .pin_source = GPIO_PinSource14,
1825 .remap = GPIO_AF_TIM4,
1828 .timer = TIM4,
1829 .timer_chan = TIM_Channel_2,
1830 .pin = {
1831 .gpio = GPIOD,
1832 .init = {
1833 .GPIO_Pin = GPIO_Pin_13,
1834 .GPIO_Speed = GPIO_Speed_2MHz,
1835 .GPIO_Mode = GPIO_Mode_AF,
1836 .GPIO_OType = GPIO_OType_PP,
1837 .GPIO_PuPd = GPIO_PuPd_UP
1839 .pin_source = GPIO_PinSource13,
1841 .remap = GPIO_AF_TIM4,
1844 .timer = TIM4,
1845 .timer_chan = TIM_Channel_1,
1846 .pin = {
1847 .gpio = GPIOD,
1848 .init = {
1849 .GPIO_Pin = GPIO_Pin_12,
1850 .GPIO_Speed = GPIO_Speed_2MHz,
1851 .GPIO_Mode = GPIO_Mode_AF,
1852 .GPIO_OType = GPIO_OType_PP,
1853 .GPIO_PuPd = GPIO_PuPd_UP
1855 .pin_source = GPIO_PinSource12,
1857 .remap = GPIO_AF_TIM4,
1860 .timer = TIM1,
1861 .timer_chan = TIM_Channel_4,
1862 .pin = {
1863 .gpio = GPIOE,
1864 .init = {
1865 .GPIO_Pin = GPIO_Pin_14,
1866 .GPIO_Speed = GPIO_Speed_2MHz,
1867 .GPIO_Mode = GPIO_Mode_AF,
1868 .GPIO_OType = GPIO_OType_PP,
1869 .GPIO_PuPd = GPIO_PuPd_UP
1871 .pin_source = GPIO_PinSource14,
1873 .remap = GPIO_AF_TIM1,
1876 .timer = TIM1,
1877 .timer_chan = TIM_Channel_3,
1878 .pin = {
1879 .gpio = GPIOE,
1880 .init = {
1881 .GPIO_Pin = GPIO_Pin_13,
1882 .GPIO_Speed = GPIO_Speed_2MHz,
1883 .GPIO_Mode = GPIO_Mode_AF,
1884 .GPIO_OType = GPIO_OType_PP,
1885 .GPIO_PuPd = GPIO_PuPd_UP
1887 .pin_source = GPIO_PinSource13,
1889 .remap = GPIO_AF_TIM1,
1892 .timer = TIM1,
1893 .timer_chan = TIM_Channel_2,
1894 .pin = {
1895 .gpio = GPIOE,
1896 .init = {
1897 .GPIO_Pin = GPIO_Pin_11,
1898 .GPIO_Speed = GPIO_Speed_2MHz,
1899 .GPIO_Mode = GPIO_Mode_AF,
1900 .GPIO_OType = GPIO_OType_PP,
1901 .GPIO_PuPd = GPIO_PuPd_UP
1903 .pin_source = GPIO_PinSource11,
1905 .remap = GPIO_AF_TIM1,
1908 .timer = TIM1,
1909 .timer_chan = TIM_Channel_1,
1910 .pin = {
1911 .gpio = GPIOE,
1912 .init = {
1913 .GPIO_Pin = GPIO_Pin_9,
1914 .GPIO_Speed = GPIO_Speed_2MHz,
1915 .GPIO_Mode = GPIO_Mode_AF,
1916 .GPIO_OType = GPIO_OType_PP,
1917 .GPIO_PuPd = GPIO_PuPd_UP
1919 .pin_source = GPIO_PinSource9,
1921 .remap = GPIO_AF_TIM1,
1925 const struct pios_pwm_cfg pios_pwm_cfg = {
1926 .tim_ic_init = {
1927 .TIM_ICPolarity = TIM_ICPolarity_Rising,
1928 .TIM_ICSelection = TIM_ICSelection_DirectTI,
1929 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
1930 .TIM_ICFilter = 0x0,
1932 .channels = pios_tim_rcvrport_all_channels,
1933 .num_channels = NELEMENTS(pios_tim_rcvrport_all_channels),
1935 #endif /* if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM) */
1938 * PPM Input
1940 #if defined(PIOS_INCLUDE_PPM)
1941 #include <pios_ppm_priv.h>
1942 static const struct pios_ppm_cfg pios_ppm_cfg = {
1943 .tim_ic_init = {
1944 .TIM_ICPolarity = TIM_ICPolarity_Rising,
1945 .TIM_ICSelection = TIM_ICSelection_DirectTI,
1946 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
1947 .TIM_ICFilter = 0x0,
1948 .TIM_Channel = TIM_Channel_2,
1950 /* Use only the first channel for ppm */
1951 .channels = &pios_tim_rcvrport_all_channels[0],
1952 .num_channels = 1,
1955 #endif // PPM
1957 #if defined(PIOS_INCLUDE_GCSRCVR)
1958 #include "pios_gcsrcvr_priv.h"
1959 #endif /* PIOS_INCLUDE_GCSRCVR */
1961 #if defined(PIOS_INCLUDE_RCVR)
1962 #include "pios_rcvr_priv.h"
1963 #endif /* PIOS_INCLUDE_RCVR */
1966 * SONAR Inputs
1968 #if defined(PIOS_INCLUDE_HCSR04)
1969 #include <pios_hcsr04_priv.h>
1971 static const struct pios_tim_channel pios_tim_hcsr04_port_all_channels[] = {
1973 .timer = TIM8,
1974 .timer_chan = TIM_Channel_3,
1975 .pin = {
1976 .gpio = GPIOC,
1977 .init = {
1978 .GPIO_Pin = GPIO_Pin_8,
1979 .GPIO_Mode = GPIO_Mode_AF,
1980 .GPIO_Speed = GPIO_Speed_2MHz,
1981 .GPIO_PuPd = GPIO_PuPd_DOWN
1983 .pin_source = GPIO_PinSource8,
1985 .remap = GPIO_AF_TIM8,
1989 const struct pios_hcsr04_cfg pios_hcsr04_cfg = {
1990 .tim_ic_init = {
1991 .TIM_ICPolarity = TIM_ICPolarity_Rising,
1992 .TIM_ICSelection = TIM_ICSelection_DirectTI,
1993 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
1994 .TIM_ICFilter = 0x0,
1996 .channels = pios_tim_hcsr04_port_all_channels,
1997 .num_channels = NELEMENTS(pios_tim_hcsr04_port_all_channels),
1998 .trigger = {
1999 .gpio = GPIOD,
2000 .init = {
2001 .GPIO_Pin = GPIO_Pin_10,
2002 .GPIO_Mode = GPIO_Mode_OUT,
2003 .GPIO_OType = GPIO_OType_PP,
2004 .GPIO_PuPd = GPIO_PuPd_UP,
2005 .GPIO_Speed = GPIO_Speed_2MHz,
2009 #endif /* if defined(PIOS_INCLUDE_HCSR04) */
2011 #if defined(PIOS_INCLUDE_USB)
2012 #include "pios_usb_priv.h"
2014 static const struct pios_usb_cfg pios_usb_main_cfg = {
2015 .irq = {
2016 .init = {
2017 .NVIC_IRQChannel = OTG_FS_IRQn,
2018 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
2019 .NVIC_IRQChannelSubPriority = 0,
2020 .NVIC_IRQChannelCmd = ENABLE,
2023 .vsense = {
2024 .gpio = GPIOD,
2025 .init = {
2026 .GPIO_Pin = GPIO_Pin_11,
2027 .GPIO_Speed = GPIO_Speed_25MHz,
2028 .GPIO_Mode = GPIO_Mode_IN,
2029 .GPIO_OType = GPIO_OType_OD,
2032 .vsense_active_low = false
2035 #include "pios_usb_board_data_priv.h"
2036 #include "pios_usb_desc_hid_cdc_priv.h"
2037 #include "pios_usb_desc_hid_only_priv.h"
2038 #include "pios_usbhook.h"
2040 #endif /* PIOS_INCLUDE_USB */
2042 #if defined(PIOS_INCLUDE_COM_MSG)
2044 #include <pios_com_msg_priv.h>
2046 #endif /* PIOS_INCLUDE_COM_MSG */
2048 #if defined(PIOS_INCLUDE_USB_HID) && !defined(PIOS_INCLUDE_USB_CDC)
2049 #include <pios_usb_hid_priv.h>
2051 const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
2052 .data_if = 0,
2053 .data_rx_ep = 1,
2054 .data_tx_ep = 1,
2056 #endif /* PIOS_INCLUDE_USB_HID && !PIOS_INCLUDE_USB_CDC */
2058 #if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_USB_CDC)
2059 #include <pios_usb_cdc_priv.h>
2061 const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
2062 .ctrl_if = 1,
2063 .ctrl_tx_ep = 2,
2065 .data_if = 2,
2066 .data_rx_ep = 3,
2067 .data_tx_ep = 3,
2070 #include <pios_usb_hid_priv.h>
2072 const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
2073 .data_if = 2,
2074 .data_rx_ep = 1,
2075 .data_tx_ep = 1,
2077 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_USB_CDC */