NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
target.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #define USE_QUAD_MIXER_ONLY 0
21 #define TARGET_BOARD_IDENTIFIER "SPEV"
22 
23 #define USE_TILT 0
24 #define LED0_GPIO GPIOB
25 #define LED0_PIN Pin_8
26 #define LED0_PERIPHERAL RCC_AHBPeriph_GPIOB
27 
28 #define BEEP_GPIO GPIOC
29 #define BEEP_PIN Pin_15
30 #define BEEP_PERIPHERAL RCC_AHBPeriph_GPIOC
31 #define BEEPER_INVERTED
32 
33 #define USABLE_TIMER_CHANNEL_COUNT 12 // PPM, 8 PWM, UART3 RX/TX, LED Strip
34 
35 #define EXTI15_10_CALLBACK_HANDLER_COUNT 2 // MPU_INT, SDCardDetect
36 
37 #define USE_MPU_DATA_READY_SIGNAL
38 #define ENSURE_MPU_DATA_READY_IS_LOW
39 
40 #define USE_MAG_DATA_READY_SIGNAL
41 #define ENSURE_MAG_DATA_READY_IS_HIGH
42 
43 
44 #define GYRO
45 //#define USE_FAKE_GYRO
46 #define USE_GYRO_SPI_MPU6500
47 
48 #define ACC
49 //#define USE_FAKE_ACC
50 #define USE_ACC_SPI_MPU6500
51 
52 #define ACC_MPU6500_ALIGN CW180_DEG
53 #define GYRO_MPU6500_ALIGN CW180_DEG
54 
55 #define BARO
56 #define USE_BARO_BMP280
57 
58 #define USE_MAG 1
59 #define USE_MPU9250_MAG // Enables bypass configuration
60 #define USE_MAG_AK8963
61 //#define USE_MAG_HMC5883 // External
62 
63 #define MAG_AK8963_ALIGN CW90_DEG_FLIP
64 
65 //#define SONAR
66 #define USE_BEEPER 1
67 #define LED0
68 
69 #define USB_IO
70 
71 #define USE_VCP
72 #define USE_UART1
73 #define USE_UART2
74 #define USE_UART3
75 #define SERIAL_PORT_COUNT 4
76 
77 #ifndef UART1_GPIO
78 #define UART1_TX_PIN GPIO_Pin_9 // PA9
79 #define UART1_RX_PIN GPIO_Pin_10 // PA10
80 #define UART1_GPIO GPIOA
81 #define UART1_GPIO_AF GPIO_AF_7
82 #define UART1_TX_PINSOURCE GPIO_PinSource9
83 #define UART1_RX_PINSOURCE GPIO_PinSource10
84 #endif
85 
86 #define UART2_TX_PIN GPIO_Pin_14 // PA14 / SWCLK
87 #define UART2_RX_PIN GPIO_Pin_15 // PA15
88 #define UART2_GPIO GPIOA
89 #define UART2_GPIO_AF GPIO_AF_7
90 #define UART2_TX_PINSOURCE GPIO_PinSource14
91 #define UART2_RX_PINSOURCE GPIO_PinSource15
92 
93 #ifndef UART3_GPIO
94 #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7)
95 #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7)
96 #define UART3_GPIO_AF GPIO_AF_7
97 #define UART3_GPIO GPIOB
98 #define UART3_TX_PINSOURCE GPIO_PinSource10
99 #define UART3_RX_PINSOURCE GPIO_PinSource11
100 #endif
101 
102 #define USE_I2C
103 #define I2C_DEVICE (I2CDEV_1) // PB6/SCL, PB7/SDA
104 
105 #define USE_SPI
106 #define USE_SPI_DEVICE_1 // PB9,3,4,5 on AF5 SPI1 (MPU)
107 #define USE_SPI_DEVICE_2 // PB12,13,14,15 on AF5 SPI2 (SDCard)
108 
109 #define SPI1_GPIO GPIOB
110 #define SPI1_GPIO_PERIPHERAL RCC_AHBPeriph_GPIOB
111 #define SPI1_NSS_PIN Pin_9
112 #define SPI1_NSS_PIN_SOURCE GPIO_PinSource9
113 #define SPI1_SCK_PIN Pin_3
114 #define SPI1_SCK_PIN_SOURCE GPIO_PinSource3
115 #define SPI1_MISO_PIN Pin_4
116 #define SPI1_MISO_PIN_SOURCE GPIO_PinSource4
117 #define SPI1_MOSI_PIN Pin_5
118 #define SPI1_MOSI_PIN_SOURCE GPIO_PinSource5
119 
120 #define SPI2_GPIO GPIOB
121 #define SPI2_GPIO_PERIPHERAL RCC_AHBPeriph_GPIOB
122 #define SPI2_NSS_PIN Pin_12
123 #define SPI2_NSS_PIN_SOURCE GPIO_PinSource12
124 #define SPI2_SCK_PIN Pin_13
125 #define SPI2_SCK_PIN_SOURCE GPIO_PinSource13
126 #define SPI2_MISO_PIN Pin_14
127 #define SPI2_MISO_PIN_SOURCE GPIO_PinSource14
128 #define SPI2_MOSI_PIN Pin_15
129 #define SPI2_MOSI_PIN_SOURCE GPIO_PinSource15
130 
131 #define USE_SDCARD
132 #define USE_SDCARD_SPI2
133 
134 #define SDCARD_DETECT_INVERTED
135 
136 #define SDCARD_DETECT_PIN GPIO_Pin_14
137 #define SDCARD_DETECT_EXTI_LINE EXTI_Line14
138 #define SDCARD_DETECT_EXTI_PIN_SOURCE EXTI_PinSource14
139 #define SDCARD_DETECT_GPIO_PORT GPIOC
140 #define SDCARD_DETECT_GPIO_CLK RCC_AHBPeriph_GPIOC
141 #define SDCARD_DETECT_EXTI_PORT_SOURCE EXTI_PortSourceGPIOC
142 #define SDCARD_DETECT_EXTI_IRQn EXTI15_10_IRQn
143 
144 #define SDCARD_SPI_INSTANCE SPI2
145 #define SDCARD_SPI_CS_GPIO SPI2_GPIO
146 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
147 
148 // SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init:
149 #define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
150 // Divide to under 25MHz for normal operation:
151 #define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
152 
153 // Note, this is the same DMA channel as USART1_RX. Luckily we don't use DMA for USART Rx.
154 #define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
155 #define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC5
156 
157 #define MPU6500_CS_GPIO_CLK_PERIPHERAL SPI1_GPIO_PERIPHERAL
158 #define MPU6500_CS_GPIO SPI1_GPIO
159 #define MPU6500_CS_PIN GPIO_Pin_9
160 #define MPU6500_SPI_INSTANCE SPI1
161 
162 #define USE_ADC
163 #define BOARD_HAS_VOLTAGE_DIVIDER
164 
165 
166 #define ADC_INSTANCE ADC2
167 #define ADC_DMA_CHANNEL DMA2_Channel1
168 #define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
169 
170 #define VBAT_ADC_GPIO GPIOA
171 #define VBAT_ADC_GPIO_PIN GPIO_Pin_4
172 #define VBAT_ADC_CHANNEL ADC_Channel_1
173 
174 #define CURRENT_METER_ADC_GPIO GPIOA
175 #define CURRENT_METER_ADC_GPIO_PIN GPIO_Pin_5
176 #define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
177 
178 #define RSSI_ADC_GPIO GPIOB
179 #define RSSI_ADC_GPIO_PIN GPIO_Pin_2
180 #define RSSI_ADC_CHANNEL ADC_Channel_12
181 
182 #define LED_STRIP
183 #define LED_STRIP_TIMER TIM1
184 
185 #define USE_LED_STRIP_ON_DMA1_CHANNEL2
186 #define WS2811_GPIO GPIOA
187 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
188 #define WS2811_GPIO_AF GPIO_AF_6
189 #define WS2811_PIN GPIO_Pin_8
190 #define WS2811_PIN_SOURCE GPIO_PinSource8
191 #define WS2811_TIMER TIM1
192 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM1
193 #define WS2811_DMA_CHANNEL DMA1_Channel2
194 #define WS2811_IRQ DMA1_Channel2_IRQn
195 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC2
196 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH2_HANDLER
197 
198 #define TRANSPONDER
199 #define TRANSPONDER_GPIO GPIOA
200 #define TRANSPONDER_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
201 #define TRANSPONDER_GPIO_AF GPIO_AF_6
202 #define TRANSPONDER_PIN GPIO_Pin_8
203 #define TRANSPONDER_PIN_SOURCE GPIO_PinSource8
204 #define TRANSPONDER_TIMER TIM1
205 #define TRANSPONDER_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM1
206 #define TRANSPONDER_DMA_CHANNEL DMA1_Channel2
207 #define TRANSPONDER_IRQ DMA1_Channel2_IRQn
208 #define TRANSPONDER_DMA_TC_FLAG DMA1_FLAG_TC2
209 #define TRANSPONDER_DMA_HANDLER_IDENTIFER DMA1_CH2_HANDLER
210 
211 #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
212 #define DEFAULT_FEATURES (FEATURE_TRANSPONDER | FEATURE_RSSI_ADC | FEATURE_CURRENT_METER | FEATURE_TELEMETRY)
213 
214 #define GPS
215 #define BLACKBOX
216 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
217 #define TELEMETRY
218 #define SERIAL_RX
219 #define GTUNE
220 #define DISPLAY
221 #define USE_SERVOS
222 #define USE_CLI
223 
224 #define SPEKTRUM_BIND
225 // USART3,
226 #define BIND_PORT GPIOB
227 #define BIND_PIN Pin_11
228 
229 #define USE_SERIAL_4WAY_BLHELI_INTERFACE