update credits
[librepilot.git] / flight / targets / boards / oplinkmini / board_hw_defs.c
blob85130655db8952b37bb55a069bb7c74187f0b8eb
1 /**
2 ******************************************************************************
4 * @file board_hw_defs.c.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
6 * @brief Defines board hardware for the OpenPilot OPLink Mini board.
7 * @see The GNU Public License (GPL) Version 3
9 *****************************************************************************/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #if defined(PIOS_INCLUDE_LED)
29 #include <pios_led_priv.h>
30 static const struct pios_gpio pios_leds[] = {
31 [PIOS_LED_USB] = {
32 .pin = {
33 .gpio = GPIOA,
34 .init = {
35 .GPIO_Pin = GPIO_Pin_3,
36 .GPIO_Mode = GPIO_Mode_Out_PP,
37 .GPIO_Speed = GPIO_Speed_50MHz,
40 .active_low = true
42 [PIOS_LED_LINK] = {
43 .pin = {
44 .gpio = GPIOB,
45 .init = {
46 .GPIO_Pin = GPIO_Pin_5,
47 .GPIO_Mode = GPIO_Mode_Out_PP,
48 .GPIO_Speed = GPIO_Speed_50MHz,
51 .active_low = true
53 [PIOS_LED_RX] = {
54 .pin = {
55 .gpio = GPIOB,
56 .init = {
57 .GPIO_Pin = GPIO_Pin_6,
58 .GPIO_Mode = GPIO_Mode_Out_PP,
59 .GPIO_Speed = GPIO_Speed_50MHz,
62 .active_low = true
64 [PIOS_LED_TX] = {
65 .pin = {
66 .gpio = GPIOB,
67 .init = {
68 .GPIO_Pin = GPIO_Pin_7,
69 .GPIO_Mode = GPIO_Mode_Out_PP,
70 .GPIO_Speed = GPIO_Speed_50MHz,
73 .active_low = true
75 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
76 [PIOS_LED_D1] = {
77 .pin = {
78 .gpio = GPIOB,
79 .init = {
80 .GPIO_Pin = GPIO_Pin_14,
81 .GPIO_Mode = GPIO_Mode_Out_PP,
82 .GPIO_Speed = GPIO_Speed_50MHz,
86 [PIOS_LED_D2] = {
87 .pin = {
88 .gpio = GPIOB,
89 .init = {
90 .GPIO_Pin = GPIO_Pin_15,
91 .GPIO_Mode = GPIO_Mode_Out_PP,
92 .GPIO_Speed = GPIO_Speed_50MHz,
96 [PIOS_LED_D3] = {
97 .pin = {
98 .gpio = GPIOA,
99 .init = {
100 .GPIO_Pin = GPIO_Pin_9,
101 .GPIO_Mode = GPIO_Mode_Out_PP,
102 .GPIO_Speed = GPIO_Speed_50MHz,
106 [PIOS_LED_D4] = {
107 .pin = {
108 .gpio = GPIOA,
109 .init = {
110 .GPIO_Pin = GPIO_Pin_10,
111 .GPIO_Mode = GPIO_Mode_Out_PP,
112 .GPIO_Speed = GPIO_Speed_50MHz,
116 #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
119 static const struct pios_gpio_cfg pios_led_cfg = {
120 .gpios = pios_leds,
121 .num_gpios = NELEMENTS(pios_leds),
124 const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision)
126 return &pios_led_cfg;
129 #endif /* PIOS_INCLUDE_LED */
131 #if defined(PIOS_INCLUDE_FLASH)
132 #include "pios_flashfs_logfs_priv.h"
133 #include "pios_flash_internal_priv.h"
135 static const struct pios_flash_internal_cfg flash_internal_cfg = {};
137 static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
138 .fs_magic = 0x99abcfef,
139 .total_fs_size = EE_BANK_SIZE, /* 2K bytes (2x1KB sectors) */
140 .arena_size = 0x00002000, /* 4 * slot size = 1K bytes = 1 sector */
141 .slot_size = 0x00000100, /* 256 bytes */
143 .start_offset = EE_BANK_BASE, /* start after the bootloader */
144 .sector_size = 0x00000400, /* 1K bytes */
145 .page_size = 0x00000400, /* 1K bytes */
148 #include "pios_flash.h"
150 #endif /* PIOS_INCLUDE_FLASH */
153 #if defined(PIOS_INCLUDE_SPI)
155 #include <pios_spi_priv.h>
157 /* OP Interface
159 * NOTE: Leave this declared as const data so that it ends up in the
160 * .rodata section (ie. Flash) rather than in the .bss section (RAM).
162 void PIOS_SPI_port_irq_handler(void);
163 void DMA1_Channel5_IRQHandler() __attribute__((alias("PIOS_SPI_port_irq_handler")));
164 void DMA1_Channel4_IRQHandler() __attribute__((alias("PIOS_SPI_port_irq_handler")));
166 static const struct pios_spi_cfg pios_spi_rfm22b_cfg = {
167 .regs = SPI1,
169 .init = {
170 .SPI_Mode = SPI_Mode_Master,
171 .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
172 .SPI_DataSize = SPI_DataSize_8b,
173 .SPI_NSS = SPI_NSS_Soft,
174 .SPI_FirstBit = SPI_FirstBit_MSB,
175 .SPI_CRCPolynomial = 0,
176 .SPI_CPOL = SPI_CPOL_Low,
177 .SPI_CPHA = SPI_CPHA_1Edge,
178 .SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16, // slowest SCLK
180 .use_crc = FALSE,
182 .dma = {
183 .ahb_clk = RCC_AHBPeriph_DMA1,
184 .irq = {
185 .flags = (DMA1_FLAG_TC2 | DMA1_FLAG_TE2 | DMA1_FLAG_HT2 | DMA1_FLAG_GL2),
186 .init = {
187 .NVIC_IRQChannel = DMA1_Channel2_IRQn,
188 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
189 .NVIC_IRQChannelSubPriority = 0,
190 .NVIC_IRQChannelCmd = ENABLE,
194 .rx = {
195 .channel = DMA1_Channel2,
196 .init = {
197 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
198 .DMA_DIR = DMA_DIR_PeripheralSRC,
199 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
200 .DMA_MemoryInc = DMA_MemoryInc_Enable,
201 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
202 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
203 .DMA_Mode = DMA_Mode_Normal,
204 .DMA_Priority = DMA_Priority_Medium,
205 .DMA_M2M = DMA_M2M_Disable,
208 .tx = {
209 .channel = DMA1_Channel3,
210 .init = {
211 .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
212 .DMA_DIR = DMA_DIR_PeripheralDST,
213 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
214 .DMA_MemoryInc = DMA_MemoryInc_Enable,
215 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
216 .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
217 .DMA_Mode = DMA_Mode_Normal,
218 .DMA_Priority = DMA_Priority_Medium,
219 .DMA_M2M = DMA_M2M_Disable,
223 .slave_count = 1,
224 .ssel = {
226 .gpio = GPIOA,
227 .init = {
228 .GPIO_Pin = GPIO_Pin_4,
229 .GPIO_Speed = GPIO_Speed_10MHz,
230 .GPIO_Mode = GPIO_Mode_Out_PP,
234 .sclk = {
235 .gpio = GPIOA,
236 .init = {
237 .GPIO_Pin = GPIO_Pin_5,
238 .GPIO_Speed = GPIO_Speed_10MHz,
239 .GPIO_Mode = GPIO_Mode_AF_PP,
242 .miso = {
243 .gpio = GPIOA,
244 .init = {
245 .GPIO_Pin = GPIO_Pin_6,
246 .GPIO_Speed = GPIO_Speed_10MHz,
247 .GPIO_Mode = GPIO_Mode_IN_FLOATING,
250 .mosi = {
251 .gpio = GPIOA,
252 .init = {
253 .GPIO_Pin = GPIO_Pin_7,
254 .GPIO_Speed = GPIO_Speed_10MHz,
255 .GPIO_Mode = GPIO_Mode_AF_PP,
260 uint32_t pios_spi_rfm22b_id;
261 void PIOS_SPI_port_irq_handler(void)
263 /* Call into the generic code to handle the IRQ for this specific device */
264 PIOS_SPI_IRQ_Handler(pios_spi_rfm22b_id);
267 #endif /* PIOS_INCLUDE_SPI */
269 #if defined(PIOS_INCLUDE_RFM22B)
271 #include <pios_rfm22b_priv.h>
273 static const struct pios_exti_cfg pios_exti_rfm22b_cfg __exti_config = {
274 .vector = PIOS_RFM22_EXT_Int,
275 .line = EXTI_Line2,
276 .pin = {
277 .gpio = GPIOA,
278 .init = {
279 .GPIO_Pin = GPIO_Pin_2,
280 .GPIO_Mode = GPIO_Mode_IN_FLOATING,
283 .irq = {
284 .init = {
285 .NVIC_IRQChannel = EXTI2_IRQn,
286 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
287 .NVIC_IRQChannelSubPriority = 0,
288 .NVIC_IRQChannelCmd = ENABLE,
291 .exti = {
292 .init = {
293 .EXTI_Line = EXTI_Line2,
294 .EXTI_Mode = EXTI_Mode_Interrupt,
295 .EXTI_Trigger = EXTI_Trigger_Falling,
296 .EXTI_LineCmd = ENABLE,
301 struct pios_rfm22b_cfg pios_rfm22b_cfg = {
302 .spi_cfg = &pios_spi_rfm22b_cfg,
303 .exti_cfg = &pios_exti_rfm22b_cfg,
304 .RFXtalCap = 0x7f,
305 .slave_num = 0,
306 .gpio_direction = GPIO0_TX_GPIO1_RX,
309 // ! Compatibility layer for various hardware revisions
310 const struct pios_rfm22b_cfg *PIOS_BOARD_HW_DEFS_GetRfm22bCfg(__attribute__((unused)) uint32_t board_revision)
312 return &pios_rfm22b_cfg;
315 #if defined(PIOS_INCLUDE_OPENLRS)
317 #include <pios_openlrs_priv.h>
319 static const struct pios_exti_cfg pios_exti_openlrs_cfg __exti_config = {
320 .vector = PIOS_OpenLRS_EXT_Int,
321 .line = EXTI_Line2,
322 .pin = {
323 .gpio = GPIOA,
324 .init = {
325 .GPIO_Pin = GPIO_Pin_2,
326 .GPIO_Mode = GPIO_Mode_IN_FLOATING,
329 .irq = {
330 .init = {
331 .NVIC_IRQChannel = EXTI2_IRQn,
332 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
333 .NVIC_IRQChannelSubPriority = 0,
334 .NVIC_IRQChannelCmd = ENABLE,
337 .exti = {
338 .init = {
339 .EXTI_Line = EXTI_Line2,
340 .EXTI_Mode = EXTI_Mode_Interrupt,
341 .EXTI_Trigger = EXTI_Trigger_Falling,
342 .EXTI_LineCmd = ENABLE,
347 struct pios_openlrs_cfg pios_openlrs_cfg = {
348 .spi_cfg = &pios_spi_rfm22b_cfg,
349 .exti_cfg = &pios_exti_openlrs_cfg,
352 // ! Compatibility layer for various hardware revisions
353 const struct pios_openlrs_cfg *PIOS_BOARD_HW_DEFS_GetOpenLRSCfg(__attribute__((unused)) uint32_t board_revision)
355 return &pios_openlrs_cfg;
358 #endif /* PIOS_INCLUDE_OpenLRS */
360 #endif /* PIOS_INCLUDE_RFM22B */
362 #if defined(PIOS_INCLUDE_ADC)
365 * ADC system
367 #include "pios_adc_priv.h"
368 extern void PIOS_ADC_handler(void);
369 void DMA1_Channel1_IRQHandler() __attribute__((alias("PIOS_ADC_handler")));
370 // Remap the ADC DMA handler to this one
371 static const struct pios_adc_cfg pios_adc_cfg = {
372 .dma = {
373 .ahb_clk = RCC_AHBPeriph_DMA1,
374 .irq = {
375 .flags = (DMA1_FLAG_TC1 | DMA1_FLAG_TE1 | DMA1_FLAG_HT1 | DMA1_FLAG_GL1),
376 .init = {
377 .NVIC_IRQChannel = DMA1_Channel1_IRQn,
378 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
379 .NVIC_IRQChannelSubPriority = 0,
380 .NVIC_IRQChannelCmd = ENABLE,
383 .rx = {
384 .channel = DMA1_Channel1,
385 .init = {
386 .DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR,
387 .DMA_DIR = DMA_DIR_PeripheralSRC,
388 .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
389 .DMA_MemoryInc = DMA_MemoryInc_Enable,
390 .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word,
391 .DMA_MemoryDataSize = DMA_MemoryDataSize_Word,
392 .DMA_Mode = DMA_Mode_Circular,
393 .DMA_Priority = DMA_Priority_High,
394 .DMA_M2M = DMA_M2M_Disable,
398 .half_flag = DMA1_IT_HT1,
399 .full_flag = DMA1_IT_TC1,
402 struct pios_adc_dev pios_adc_devs[] = {
404 .cfg = &pios_adc_cfg,
405 .callback_function = NULL,
409 uint8_t pios_adc_num_devices = NELEMENTS(pios_adc_devs);
411 void PIOS_ADC_handler()
413 PIOS_ADC_DMA_Handler();
416 #endif /* PIOS_INCLUDE_ADC */
418 #if defined(PIOS_INCLUDE_TIM)
420 #include "pios_tim_priv.h"
422 static const TIM_TimeBaseInitTypeDef tim_1_2_3_4_time_base = {
423 .TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
424 .TIM_ClockDivision = TIM_CKD_DIV1,
425 .TIM_CounterMode = TIM_CounterMode_Up,
426 .TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
427 .TIM_RepetitionCounter = 0x0000,
430 static const struct pios_tim_clock_cfg tim_1_cfg = {
431 .timer = TIM1,
432 .time_base_init = &tim_1_2_3_4_time_base,
433 .irq = {
434 .init = {
435 .NVIC_IRQChannel = TIM1_CC_IRQn,
436 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
437 .NVIC_IRQChannelSubPriority = 0,
438 .NVIC_IRQChannelCmd = ENABLE,
443 static const struct pios_tim_clock_cfg tim_2_cfg = {
444 .timer = TIM2,
445 .time_base_init = &tim_1_2_3_4_time_base,
446 .irq = {
447 .init = {
448 .NVIC_IRQChannel = TIM2_IRQn,
449 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
450 .NVIC_IRQChannelSubPriority = 0,
451 .NVIC_IRQChannelCmd = ENABLE,
456 static const struct pios_tim_clock_cfg tim_3_cfg = {
457 .timer = TIM3,
458 .time_base_init = &tim_1_2_3_4_time_base,
459 .irq = {
460 .init = {
461 .NVIC_IRQChannel = TIM3_IRQn,
462 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
463 .NVIC_IRQChannelSubPriority = 0,
464 .NVIC_IRQChannelCmd = ENABLE,
469 static const struct pios_tim_clock_cfg tim_4_cfg = {
470 .timer = TIM4,
471 .time_base_init = &tim_1_2_3_4_time_base,
472 .irq = {
473 .init = {
474 .NVIC_IRQChannel = TIM4_IRQn,
475 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
476 .NVIC_IRQChannelSubPriority = 0,
477 .NVIC_IRQChannelCmd = ENABLE,
482 static const struct pios_tim_channel pios_tim_all_port_pins[] = {
483 /* Main Tx */
485 .timer = TIM1,
486 .timer_chan = TIM_Channel_2,
487 .pin = {
488 .gpio = GPIOA,
489 .init = {
490 .GPIO_Pin = GPIO_Pin_9,
491 .GPIO_Mode = GPIO_Mode_AF_PP,
492 .GPIO_Speed = GPIO_Speed_2MHz,
496 /* Main Rx */
498 .timer = TIM1,
499 .timer_chan = TIM_Channel_3,
500 .pin = {
501 .gpio = GPIOA,
502 .init = {
503 .GPIO_Pin = GPIO_Pin_10,
504 .GPIO_Mode = GPIO_Mode_AF_PP,
505 .GPIO_Speed = GPIO_Speed_2MHz,
509 /* Flexi Tx */
511 .timer = TIM2,
512 .timer_chan = TIM_Channel_3,
513 .pin = {
514 .gpio = GPIOB,
515 .init = {
516 .GPIO_Pin = GPIO_Pin_10,
517 .GPIO_Mode = GPIO_Mode_AF_PP,
518 .GPIO_Speed = GPIO_Speed_2MHz,
521 .remap = GPIO_PartialRemap2_TIM2,
523 /* Flexi Rx */
525 .timer = TIM2,
526 .timer_chan = TIM_Channel_4,
527 .pin = {
528 .gpio = GPIOB,
529 .init = {
530 .GPIO_Pin = GPIO_Pin_11,
531 .GPIO_Mode = GPIO_Mode_AF_PP,
532 .GPIO_Speed = GPIO_Speed_2MHz,
535 .remap = GPIO_PartialRemap2_TIM2,
539 static const struct pios_tim_channel pios_tim_main_port_ppm = {
540 .timer = TIM1,
541 .timer_chan = TIM_Channel_3,
542 .pin = {
543 .gpio = GPIOA,
544 .init = {
545 .GPIO_Pin = GPIO_Pin_10,
546 .GPIO_Mode = GPIO_Mode_IPD,
547 .GPIO_Speed = GPIO_Speed_2MHz,
552 static const struct pios_tim_channel pios_tim_flexi_port_ppm = {
553 .timer = TIM2,
554 .timer_chan = TIM_Channel_4,
555 .pin = {
556 .gpio = GPIOB,
557 .init = {
558 .GPIO_Pin = GPIO_Pin_11,
559 .GPIO_Mode = GPIO_Mode_IPD,
560 .GPIO_Speed = GPIO_Speed_2MHz,
563 .remap = GPIO_PartialRemap2_TIM2,
566 #endif /* PIOS_INCLUDE_TIM */
568 #if defined(PIOS_INCLUDE_SERVO) && defined(PIOS_INCLUDE_TIM)
570 * Servo outputs
572 #include <pios_servo_priv.h>
574 const struct pios_servo_cfg pios_servo_main_cfg = {
575 .tim_oc_init = {
576 .TIM_OCMode = TIM_OCMode_PWM1,
577 .TIM_OutputState = TIM_OutputState_Enable,
578 .TIM_OutputNState = TIM_OutputNState_Disable,
579 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
580 .TIM_OCPolarity = TIM_OCPolarity_High,
581 .TIM_OCNPolarity = TIM_OCPolarity_High,
582 .TIM_OCIdleState = TIM_OCIdleState_Reset,
583 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
585 .channels = pios_tim_all_port_pins,
586 .num_channels = 2
589 const struct pios_servo_cfg pios_servo_flexi_cfg = {
590 .tim_oc_init = {
591 .TIM_OCMode = TIM_OCMode_PWM1,
592 .TIM_OutputState = TIM_OutputState_Enable,
593 .TIM_OutputNState = TIM_OutputNState_Disable,
594 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
595 .TIM_OCPolarity = TIM_OCPolarity_High,
596 .TIM_OCNPolarity = TIM_OCPolarity_High,
597 .TIM_OCIdleState = TIM_OCIdleState_Reset,
598 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
600 .channels = &(pios_tim_all_port_pins[2]),
601 .num_channels = 2
604 const struct pios_servo_cfg pios_servo_main_flexi_cfg = {
605 .tim_oc_init = {
606 .TIM_OCMode = TIM_OCMode_PWM1,
607 .TIM_OutputState = TIM_OutputState_Enable,
608 .TIM_OutputNState = TIM_OutputNState_Disable,
609 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
610 .TIM_OCPolarity = TIM_OCPolarity_High,
611 .TIM_OCNPolarity = TIM_OCPolarity_High,
612 .TIM_OCIdleState = TIM_OCIdleState_Reset,
613 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
615 .channels = pios_tim_all_port_pins,
616 .num_channels = 4
619 #endif /* PIOS_INCLUDE_SERVO && PIOS_INCLUDE_TIM */
622 * PPM Inputs
624 #if defined(PIOS_INCLUDE_PPM)
625 #include <pios_ppm_priv.h>
627 const struct pios_ppm_cfg pios_ppm_main_cfg = {
628 .tim_ic_init = {
629 .TIM_ICPolarity = TIM_ICPolarity_Rising,
630 .TIM_ICSelection = TIM_ICSelection_DirectTI,
631 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
632 .TIM_ICFilter = 0x0,
634 .channels = &pios_tim_main_port_ppm,
635 .num_channels = 1,
638 const struct pios_ppm_cfg pios_ppm_flexi_cfg = {
639 .tim_ic_init = {
640 .TIM_ICPolarity = TIM_ICPolarity_Rising,
641 .TIM_ICSelection = TIM_ICSelection_DirectTI,
642 .TIM_ICPrescaler = TIM_ICPSC_DIV1,
643 .TIM_ICFilter = 0x0,
645 .channels = &pios_tim_flexi_port_ppm,
646 .num_channels = 1,
649 #endif /* PIOS_INCLUDE_PPM */
652 * PPM Output
654 #if defined(PIOS_INCLUDE_PPM_OUT)
655 #include <pios_ppm_out_priv.h>
657 const struct pios_ppm_out_cfg pios_main_ppm_out_cfg = {
658 .tim_oc_init = {
659 .TIM_OCMode = TIM_OCMode_PWM1,
660 .TIM_OutputState = TIM_OutputState_Enable,
661 .TIM_OutputNState = TIM_OutputNState_Disable,
662 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
663 .TIM_OCPolarity = TIM_OCPolarity_Low,
664 .TIM_OCNPolarity = TIM_OCPolarity_Low,
665 .TIM_OCIdleState = TIM_OCIdleState_Reset,
666 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
668 .channel = &(pios_tim_all_port_pins[0]),
671 const struct pios_ppm_out_cfg pios_flexi_ppm_out_cfg = {
672 .tim_oc_init = {
673 .TIM_OCMode = TIM_OCMode_PWM1,
674 .TIM_OutputState = TIM_OutputState_Enable,
675 .TIM_OutputNState = TIM_OutputNState_Disable,
676 .TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
677 .TIM_OCPolarity = TIM_OCPolarity_Low,
678 .TIM_OCNPolarity = TIM_OCPolarity_Low,
679 .TIM_OCIdleState = TIM_OCIdleState_Reset,
680 .TIM_OCNIdleState = TIM_OCNIdleState_Reset,
682 .channel = &(pios_tim_all_port_pins[2]),
685 #endif /* PIOS_INCLUDE_PPM_OUT */
687 #if defined(PIOS_INCLUDE_USART)
689 #include <pios_usart_priv.h>
692 * SERIAL USART
694 static const struct pios_usart_cfg pios_usart_main_cfg = {
695 .regs = USART1,
696 .rx = {
697 .gpio = GPIOA,
698 .init = {
699 .GPIO_Pin = GPIO_Pin_10,
700 .GPIO_Speed = GPIO_Speed_2MHz,
701 .GPIO_Mode = GPIO_Mode_IPU,
704 .tx = {
705 .gpio = GPIOA,
706 .init = {
707 .GPIO_Pin = GPIO_Pin_9,
708 .GPIO_Speed = GPIO_Speed_2MHz,
709 .GPIO_Mode = GPIO_Mode_AF_PP,
714 static const struct pios_usart_cfg pios_usart_flexi_cfg = {
715 .regs = USART3,
716 .rx = {
717 .gpio = GPIOB,
718 .init = {
719 .GPIO_Pin = GPIO_Pin_11,
720 .GPIO_Speed = GPIO_Speed_2MHz,
721 .GPIO_Mode = GPIO_Mode_IPU,
724 .tx = {
725 .gpio = GPIOB,
726 .init = {
727 .GPIO_Pin = GPIO_Pin_10,
728 .GPIO_Speed = GPIO_Speed_2MHz,
729 .GPIO_Mode = GPIO_Mode_AF_PP,
734 #endif /* PIOS_INCLUDE_USART */
736 #if defined(PIOS_INCLUDE_COM)
738 #include <pios_com_priv.h>
740 #endif /* PIOS_INCLUDE_COM */
742 #if defined(PIOS_INCLUDE_RTC)
744 * Realtime Clock (RTC)
746 #include <pios_rtc_priv.h>
748 void PIOS_RTC_IRQ_Handler(void);
749 void RTC_IRQHandler() __attribute__((alias("PIOS_RTC_IRQ_Handler")));
750 static const struct pios_rtc_cfg pios_rtc_main_cfg = {
751 .clksrc = RCC_RTCCLKSource_HSE_Div128,
752 .prescaler = 100,
753 .irq = {
754 .init = {
755 .NVIC_IRQChannel = RTC_IRQn,
756 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
757 .NVIC_IRQChannelSubPriority = 0,
758 .NVIC_IRQChannelCmd = ENABLE,
763 void PIOS_RTC_IRQ_Handler(void)
765 PIOS_RTC_irq_handler();
768 #endif /* if defined(PIOS_INCLUDE_RTC) */
770 #if defined(PIOS_INCLUDE_RCVR)
771 #include "pios_rcvr_priv.h"
773 #endif /* PIOS_INCLUDE_RCVR */
775 #if defined(PIOS_INCLUDE_USB)
776 #include "pios_usb_priv.h"
778 static const struct pios_usb_cfg pios_usb_main_cfg = {
779 .irq = {
780 .init = {
781 .NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn,
782 .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
783 .NVIC_IRQChannelSubPriority = 0,
784 .NVIC_IRQChannelCmd = ENABLE,
787 .vsense = {
788 .gpio = GPIOA,
789 .init = {
790 .GPIO_Pin = GPIO_Pin_8,
791 .GPIO_Speed = GPIO_Speed_10MHz,
792 .GPIO_Mode = GPIO_Mode_AF_OD,
795 .vsense_active_low = false
798 const struct pios_usb_cfg *PIOS_BOARD_HW_DEFS_GetUsbCfg(__attribute__((unused)) uint32_t board_revision)
800 return &pios_usb_main_cfg;
803 #include "pios_usb_board_data_priv.h"
804 #include "pios_usb_desc_hid_cdc_priv.h"
805 #include "pios_usb_desc_hid_only_priv.h"
807 #endif /* PIOS_INCLUDE_USB */
809 #if defined(PIOS_INCLUDE_COM_MSG)
811 #include <pios_com_msg_priv.h>
813 #endif /* PIOS_INCLUDE_COM_MSG */
815 #if defined(PIOS_INCLUDE_FLASH_EEPROM)
816 #include <pios_eeprom.h>
818 const struct pios_eeprom_cfg pios_eeprom_cfg = {
819 .base_address = PIOS_FLASH_EEPROM_ADDR,
820 .max_size = PIOS_FLASH_EEPROM_LEN,
822 #endif /* PIOS_INCLUDE_FLASH_EEPROM */
824 #if defined(PIOS_INCLUDE_RFM22B)
825 #include <pios_rfm22b_priv.h>
827 #endif /* PIOS_INCLUDE_RFM22B */