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 
11 /*
12  const gpio_dev * const gpio_device; < Board pin's GPIO device
13  const timer_dev * const timer_device; < Pin's timer device, if any.
14  const adc_dev * const adc_device; < ADC device, if any.
15  uint8_t gpio_bit; < Pin's GPIO port bit.
16  uint8_t timer_channel; < Timer channel, or 0 if none.
17  uint8_t adc_channel; < Pin ADC channel, or nADC if none.
18 */
19 
20  {&gpiob, NULL, NULL, 10, NO_CH, nADC}, /* D0/PB10 0 USART3_TX/I2C2-SCL */
21  {&gpiob, NULL, NULL, 2, NO_CH, nADC}, /* D1/PB2 1*/
22  {&gpiob, NULL, NULL, 12, NO_CH, nADC}, /* D2/PB12 2 in0 on REVO */
23  {&gpiob, NULL, NULL, 13, NO_CH, nADC}, /* D3/PB13 3 in1 on REVO */
24  {&gpiob,&timer12,NULL, 14, TIMER_CH1, nADC}, /* D4/PB14 4 CH1_IN - PPMSUM */
25  {&gpiob,&timer12,NULL, 15, TIMER_CH2, nADC}, /* D5/PB15 5 CH2_IN - PPMSUM2 */
26  {&gpioc, NULL,&_adc1, 0, NO_CH, 10}, /* D6/PC0 6 SBUS invertor output */
27  {&gpioc, NULL,&_adc1, 1, NO_CH, 11}, /* D7/PC1 7 AMP */
28  {&gpioc, NULL,&_adc1, 2, NO_CH, 12}, /* D8/PC2 8 Volt/SONAR (connected to 22) */
29  {&gpioc, NULL,&_adc1, 3, NO_CH, 13}, /* D9/PC3 9 freq sense - resistor to VCC */
30  {&gpioc, NULL,&_adc1, 4, NO_CH, 14}, /* D10/PC4 10 EXTI_MPU6000 */
31  {&gpioc, NULL,&_adc1, 5, NO_CH, 15}, /* D11/PC5 1 USB_SENSE */
32  {&gpioc, &timer8,NULL, 6, TIMER_CH1, nADC}, /* D12/PC6 2 CH3_IN / UART6_TX */
33  {&gpioc, &timer8,NULL, 7, TIMER_CH2, nADC}, /* D13/PC7 3 CH4_IN / UART6_RX */
34  {&gpioc, &timer8,NULL, 8, TIMER_CH3, nADC}, /* D14/PC8 4 CH5_IN / S_scl / Servo7 */
35  {&gpioc, &timer8,NULL, 9, TIMER_CH4, nADC}, /* D15/PC9 5 CH6_IN / S_sda / Servo8 */
36  {&gpioc, NULL, NULL, 10, NO_CH, nADC}, /* D16/PC10 6 SPI3_SCLK */
37  {&gpioc, NULL, NULL, 11, NO_CH, nADC}, /* D17/PC11 7 SPI3_MISO */
38  {&gpioc, NULL, NULL, 12, NO_CH, nADC}, /* D18/PC12 8 SPI3_MOSI */
39  {&gpioc, NULL, NULL, 13, NO_CH, nADC}, /* D19/PC13 9 NOT CONNECTED */
40  {&gpioc, NULL, NULL, 14, NO_CH, nADC}, /* D20/PC14 20 NOT CONNECTED */
41  {&gpioc, NULL, NULL, 15, NO_CH, nADC}, /* D21/PC15 1 NOT CONNECTED */
42  {&gpioa, &timer1,NULL, 8, TIMER_CH1, nADC}, /* D22/PA8 2 Volt/Sonar double (connected to 8) */
43  {&gpioa, &timer1,NULL, 9, TIMER_CH2, nADC}, /* D23/PA9 3 USART1_TX */
44  {&gpioa, &timer1,NULL, 10, TIMER_CH3, nADC}, /* D24/PA10 4 USART1_RX */
45  {&gpiob, NULL, NULL, 9, TIMER_CH4, nADC}, /* D25/PB9 5 I2C1_SDA */
46  {&gpiod, NULL, NULL, 2, NO_CH, nADC}, /* D26/PD2 6 EXTI_RFM22B / UART5_RX */
47  {&gpiod, NULL, NULL, 3, NO_CH, nADC}, /* D27/PD3 7*/
48  {&gpiod, NULL, NULL, 6, NO_CH, nADC}, /* D28/PD6 8*/
49  {&gpiog, NULL, NULL, 11, NO_CH, nADC}, /* D29/PG11 9*/
50  {&gpiog, NULL, NULL, 12, NO_CH, nADC}, /* D30/PG12 30*/
51  {&gpiog, NULL, NULL, 13, NO_CH, nADC}, /* D31/PG13 1*/
52  {&gpiog, NULL, NULL, 14, NO_CH, nADC}, /* D32/PG14 2*/
53  {&gpiog, NULL, NULL, 8, NO_CH, nADC}, /* D33/PG8 3*/
54  {&gpiog, NULL, NULL, 7, NO_CH, nADC}, /* D34/PG7 4*/
55  {&gpiog, NULL, NULL, 6, NO_CH, nADC}, /* D35/PG6 5*/
56  {&gpiob, &timer3,NULL, 5, TIMER_CH2, nADC}, /* D36/PB5 6 LED_BLUE */
57  {&gpiob, &timer4,NULL, 6, TIMER_CH1, nADC}, /* D37/PB6 7 LED_YELLOW - OPTIONAL, not connected */
58  {&gpiob, &timer4,NULL, 7, TIMER_CH2, nADC}, /* D38/PB7 8 DRDY_HMC5883 */
59  {&gpiof, NULL,&_adc3, 6, NO_CH, 4}, /* D39/PF6 9*/
60  {&gpiof, NULL,&_adc3, 7, NO_CH, 5}, /* D40/PF7 40*/
61  {&gpiof, NULL,&_adc3, 8, NO_CH, 6}, /* D41/PF8 1*/
62  {&gpiof, NULL,&_adc3, 9, NO_CH, 7}, /* D42/PF9 2*/
63  {&gpiof, NULL,&_adc3,10, NO_CH, 8}, /* D43/PF10 3*/
64  {&gpiof, NULL, NULL, 11, NO_CH, nADC}, /* D44/PF11 4*/
65  {&gpiob, &timer3,&_adc1,1, TIMER_CH4, 9}, /* D45/PB1 5 SERVO2 */
66  {&gpiob, &timer3,&_adc1,0, TIMER_CH3, 8}, /* D46/PB0 6 SERVO1 */
67  {&gpioa, &timer2,&_adc1,0, TIMER_CH1, 0}, /* D47/PA0 7 SERVO6 / UART4_TX Also can be mapped to Timer5 */
68  {&gpioa, &timer2,&_adc1,1, TIMER_CH2, 1}, /* D48/PA1 8 SERVO5 / UART4_RX */
69  {&gpioa, &timer2,&_adc1,2, TIMER_CH3, 2}, /* D49/PA2 9 SERVO4 */
70  {&gpioa, &timer2,&_adc1,3, TIMER_CH4, 3}, /* D50/PA3 50 SERVO3 */
71  {&gpioa, NULL, &_adc1,4, NO_CH, 4}, /* D51/PA4 1 CS_MPU6000 */
72  {&gpioa, NULL, &_adc1,5, NO_CH, 5}, /* D52/PA5 2 SPI1_CLK */
73  {&gpioa, &timer3,&_adc1,6, TIMER_CH1, 6}, /* D53/PA6 3 SPI1_MISO */
74  {&gpioa, &timer3,&_adc1,7, TIMER_CH2, 7}, /* D54/PA7 4 SPI1_MOSI */
75  {&gpiof, NULL, NULL, 0, NO_CH, nADC}, /* D55/PF0 5*/
76  {&gpiod, NULL, NULL, 11, NO_CH, nADC}, /* D56/PD11 6*/
77  {&gpiod, &timer4,NULL, 14, TIMER_CH3, nADC}, /* D57/PD14 7*/
78  {&gpiof, NULL, NULL, 1, NO_CH, nADC}, /* D58/PF1 8*/
79  {&gpiod, &timer4,NULL, 12, TIMER_CH1, nADC}, /* D59/PD12 9*/
80  {&gpiod, &timer4,NULL, 15, TIMER_CH4, nADC}, /* D60/PD15 60*/
81  {&gpiof, NULL, NULL, 2, NO_CH, nADC}, /* D61/PF2 1*/
82  {&gpiod, &timer4,NULL, 13, TIMER_CH2, nADC}, /* D62/PD13 2*/
83  {&gpiod, NULL, NULL, 0, NO_CH, nADC}, /* D63/PD0 3*/
84  {&gpiof, NULL, NULL, 3, NO_CH, nADC}, /* D64/PF3 4*/
85  {&gpioe, NULL, NULL, 3, NO_CH, nADC}, /* D65/PE3 5*/
86  {&gpiod, NULL, NULL, 1, NO_CH, nADC}, /* D66/PD1 6*/
87  {&gpiof, NULL, NULL, 4, NO_CH, nADC}, /* D67/PF4 7*/
88  {&gpioe, NULL, NULL, 4, NO_CH, nADC}, /* D68/PE4 8*/
89  {&gpioe, NULL, NULL, 7, NO_CH, nADC}, /* D69/PE7 9*/
90  {&gpiof, NULL, NULL, 5, NO_CH, nADC}, /* D70/PF5 70*/
91  {&gpioe, NULL, NULL, 5, NO_CH, nADC}, /* D71/PE5 1*/
92  {&gpioe, NULL, NULL, 8, NO_CH, nADC}, /* D72/PE8 2*/
93  {&gpiof, NULL, NULL, 12, NO_CH, nADC}, /* D73/PF12 3*/
94  {&gpioe, NULL, NULL, 6, NO_CH, nADC}, /* D74/PE6 4*/
95  {&gpioe, &timer1,NULL, 9, TIMER_CH1, nADC}, /* D75/PE9 */
96  {&gpiof, NULL, NULL, 13, NO_CH, nADC}, /* D76/PF13 6*/
97  {&gpioe, NULL, NULL, 10, NO_CH, nADC}, /* D77/PE10 7*/
98  {&gpiof, NULL, NULL, 14, NO_CH, nADC}, /* D78/PF14 8*/
99  {&gpiog, NULL, NULL, 9, NO_CH, nADC}, /* D79/PG9 9*/
100  {&gpioe, &timer1,NULL, 11, TIMER_CH2, nADC}, /* D80/PE11 */
101  {&gpiof, NULL, NULL, 15, NO_CH, nADC}, /* D81/PF15 1*/
102  {&gpiog, NULL, NULL, 10, NO_CH, nADC}, /* D82/PG10 2*/
103  {&gpioe, NULL, NULL, 12, NO_CH, nADC}, /* D83/PE12 3*/
104  {&gpiog, NULL, NULL, 0, NO_CH, nADC}, /* D84/PG0 4*/
105  {&gpiod, NULL, NULL, 5, NO_CH, nADC}, /* D85/PD5 5*/
106  {&gpioe, &timer1,NULL, 13, TIMER_CH3, nADC}, /* D86/PE13 */
107  {&gpiog, NULL, NULL, 1, NO_CH, nADC}, /* D87/PG1 7*/
108  {&gpiod, NULL, NULL, 4, NO_CH, nADC}, /* D88/PD4 8*/
109  {&gpioe, &timer1,NULL, 14, TIMER_CH4, nADC}, /* D89/PE14 */
110  {&gpiog, NULL, NULL, 2, NO_CH, nADC}, /* D90/PG2 90*/
111  {&gpioe, NULL, NULL, 1, NO_CH, nADC}, /* D91/PE1 1*/
112  {&gpioe, NULL, NULL, 15, NO_CH, nADC}, /* D92/PE15 2*/
113  {&gpiog, NULL, NULL, 3, NO_CH, nADC}, /* D93/PG3 3*/
114  {&gpioe, NULL, NULL, 0, NO_CH, nADC}, /* D94/PE0 4*/
115  {&gpiod, NULL, NULL, 8, NO_CH, nADC}, /* D95/PD8 5*/
116  {&gpiog, NULL, NULL, 4, NO_CH, nADC}, /* D96/PG4 6*/
117  {&gpiod, NULL, NULL, 9, NO_CH, nADC}, /* D97/PD9 7*/
118  {&gpiog, NULL, NULL, 5, NO_CH, nADC}, /* D98/PG5 8*/
119  {&gpiod, NULL, NULL, 10, NO_CH, nADC}, /* D99/PD10 9*/
120  {&gpiob, NULL, NULL, 11, NO_CH, nADC}, /* D100/PB11 100 USART3_RX/I2C2-SDA */
121  {&gpiob, NULL, NULL, 8, NO_CH, nADC}, /* D101/PB8 I2C1_SCL */
122  {&gpioe, NULL, NULL, 2, NO_CH, nADC}, /* D102/PE2 */
123  {&gpioa, NULL, NULL, 15, NO_CH, nADC}, /* D103/PA15 BOARD_SPEKTRUM_PWR_PIN */
124  {&gpiob, NULL, NULL, 3, NO_CH, nADC}, /* D104/PB3 CS_FLASH */
125  {&gpiob, NULL, NULL, 4, NO_CH, nADC}, /* D105/PB4 LED_RED */
126  {&gpioa, NULL, NULL, 13, NO_CH, nADC}, /* D106/PA13 SWDIO */
127  {&gpioa, NULL, NULL, 14, NO_CH, nADC}, /* D107/PA14 SWCLK */
128  {&gpioa, NULL, NULL, 11, NO_CH, nADC}, /* D108/PA11 - USB D- */
129 
130 };
131 
132 
133 
134 extern const struct TIM_Channel PWM_Channels[] __FLASH__ = {
135  //CH1 and CH2 also for PPMSUM / SBUS / DSM
136  { // 0 RC_IN1
137  .pin = 4,
138  },
139  { // 1 RC_IN2
140  .pin = 5,
141  },
142  { // 2 RC_IN3
143  .pin = 12,
144  },
145  { // 3 RC_IN4
146  .pin = 13,
147  },
148  { // 4 RC_IN5
149  .pin = 14,
150  },
151  { // 5 RC_IN6 - also used for SoftUART
152  .pin = 15,
153  },
154 };
155 
156 
157 extern const SPIDesc spi_device_table[] = { // different SPI tables per board subtype
158 // name device bus mode cs_pin speed_low speed_high dma priority assert_dly release_dly
160  { BOARD_DATAFLASH_NAME, _SPI3, 3, SPI_MODE_3, 255 /* caller controls CS */, SPI_1_125MHZ, SPI_18MHZ, SPI_TRANSFER_DMA, DMA_Priority_Medium, 0, 0 },
161 };
162 
163 extern const uint8_t F4Light_SPI_DEVICE_NUM_DEVICES = ARRAY_SIZE(spi_device_table);
164 
165 void boardInit(void) {
166 
167 /* we don't use RFM22! this pins are used for other needs so will be initialized in respective places
168  const stm32_pin_info &pp = PIN_MAP[BOARD_RFM22B_CS_PIN];
169 
170  // Init RFM22B SC pin and set to HI
171  gpio_set_mode( pp.gpio_device, pp.gpio_bit, GPIO_OUTPUT_PP);
172  gpio_write_bit(pp.gpio_device, pp.gpio_bit, 1);
173 
174  // Init RFM22B EXT_INT pin
175  gpio_set_mode(PIN_MAP[BOARD_RFM22B_INT_PIN].gpio_device, PIN_MAP[BOARD_RFM22B_INT_PIN].gpio_bit, GPIO_INPUT_PU);
176 */
177 
178 #ifdef BOARD_HMC5883_DRDY_PIN
179  { // Init HMC5883 DRDY EXT_INT pin - but it not used by driver
182  }
183 #endif
184 
185 #ifdef BOARD_MPU6000_DRDY_PIN
186  { // Init MPU6000 DRDY pin - but it not used by driver
189  }
190 #endif
191 
192 #ifdef BOARD_SBUS_INVERTER
193  { // it is not necessary because of 10K resistor to ground
196  gpio_write_bit(pp.gpio_device, pp.gpio_bit, 0); // not inverted
197  }
198 #endif
199 
200 }
201 
202 
203 #endif
const adc_dev const _adc3
Definition: adc.c:28
#define timer12
Definition: timer.h:605
Definition: spi.h:55
const gpio_dev gpiof
Definition: gpio_hal.c:57
#define BOARD_SBUS_INVERTER
Definition: board.h:164
#define BOARD_INS_MPU60x0_NAME
Definition: board.h:132
#define BOARD_HMC5883_DRDY_PIN
Definition: board.h:140
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
const gpio_dev gpioe
Definition: gpio_hal.c:49
#define timer1
Definition: timer.h:594
#define BOARD_DATAFLASH_NAME
Definition: board.h:137
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
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
uint8_t gpio_bit
Definition: boards.h:92
Stores STM32-specific information related to a given Maple pin.
Definition: boards.h:88
const gpio_dev *const gpio_device
Definition: boards.h:89
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