APM:Libraries
board.cpp
Go to the documentation of this file.
1 #ifndef BOARD_STM32V1F4
2 #define BOARD_STM32V1F4
3 
4 #include <boards.h>
5 #include "../../SPIDevice.h"
6 #include <AP_Common/AP_Common.h>
7 
8 using namespace F4Light;
9 
10 /*
11  LQFP64
12 
13  PA0-15
14  PB0-15
15  PC0-12
16  PD2
17 
18 
19 */
20 
22 
23  /* Top header */
24 /*
25  const gpio_dev * const gpio_device; < Maple pin's GPIO device
26  const timer_dev * const timer_device; < Pin's timer device, if any.
27  const adc_dev * const adc_device; < ADC device, if any.
28  uint8_t gpio_bit; < Pin's GPIO port bit.
29  uint8_t timer_channel; < Timer channel, or 0 if none.
30  uint8_t adc_channel; < Pin ADC channel, or nADC if none.
31 */
32 
33  {&gpiob, NULL, NULL, 10, NO_CH, nADC}, /* D0/PB10 0 MAX7456_SPI_CS_PIN */
34  {&gpiob, NULL, NULL, 2, NO_CH, nADC}, /* D1/PB2 1 (BOOT1) */
35  {&gpiob, NULL, NULL, 12, NO_CH, nADC}, /* D2/PB12 2 SDCARD CS pin */
36  {&gpiob, NULL, NULL, 13, NO_CH, nADC}, /* D3/PB13 3 SPI2_SCK */
37  {&gpiob,&timer12,NULL, 14, TIMER_CH1, nADC}, /* D4/PB14 4 SPI2_MOSI */
38  {&gpiob,&timer12,NULL, 15, TIMER_CH2, nADC}, /* D5/PB15 5 SPI2_MISO */
39  {&gpioc, NULL,&_adc1, 0, NO_CH, 10}, /* D6/PC0 6 */
40  {&gpioc, NULL,&_adc1, 1, NO_CH, 11}, /* D7/PC1 7 SD CS */
41  {&gpioc, NULL,&_adc1, 2, NO_CH, 12}, /* D8/PC2 8 CS_MPU6000 */
42  {&gpioc, NULL,&_adc1, 3, NO_CH, 13}, /* D9/PC3 9 EXTI_MPU6000 */
43  {&gpioc, NULL,&_adc1, 4, NO_CH, 14}, /* D10/PC4 10 Current */
44  {&gpioc, NULL,&_adc1, 5, NO_CH, 15}, /* D11/PC5 1 Vbat */
45  {&gpioc, &timer8,NULL, 6, TIMER_CH1, nADC}, /* D12/PC6 2 SERVO_1 */
46  {&gpioc, &timer8,NULL, 7, TIMER_CH2, nADC}, /* D13/PC7 3 SERVO_2 */
47  {&gpioc, &timer8,NULL, 8, TIMER_CH3, nADC}, /* D14/PC8 4 SERVO_3 */
48  {&gpioc, &timer8,NULL, 9, TIMER_CH4, nADC}, /* D15/PC9 5 SERVO_4 */
49  {&gpioc, NULL, NULL, 10, NO_CH, nADC}, /* D16/PC10 6 UART3 RX */
50  {&gpioc, NULL, NULL, 11, NO_CH, nADC}, /* D17/PC11 7 UART3 TX */
51  {&gpioc, NULL, NULL, 12, NO_CH, nADC}, /* D18/PC12 8 UART5_TX */
52  {&gpioc, NULL, NULL, 13, NO_CH, nADC}, /* D19/PC13 9 Buzzer */
53  {&gpioc, NULL, NULL, 14, NO_CH, nADC}, /* D20/PC14 20 n/a */
54  {&gpioc, NULL, NULL, 15, NO_CH, nADC}, /* D21/PC15 1 n/a */
55  {&gpioa, &timer1,NULL, 8, TIMER_CH1, nADC}, /* D22/PA8 2 SERVO_6 */
56  {&gpioa, &timer1,NULL, 9, TIMER_CH2, nADC}, /* D23/PA9 3 USART1_TX */
57  {&gpioa, &timer1,NULL, 10, TIMER_CH3, nADC}, /* D24/PA10 4 USART1_RX */
58  {&gpiob, &timer4,NULL, 9, TIMER_CH4, nADC}, /* D25/PB9 5 LED */
59  {&gpiod, NULL, NULL, 2, NO_CH, nADC}, /* D26/PD2 6 UART5_RX */
60  {&gpiod, NULL, NULL, 3, NO_CH, nADC}, /* D27/PD3 7 n/a */
61  {&gpiod, NULL, NULL, 6, NO_CH, nADC}, /* D28/PD6 8 n/a */
62  {&gpiog, NULL, NULL, 11, NO_CH, nADC}, /* D29/PG11 9*/
63  {&gpiog, NULL, NULL, 12, NO_CH, nADC}, /* D30/PG12 30*/
64  {&gpiog, NULL, NULL, 13, NO_CH, nADC}, /* D31/PG13 1*/
65  {&gpiog, NULL, NULL, 14, NO_CH, nADC}, /* D32/PG14 2*/
66  {&gpiog, NULL, NULL, 8, NO_CH, nADC}, /* D33/PG8 3*/
67  {&gpiog, NULL, NULL, 7, NO_CH, nADC}, /* D34/PG7 4*/
68  {&gpiog, NULL, NULL, 6, NO_CH, nADC}, /* D35/PG6 5*/
69  {&gpiob, &timer3,NULL, 5, TIMER_CH2, nADC}, /* D36/PB5 6 SPI3 MOSI */
70  {&gpiob, &timer4,NULL, 6, TIMER_CH1, nADC}, /* D37/PB6 7 SCL pad */
71  {&gpiob, &timer4,NULL, 7, TIMER_CH2, nADC}, /* D38/PB7 8 SDA pad */
72  {&gpiof, NULL,&_adc3, 6, NO_CH, 4}, /* D39/PF6 9*/
73  {&gpiof, NULL,&_adc3, 7, NO_CH, 5}, /* D40/PF7 40*/
74  {&gpiof, NULL,&_adc3, 8, NO_CH, 6}, /* D41/PF8 1*/
75  {&gpiof, NULL,&_adc3, 9, NO_CH, 7}, /* D42/PF9 2*/
76  {&gpiof, NULL,&_adc3,10, NO_CH, 8}, /* D43/PF10 3*/
77  {&gpiof, NULL, NULL, 11, NO_CH, nADC}, /* D44/PF11 4*/
78  {&gpiob, &timer3,&_adc1,1, TIMER_CH4, 9}, /* D45/PB1 5 RSSI */
79  {&gpiob, &timer3,&_adc1,0, TIMER_CH3, 8}, /* D46/PB0 6 */
80  {&gpioa, &timer2,&_adc1,0, TIMER_CH1, 0}, /* D47/PA0 7 UART4 TX (wkup)*/
81  {&gpioa, &timer2,&_adc1,1, TIMER_CH2, 1}, /* D48/PA1 8 UART4_RX */
82  {&gpioa, &timer2,&_adc1,2, TIMER_CH3, 2}, /* D49/PA2 9 PPM_IN 2 */
83  {&gpioa, &timer2,&_adc1,3, TIMER_CH4, 3}, /* D50/PA3 50 PPM_IN 1 */
84  {&gpioa, NULL, &_adc1,4, NO_CH, 4}, /* D51/PA4 1 */
85  {&gpioa, NULL, &_adc1,5, NO_CH, 5}, /* D52/PA5 2 SPI1_CLK */
86  {&gpioa, &timer3,&_adc1,6, TIMER_CH1, 6}, /* D53/PA6 3 SPI1_MISO */
87  {&gpioa, &timer3,&_adc1,7, TIMER_CH2, 7}, /* D54/PA7 4 SPI1_MOSI */
88  {&gpiof, NULL, NULL, 0, NO_CH, nADC}, /* D55/PF0 5*/
89  {&gpiod, NULL, NULL, 11, NO_CH, nADC}, /* D56/PD11 6*/
90  {&gpiod, &timer4,NULL, 14, TIMER_CH3, nADC}, /* D57/PD14 7*/
91  {&gpiof, NULL, NULL, 1, NO_CH, nADC}, /* D58/PF1 8*/
92  {&gpiod, &timer4,NULL, 12, TIMER_CH1, nADC}, /* D59/PD12 9*/
93  {&gpiod, &timer4,NULL, 15, TIMER_CH4, nADC}, /* D60/PD15 60*/
94  {&gpiof, NULL, NULL, 2, NO_CH, nADC}, /* D61/PF2 1*/
95  {&gpiod, &timer4,NULL, 13, TIMER_CH2, nADC}, /* D62/PD13 2*/
96  {&gpiod, NULL, NULL, 0, NO_CH, nADC}, /* D63/PD0 3*/
97  {&gpiof, NULL, NULL, 3, NO_CH, nADC}, /* D64/PF3 4*/
98  {&gpioe, NULL, NULL, 3, NO_CH, nADC}, /* D65/PE3 5*/
99  {&gpiod, NULL, NULL, 1, NO_CH, nADC}, /* D66/PD1 6*/
100  {&gpiof, NULL, NULL, 4, NO_CH, nADC}, /* D67/PF4 7*/
101  {&gpioe, NULL, NULL, 4, NO_CH, nADC}, /* D68/PE4 8*/
102  {&gpioe, NULL, NULL, 7, NO_CH, nADC}, /* D69/PE7 9*/
103  {&gpiof, NULL, NULL, 5, NO_CH, nADC}, /* D70/PF5 70*/
104  {&gpioe, NULL, NULL, 5, NO_CH, nADC}, /* D71/PE5 1*/
105  {&gpioe, NULL, NULL, 8, NO_CH, nADC}, /* D72/PE8 2*/
106  {&gpiof, NULL, NULL, 12, NO_CH, nADC}, /* D73/PF12 3*/
107  {&gpioe, NULL, NULL, 6, NO_CH, nADC}, /* D74/PE6 4*/
108  {&gpioe, &timer1,NULL, 9, TIMER_CH1, nADC}, /* D75/PE9 */
109  {&gpiof, NULL, NULL, 13, NO_CH, nADC}, /* D76/PF13 6*/
110  {&gpioe, NULL, NULL, 10, NO_CH, nADC}, /* D77/PE10 7*/
111  {&gpiof, NULL, NULL, 14, NO_CH, nADC}, /* D78/PF14 8*/
112  {&gpiog, NULL, NULL, 9, NO_CH, nADC}, /* D79/PG9 9*/
113  {&gpioe, &timer1,NULL, 11, TIMER_CH2, nADC}, /* D80/PE11 */
114  {&gpiof, NULL, NULL, 15, NO_CH, nADC}, /* D81/PF15 1*/
115  {&gpiog, NULL, NULL, 10, NO_CH, nADC}, /* D82/PG10 2*/
116  {&gpioe, NULL, NULL, 12, NO_CH, nADC}, /* D83/PE12 3*/
117  {&gpiog, NULL, NULL, 0, NO_CH, nADC}, /* D84/PG0 4*/
118  {&gpiod, NULL, NULL, 5, NO_CH, nADC}, /* D85/PD5 5*/
119  {&gpioe, &timer1,NULL, 13, TIMER_CH3, nADC}, /* D86/PE13 */
120  {&gpiog, NULL, NULL, 1, NO_CH, nADC}, /* D87/PG1 7*/
121  {&gpiod, NULL, NULL, 4, NO_CH, nADC}, /* D88/PD4 8*/
122  {&gpioe, &timer1,NULL, 14, TIMER_CH4, nADC}, /* D89/PE14 */
123  {&gpiog, NULL, NULL, 2, NO_CH, nADC}, /* D90/PG2 90*/
124  {&gpioe, NULL, NULL, 1, NO_CH, nADC}, /* D91/PE1 1*/
125  {&gpioe, NULL, NULL, 15, NO_CH, nADC}, /* D92/PE15 2*/
126  {&gpiog, NULL, NULL, 3, NO_CH, nADC}, /* D93/PG3 3*/
127  {&gpioe, NULL, NULL, 0, NO_CH, nADC}, /* D94/PE0 4*/
128  {&gpiod, NULL, NULL, 8, NO_CH, nADC}, /* D95/PD8 5*/
129  {&gpiog, NULL, NULL, 4, NO_CH, nADC}, /* D96/PG4 6*/
130  {&gpiod, NULL, NULL, 9, NO_CH, nADC}, /* D97/PD9 7*/
131  {&gpiog, NULL, NULL, 5, NO_CH, nADC}, /* D98/PG5 8*/
132  {&gpiod, NULL, NULL, 10, NO_CH, nADC}, /* D99/PD10 9*/
133  {&gpiob, NULL, NULL, 11, NO_CH, nADC}, /* D100/PB11 100 */
134  {&gpiob, &timer4,NULL, 8, TIMER_CH3, nADC}, /* D101/PB8 */
135  {&gpioe, NULL, NULL, 2, NO_CH, nADC}, /* D102/PE2 */
136  {&gpioa, &timer2,NULL, 15, TIMER_CH1, nADC}, /* D103/PA15 SERVO_5 */
137  {&gpiob, NULL, NULL, 3, NO_CH, nADC}, /* D104/PB3 SPI3 SCK */
138  {&gpiob, NULL, NULL, 4, NO_CH, nADC}, /* D105/PB4 SPI3 MISO */
139  {&gpioa, NULL, NULL, 13, NO_CH, nADC}, /* D106/PA13 SWDIO */
140  {&gpioa, NULL, NULL, 14, NO_CH, nADC}, /* D107/PA14 SWCLK LED */
141  {&gpioa, NULL, NULL, 11, NO_CH, nADC}, /* D108/PA11 - USB D- */
142 
143 };
144 
145 
146 extern const struct TIM_Channel PWM_Channels[] __FLASH__ = {
147 //CH1 and CH2 also for PPMSUM / SBUS / DSM
148  { // 0 RC_IN1
149  .pin = PA3, // UART2 RX
150  },
151  { // 1 RC_IN2
152  .pin = PA2, // UART2 TX
153  },
154 };
155 
156 
157 /*
158  DMA modes:
159 
160 0 - disable
161 1 - enable on large transfers
162 2 - enable alaways
163 
164 */
165 extern const SPIDesc spi_device_table[] = { // different SPI tables per board subtype
166 // name device bus mode cs_pin speed_low speed_high dma priority
170 // { BOARD_DATAFLASH_NAME, _SPI3, 3, SPI_MODE_3, 255/*device controls CS*/,SPI_1_125MHZ, SPI_18MHZ, SPI_TRANSFER_DMA, DMA_Priority_High, 1, 1 },
171 };
172 
173 extern const uint8_t F4Light_SPI_DEVICE_NUM_DEVICES = ARRAY_SIZE(spi_device_table);
174 
175 void boardInit(void) {
176 
177 
178 #ifdef BOARD_HMC5883_DRDY_PIN
179  // Init HMC5883 DRDY EXT_INT pin - but it not used by driver
181 #endif
182 
183 #ifdef BOARD_MPU6000_DRDY_PIN
184  // Init MPU6000 DRDY pin - but it not used by driver
186 #endif
187 
188 #ifdef BOARD_SBUS_INVERTER
189 // it is not necessary because of 10K resistor to ground
191  gpio_write_bit(PIN_MAP[BOARD_SBUS_INVERTER].gpio_device, PIN_MAP[BOARD_SBUS_INVERTER].gpio_bit, 0); // not inverted
192 #endif
193 
194 }
195 
196 
197 #endif
const adc_dev const _adc3
Definition: adc.c:28
#define timer12
Definition: timer.h:605
Definition: spi.h:55
const spi_dev *const _SPI2
Definition: spi.c:43
const gpio_dev gpiof
Definition: gpio_hal.c:57
#define BOARD_SBUS_INVERTER
Definition: board.h:164
Definition: boards.h:222
#define DMA_Priority_Low
Definition: dma.h:162
#define BOARD_INS_MPU60x0_NAME
Definition: board.h:132
#define BOARD_HMC5883_DRDY_PIN
Definition: board.h:140
Definition: boards.h:223
const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS]
const stm32_pin_info PIN_MAP [BOARD_NR_GPIO_PINS] __FLASH__
Definition: board.cpp:135
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
void gpio_set_mode(const gpio_dev *const dev, uint8_t pin, gpio_pin_mode mode)
Definition: gpio_hal.c:125
const adc_dev _adc1
Definition: adc.c:16
const gpio_dev gpioa
Definition: gpio_hal.c:17
const SPIDesc spi_device_table[]
const spi_dev *const _SPI3
Definition: spi.c:54
#define BOARD_MPU6000_CS_PIN
Definition: board.h:69
#define timer2
Definition: timer.h:595
const gpio_dev gpiob
Definition: gpio_hal.c:25
#define nADC
Definition: hal_types.h:70
#define BOARD_SDCARD_NAME
Definition: board.h:136
const gpio_dev gpioe
Definition: gpio_hal.c:49
#define timer1
Definition: timer.h:594
Definition: spi.h:61
#define DMA_Priority_Medium
Definition: dma.h:163
#define ARRAY_SIZE(_arr)
Definition: AP_Common.h:80
#define BOARD_NR_GPIO_PINS
Definition: board.h:96
#define NULL
Definition: hal_types.h:59
#define DMA_Priority_VeryHigh
Definition: dma.h:165
Board-specific pin information.
Common definitions and utility routines for the ArduPilot libraries.
#define timer3
Definition: timer.h:596
void boardInit(void)
Board-specific initialization code.
Definition: board.cpp:160
#define timer4
Definition: timer.h:597
#define BOARD_OSD_NAME
Definition: board.h:146
const gpio_dev gpioc
Definition: gpio_hal.c:33
const spi_dev *const _SPI1
Definition: spi.c:32
Definition: timer.h:442
#define timer8
Definition: timer.h:601
const gpio_dev gpiod
Definition: gpio_hal.c:41
const uint8_t F4Light_SPI_DEVICE_NUM_DEVICES
const struct TIM_Channel PWM_Channels[]
Definition: board.cpp:135
Stores STM32-specific information related to a given Maple pin.
Definition: boards.h:88
#define BOARD_OSD_CS_PIN
Definition: board.h:147
const gpio_dev gpiog
Definition: gpio_hal.c:65
static INLINE void gpio_write_bit(const gpio_dev *const dev, uint8_t pin, uint8_t val)
Definition: gpio_hal.h:115
#define BOARD_MPU6000_DRDY_PIN
Definition: board.h:70