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