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
8 * @addtogroup OpenPilotCore OpenPilot Core
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
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
] = {
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
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
60 static const struct pios_gpio_cfg pios_led_cfg
= {
62 .num_gpios
= NELEMENTS(pios_leds
),
65 const struct pios_gpio_cfg
*PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused
)) uint32_t board_revision
)
70 #endif /* PIOS_INCLUDE_LED */
72 #if defined(PIOS_INCLUDE_SPI)
73 #include <pios_spi_priv.h>
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
= {
82 .remap
= GPIO_AF_SPI1
,
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
,
97 .flags
= (DMA_IT_TCIF0
| DMA_IT_TEIF0
| DMA_IT_HTIF0
),
99 .NVIC_IRQChannel
= DMA2_Stream0_IRQn
,
100 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
101 .NVIC_IRQChannelSubPriority
= 0,
102 .NVIC_IRQChannelCmd
= ENABLE
,
107 .channel
= DMA2_Stream0
,
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
,
125 .channel
= DMA2_Stream3
,
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
,
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
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
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
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
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
);
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
= {
214 .remap
= GPIO_AF_SPI2
,
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
,
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
),
232 .NVIC_IRQChannel
= DMA1_Stream3_IRQn
,
233 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
234 .NVIC_IRQChannelSubPriority
= 0,
235 .NVIC_IRQChannelCmd
= ENABLE
,
240 .channel
= DMA1_Stream3
,
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
,
252 .DMA_FIFOMode
= DMA_FIFOMode_Disable
,
253 .DMA_FIFOThreshold
= DMA_FIFOThreshold_Full
,
254 .DMA_MemoryBurst
= DMA_MemoryBurst_Single
,
255 .DMA_PeripheralBurst
= DMA_PeripheralBurst_Single
,
259 .channel
= DMA1_Stream4
,
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
,
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
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
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
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)
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
= {
339 .remap
= GPIO_AF_SPI3
,
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
,
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
),
357 .NVIC_IRQChannel
= DMA1_Stream0_IRQn
,
358 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
359 .NVIC_IRQChannelSubPriority
= 0,
360 .NVIC_IRQChannelCmd
= ENABLE
,
365 .channel
= DMA1_Stream0
,
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
,
377 .DMA_FIFOMode
= DMA_FIFOMode_Disable
,
378 .DMA_FIFOThreshold
= DMA_FIFOThreshold_Full
,
379 .DMA_MemoryBurst
= DMA_MemoryBurst_Single
,
380 .DMA_PeripheralBurst
= DMA_PeripheralBurst_Single
,
384 .channel
= DMA1_Stream5
,
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
,
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
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
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
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)
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
= {
498 .remap
= GPIO_AF_SPI3
,
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
,
513 // Note this is the stream ID that triggers interrupts (in this case TX)
514 .flags
= (DMA_IT_TCIF7
),
516 .NVIC_IRQChannel
= DMA1_Stream7_IRQn
,
517 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
518 .NVIC_IRQChannelSubPriority
= 0,
519 .NVIC_IRQChannelCmd
= ENABLE
,
524 .channel
= DMA1_Stream0
,
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
,
536 .DMA_FIFOMode
= DMA_FIFOMode_Disable
,
537 .DMA_FIFOThreshold
= DMA_FIFOThreshold_Full
,
538 .DMA_MemoryBurst
= DMA_MemoryBurst_Single
,
539 .DMA_PeripheralBurst
= DMA_PeripheralBurst_Single
,
543 .channel
= DMA1_Stream7
,
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
,
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
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
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
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
= {
624 .remap
= GPIO_AF_USART2
,
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
,
636 .NVIC_IRQChannel
= USART2_IRQn
,
637 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
638 .NVIC_IRQChannelSubPriority
= 0,
639 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
670 static const struct pios_usart_cfg pios_usart_gps_cfg
= {
672 .remap
= GPIO_AF_USART1
,
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
,
684 .NVIC_IRQChannel
= USART1_IRQn
,
685 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
686 .NVIC_IRQChannelSubPriority
= 0,
687 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
720 .remap
= GPIO_AF_USART6
,
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
,
732 .NVIC_IRQChannel
= USART6_IRQn
,
733 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
734 .NVIC_IRQChannelSubPriority
= 0,
735 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
768 .remap
= GPIO_AF_UART4
,
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
,
780 .NVIC_IRQChannel
= UART4_IRQn
,
781 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
782 .NVIC_IRQChannelSubPriority
= 0,
783 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
814 static const struct pios_usart_cfg pios_usart_flexi_cfg
= {
816 .remap
= GPIO_AF_USART3
,
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
,
828 .NVIC_IRQChannel
= USART3_IRQn
,
829 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
830 .NVIC_IRQChannelSubPriority
= 0,
831 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
866 .remap
= GPIO_AF_USART6
,
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
,
877 .NVIC_IRQChannel
= USART6_IRQn
,
878 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
879 .NVIC_IRQChannelSubPriority
= 0,
880 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
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
= {
920 .remap
= GPIO_AF_UART4
,
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
,
931 .NVIC_IRQChannel
= UART4_IRQn
,
932 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
933 .NVIC_IRQChannelSubPriority
= 0,
934 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
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
= {
974 .remap
= GPIO_AF_USART3
,
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
,
985 .NVIC_IRQChannel
= USART3_IRQn
,
986 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
987 .NVIC_IRQChannelSubPriority
= 0,
988 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
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)
1032 #include <pios_sbus_priv.h>
1034 static const struct pios_usart_cfg pios_usart_sbus_auxsbus_cfg
= {
1036 .remap
= GPIO_AF_UART4
,
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
,
1047 .NVIC_IRQChannel
= UART4_IRQn
,
1048 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
1049 .NVIC_IRQChannelSubPriority
= 0,
1050 .NVIC_IRQChannelCmd
= ENABLE
,
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
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 */
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 */
1097 static const struct pios_usart_cfg pios_usart_hkosd_auxsbus_cfg
= {
1099 .remap
= GPIO_AF_UART4
,
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
,
1110 .NVIC_IRQChannel
= UART4_IRQn
,
1111 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
1112 .NVIC_IRQChannelSubPriority
= 0,
1113 .NVIC_IRQChannelCmd
= ENABLE
,
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
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
= {
1140 .remap
= GPIO_AF_USART6
,
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
,
1151 .NVIC_IRQChannel
= USART6_IRQn
,
1152 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_MID
,
1153 .NVIC_IRQChannelSubPriority
= 0,
1154 .NVIC_IRQChannelCmd
= ENABLE
,
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
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>
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
= {
1201 .remapSCL
= GPIO_AF_I2C1
,
1202 .remapSDA
= GPIO_AF_I2C1
,
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,
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
,
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
,
1233 .flags
= 0, /* FIXME: check this */
1235 .NVIC_IRQChannel
= I2C1_EV_IRQn
,
1236 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGHEST
,
1237 .NVIC_IRQChannelSubPriority
= 0,
1238 .NVIC_IRQChannelCmd
= ENABLE
,
1242 .flags
= 0, /* FIXME: check this */
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
= {
1273 .remapSCL
= GPIO_AF_I2C2
,
1274 .remapSDA
= GPIO_AF_I2C2
,
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,
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
,
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
,
1305 .flags
= 0, /* FIXME: check this */
1307 .NVIC_IRQChannel
= I2C2_EV_IRQn
,
1308 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGHEST
,
1309 .NVIC_IRQChannelSubPriority
= 0,
1310 .NVIC_IRQChannelCmd
= ENABLE
,
1314 .flags
= 0, /* FIXME: check this */
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
= {
1345 .remapSCL
= GPIO_AF_I2C3
,
1346 .remapSDA
= GPIO_AF_I2C3
,
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,
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
,
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
,
1377 .flags
= 0, /* FIXME: check this */
1379 .NVIC_IRQChannel
= I2C3_EV_IRQn
,
1380 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGHEST
,
1381 .NVIC_IRQChannelSubPriority
= 0,
1382 .NVIC_IRQChannelCmd
= ENABLE
,
1386 .flags
= 0, /* FIXME: check this */
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
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
= {
1487 .time_base_init
= &tim_2_3_5_time_base
,
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
= {
1501 .time_base_init
= &tim_2_3_5_time_base
,
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
= {
1515 .time_base_init
= &tim_2_3_5_time_base
,
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
= {
1528 .time_base_init
= &tim_8_time_base
,
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
= {
1541 .time_base_init
= &tim_9_10_11_time_base
,
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
= {
1554 .time_base_init
= &tim_9_10_11_time_base
,
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
= {
1567 .time_base_init
= &tim_9_10_11_time_base
,
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
= {
1580 .time_base_init
= &tim_1_time_base
,
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
= {
1593 .time_base_init
= &tim_4_time_base
,
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
[] = {
1611 .timer_chan
= TIM_Channel_1
,
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
,
1627 .timer_chan
= TIM_Channel_2
,
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
,
1643 .timer_chan
= TIM_Channel_1
,
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
,
1659 .timer_chan
= TIM_Channel_1
,
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
,
1675 .timer_chan
= TIM_Channel_3
,
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
,
1691 .timer_chan
= TIM_Channel_4
,
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
,
1707 .timer_chan
= TIM_Channel_3
,
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
,
1723 .timer_chan
= TIM_Channel_4
,
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
1740 .timer_chan
= TIM_Channel_2
,
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
1757 .timer_chan
= TIM_Channel_1
,
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
= {
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
),
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
[] = {
1797 .timer_chan
= TIM_Channel_4
,
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
,
1813 .timer_chan
= TIM_Channel_3
,
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
,
1829 .timer_chan
= TIM_Channel_2
,
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
,
1845 .timer_chan
= TIM_Channel_1
,
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
,
1861 .timer_chan
= TIM_Channel_4
,
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
,
1877 .timer_chan
= TIM_Channel_3
,
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
,
1893 .timer_chan
= TIM_Channel_2
,
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
,
1909 .timer_chan
= TIM_Channel_1
,
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
= {
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) */
1940 #if defined(PIOS_INCLUDE_PPM)
1941 #include <pios_ppm_priv.h>
1942 static const struct pios_ppm_cfg pios_ppm_cfg
= {
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],
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 */
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
[] = {
1974 .timer_chan
= TIM_Channel_3
,
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
= {
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
),
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
= {
2017 .NVIC_IRQChannel
= OTG_FS_IRQn
,
2018 .NVIC_IRQChannelPreemptionPriority
= PIOS_IRQ_PRIO_HIGH
,
2019 .NVIC_IRQChannelSubPriority
= 0,
2020 .NVIC_IRQChannelCmd
= ENABLE
,
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
= {
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
= {
2070 #include <pios_usb_hid_priv.h>
2072 const struct pios_usb_hid_cfg pios_usb_hid_cfg
= {
2077 #endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_USB_CDC */