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 "SRFM"
22 
23 #define USE_TILT 0
24 // early prototype had slightly different pin mappings.
25 //#define SPRACINGF3MINI_MKII_REVA
26 
27 #define LED0_GPIO GPIOB
28 #define LED0_PIN Pin_3
29 #define LED0_PERIPHERAL RCC_AHBPeriph_GPIOB
30 
31 #define BEEP_GPIO GPIOC
32 #define BEEP_PIN Pin_15
33 #define BEEP_PERIPHERAL RCC_AHBPeriph_GPIOC
34 #define BEEPER_INVERTED
35 
36 #define USABLE_TIMER_CHANNEL_COUNT 12 // 8 Outputs; PPM; LED Strip; 2 additional PWM pins also on UART3 RX/TX pins.
37 
38 #define EXTI15_10_CALLBACK_HANDLER_COUNT 2 // MPU_INT, SDCardDetect
39 
40 #define USE_MPU_DATA_READY_SIGNAL
41 #define ENSURE_MPU_DATA_READY_IS_LOW
42 
43 #define USE_MAG_DATA_READY_SIGNAL
44 #define ENSURE_MAG_DATA_READY_IS_HIGH
45 
46 
47 #define GYRO
48 //#define USE_FAKE_GYRO
49 #define USE_GYRO_MPU6500
50 
51 #define ACC
52 //#define USE_FAKE_ACC
53 #define USE_ACC_MPU6500
54 
55 #define ACC_MPU6500_ALIGN CW180_DEG
56 #define GYRO_MPU6500_ALIGN CW180_DEG
57 
58 #define BARO
59 #define USE_BARO_BMP280
60 
61 #define USE_MAG 1
62 #define USE_MPU9250_MAG // Enables bypass configuration
63 #define USE_MAG_AK8963
64 #define USE_MAG_HMC5883 // External
65 
66 #define MAG_AK8963_ALIGN CW90_DEG_FLIP
67 
68 #define USE_BEEPER 1
69 #define LED0
70 
71 #define SONAR
72 #define SONAR_TRIGGER_PIN Pin_0 // RC_CH7 (PB0) - only 3.3v ( add a 1K Ohms resistor )
73 #define SONAR_TRIGGER_GPIO GPIOB
74 #define SONAR_ECHO_PIN Pin_1 // RC_CH8 (PB1) - only 3.3v ( add a 1K Ohms resistor )
75 #define SONAR_ECHO_GPIO GPIOB
76 #define SONAR_EXTI_LINE EXTI_Line1
77 #define SONAR_EXTI_PIN_SOURCE EXTI_PinSource1
78 #define SONAR_EXTI_IRQN EXTI1_IRQn
79 
80 #define USB_IO
81 #define USB_CABLE_DETECTION
82 
83 #define USB_DETECT_PIN GPIO_Pin_5
84 #define USB_DETECT_GPIO_PORT GPIOB
85 #define USB_DETECT_GPIO_CLK RCC_AHBPeriph_GPIOC
86 
87 #define USE_VCP
88 #define USE_UART1
89 #define USE_UART2
90 #define USE_UART3
91 #define USE_SOFTSERIAL1
92 #define SERIAL_PORT_COUNT 5
93 
94 #ifndef UART1_GPIO
95 #define UART1_TX_PIN GPIO_Pin_9 // PA9
96 #define UART1_RX_PIN GPIO_Pin_10 // PA10
97 #define UART1_GPIO GPIOA
98 #define UART1_GPIO_AF GPIO_AF_7
99 #define UART1_TX_PINSOURCE GPIO_PinSource9
100 #define UART1_RX_PINSOURCE GPIO_PinSource10
101 #endif
102 
103 #define UART2_TX_PIN GPIO_Pin_14 // PA14 / SWCLK
104 #define UART2_RX_PIN GPIO_Pin_15 // PA15
105 #define UART2_GPIO GPIOA
106 #define UART2_GPIO_AF GPIO_AF_7
107 #define UART2_TX_PINSOURCE GPIO_PinSource14
108 #define UART2_RX_PINSOURCE GPIO_PinSource15
109 
110 #ifndef UART3_GPIO
111 #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7)
112 #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7)
113 #define UART3_GPIO_AF GPIO_AF_7
114 #define UART3_GPIO GPIOB
115 #define UART3_TX_PINSOURCE GPIO_PinSource10
116 #define UART3_RX_PINSOURCE GPIO_PinSource11
117 #endif
118 
119 #define SOFTSERIAL_1_TIMER TIM2
120 #define SOFTSERIAL_1_TIMER_RX_HARDWARE 9 // PA0
121 #define SOFTSERIAL_1_TIMER_TX_HARDWARE 10 // PA1
122 
123 #define USE_I2C
124 #define I2C_DEVICE (I2CDEV_1) // PB6/SCL, PB7/SDA
125 
126 #define USE_SPI
127 #define USE_SPI_DEVICE_2 // PB12,13,14,15 on AF5
128 
129 #define SPI2_GPIO GPIOB
130 #define SPI2_GPIO_PERIPHERAL RCC_AHBPeriph_GPIOB
131 #define SPI2_NSS_PIN Pin_12
132 #define SPI2_NSS_PIN_SOURCE GPIO_PinSource12
133 #define SPI2_SCK_PIN Pin_13
134 #define SPI2_SCK_PIN_SOURCE GPIO_PinSource13
135 #define SPI2_MISO_PIN Pin_14
136 #define SPI2_MISO_PIN_SOURCE GPIO_PinSource14
137 #define SPI2_MOSI_PIN Pin_15
138 #define SPI2_MOSI_PIN_SOURCE GPIO_PinSource15
139 
140 #define USE_SDCARD
141 #define USE_SDCARD_SPI2
142 
143 #define SDCARD_DETECT_INVERTED
144 
145 #define SDCARD_DETECT_PIN GPIO_Pin_14
146 #define SDCARD_DETECT_EXTI_LINE EXTI_Line14
147 #define SDCARD_DETECT_EXTI_PIN_SOURCE EXTI_PinSource14
148 #define SDCARD_DETECT_GPIO_PORT GPIOC
149 #define SDCARD_DETECT_GPIO_CLK RCC_AHBPeriph_GPIOC
150 #define SDCARD_DETECT_EXTI_PORT_SOURCE EXTI_PortSourceGPIOC
151 #define SDCARD_DETECT_EXTI_IRQn EXTI15_10_IRQn
152 
153 #define SDCARD_SPI_INSTANCE SPI2
154 #define SDCARD_SPI_CS_GPIO SPI2_GPIO
155 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
156 
157 // SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init:
158 #define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
159 // Divide to under 25MHz for normal operation:
160 #define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
161 
162 // Note, this is the same DMA channel as USART1_RX. Luckily we don't use DMA for USART Rx.
163 #define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
164 #define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC5
165 
166 // Performance logging for SD card operations:
167 // #define AFATFS_USE_INTROSPECTIVE_LOGGING
168 
169 #define USE_ADC
170 #define BOARD_HAS_VOLTAGE_DIVIDER
171 
172 
173 #define ADC_INSTANCE ADC2
174 #define ADC_DMA_CHANNEL DMA2_Channel1
175 #define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
176 
177 #define VBAT_ADC_GPIO GPIOA
178 #define VBAT_ADC_GPIO_PIN GPIO_Pin_4
179 #define VBAT_ADC_CHANNEL ADC_Channel_1
180 
181 #define CURRENT_METER_ADC_GPIO GPIOA
182 #define CURRENT_METER_ADC_GPIO_PIN GPIO_Pin_5
183 #define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
184 
185 #define RSSI_ADC_GPIO GPIOB
186 #define RSSI_ADC_GPIO_PIN GPIO_Pin_2
187 #define RSSI_ADC_CHANNEL ADC_Channel_12
188 
189 #define LED_STRIP
190 #define LED_STRIP_TIMER TIM1
191 
192 #define WS2811_GPIO GPIOA
193 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
194 #define WS2811_GPIO_AF GPIO_AF_6
195 #define WS2811_PIN GPIO_Pin_8
196 #define WS2811_PIN_SOURCE GPIO_PinSource8
197 #define WS2811_TIMER TIM1
198 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM1
199 #define WS2811_DMA_CHANNEL DMA1_Channel2
200 #define WS2811_IRQ DMA1_Channel2_IRQn
201 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC2
202 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH2_HANDLER
203 
204 #define TRANSPONDER
205 #define TRANSPONDER_GPIO GPIOA
206 #define TRANSPONDER_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
207 #define TRANSPONDER_GPIO_AF GPIO_AF_6
208 #define TRANSPONDER_PIN GPIO_Pin_8
209 #define TRANSPONDER_PIN_SOURCE GPIO_PinSource8
210 #define TRANSPONDER_TIMER TIM1
211 #define TRANSPONDER_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM1
212 #define TRANSPONDER_DMA_CHANNEL DMA1_Channel2
213 #define TRANSPONDER_IRQ DMA1_Channel2_IRQn
214 #define TRANSPONDER_DMA_TC_FLAG DMA1_FLAG_TC2
215 #define TRANSPONDER_DMA_HANDLER_IDENTIFER DMA1_CH2_HANDLER
216 
217 #define REDUCE_TRANSPONDER_CURRENT_DRAW_WHEN_USB_CABLE_PRESENT
218 
219 #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
220 
221 #define GPS
222 #define BLACKBOX
223 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
224 #define TELEMETRY
225 #define SERIAL_RX
226 #define GTUNE
227 #define DISPLAY
228 #define USE_SERVOS
229 #define USE_CLI
230 
231 #define BUTTONS
232 #define BUTTON_A_PORT GPIOB
233 #define BUTTON_A_PIN Pin_1
234 #define BUTTON_B_PORT GPIOB
235 #define BUTTON_B_PIN Pin_0
236 
237 #define SPEKTRUM_BIND
238 // USART3,
239 #define BIND_PORT GPIOB
240 #define BIND_PIN Pin_11
241 
242 #define HARDWARE_BIND_PLUG
243 #define BINDPLUG_PORT BUTTON_B_PORT
244 #define BINDPLUG_PIN BUTTON_B_PIN
245 
246 #define USE_SERIAL_4WAY_BLHELI_INTERFACE