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 "AFNA" // AFroNAze - NAZE might be considered misleading on Naze clones like the flip32.
22 #define USE_HARDWARE_REVISION_DETECTION
23 
24 #define BOARD_HAS_VOLTAGE_DIVIDER
25 
26 #define LED0_GPIO GPIOB
27 #define LED0_PIN Pin_3 // PB3 (LED)
28 #define LED0_PERIPHERAL RCC_APB2Periph_GPIOB
29 #define LED1_GPIO GPIOB
30 #define LED1_PIN Pin_4 // PB4 (LED)
31 #define LED1_PERIPHERAL RCC_APB2Periph_GPIOB
32 
33 #define BEEP_GPIO GPIOA
34 #define BEEP_PIN Pin_12 // PA12 (Beeper)
35 #define BEEP_PERIPHERAL RCC_APB2Periph_GPIOA
36 
37 #define BARO_XCLR_GPIO GPIOC
38 #define BARO_XCLR_PIN Pin_13
39 #define BARO_EOC_GPIO GPIOC
40 #define BARO_EOC_PIN Pin_14
41 #define BARO_APB2_PERIPHERALS RCC_APB2Periph_GPIOC
42 
43 #define INVERTER_PIN Pin_2 // PB2 (BOOT1) abused as inverter select GPIO
44 #define INVERTER_GPIO GPIOB
45 #define INVERTER_PERIPHERAL RCC_APB2Periph_GPIOB
46 #define INVERTER_USART USART2
47 
48 // SPI2
49 // PB15 28 SPI2_MOSI
50 // PB14 27 SPI2_MISO
51 // PB13 26 SPI2_SCK
52 // PB12 25 SPI2_NSS
53 
54 #define USE_SPI
55 #define USE_SPI_DEVICE_2
56 
57 #define NAZE_SPI_INSTANCE SPI2
58 #define NAZE_SPI_CS_GPIO GPIOB
59 #define NAZE_SPI_CS_PIN GPIO_Pin_12
60 #define NAZE_CS_GPIO_CLK_PERIPHERAL RCC_APB2Periph_GPIOB
61 
62 // We either have this 16mbit flash chip on SPI or the MPU6500 acc/gyro depending on board revision:
63 #define M25P16_CS_GPIO NAZE_SPI_CS_GPIO
64 #define M25P16_CS_PIN NAZE_SPI_CS_PIN
65 #define M25P16_SPI_INSTANCE NAZE_SPI_INSTANCE
66 
67 #define MPU6500_CS_GPIO_CLK_PERIPHERAL NAZE_CS_GPIO_CLK_PERIPHERAL
68 #define MPU6500_CS_GPIO NAZE_SPI_CS_GPIO
69 #define MPU6500_CS_PIN NAZE_SPI_CS_PIN
70 #define MPU6500_SPI_INSTANCE NAZE_SPI_INSTANCE
71 
72 
73 #define USE_FLASHFS
74 
75 #define USE_FLASH_M25P16
76 
77 #define EXTI_CALLBACK_HANDLER_COUNT 3 // MPU data ready, MAG data ready, BMP085 EOC
78 
79 //#define DEBUG_MPU_DATA_READY_INTERRUPT
80 #define USE_MPU_DATA_READY_SIGNAL
81 
82 //#define DEBUG_MAG_DATA_READY_INTERRUPT
83 #define USE_MAG_DATA_READY_SIGNAL
84 
85 #define GYRO
86 #define USE_GYRO_MPU3050
87 #define USE_GYRO_MPU6050
88 #define USE_GYRO_MPU6500
89 #define USE_GYRO_SPI_MPU6500
90 
91 
92 #define GYRO_MPU3050_ALIGN CW0_DEG
93 #define GYRO_MPU6050_ALIGN CW0_DEG
94 #define GYRO_MPU6500_ALIGN CW0_DEG
95 
96 #define ACC
97 #define USE_ACC_ADXL345
98 #define USE_ACC_BMA280
99 #define USE_ACC_MMA8452
100 #define USE_ACC_MPU6050
101 #define USE_ACC_MPU6500
102 #define USE_ACC_SPI_MPU6500
103 
104 #define ACC_ADXL345_ALIGN CW270_DEG
105 #define ACC_MPU6050_ALIGN CW0_DEG
106 #define ACC_MMA8452_ALIGN CW90_DEG
107 #define ACC_BMA280_ALIGN CW0_DEG
108 #define ACC_MPU6500_ALIGN CW0_DEG
109 
110 #define BARO
111 #define USE_BARO_MS5611
112 #define USE_BARO_BMP085
113 #define USE_BARO_BMP280
114 
115 #define USE_MAG 0
116 #define USE_MAG_HMC5883
117 
118 #define MAG_HMC5883_ALIGN CW180_DEG
119 
120 #define USE_BEEPER 1
121 #define LED0
122 #define LED1
123 #define INVERTER
124 //#define DISPLAY
125 
126 #if 0
127 #define SONAR
128 #define SONAR_PWM_TRIGGER_PIN Pin_8 // PWM5 (PB8) - 5v tolerant
129 #define SONAR_PWM_TRIGGER_GPIO GPIOB
130 #define SONAR_PWM_ECHO_PIN Pin_9 // PWM6 (PB9) - 5v tolerant
131 #define SONAR_PWM_ECHO_GPIO GPIOB
132 #define SONAR_PWM_EXTI_LINE EXTI_Line9
133 #define SONAR_PWM_EXTI_PIN_SOURCE GPIO_PinSource9
134 #define SONAR_PWM_EXTI_IRQN EXTI9_5_IRQn
135 #define SONAR_TRIGGER_PIN Pin_0 // RX7 (PB0) - only 3.3v ( add a 1K Ohms resistor )
136 #define SONAR_TRIGGER_GPIO GPIOB
137 #define SONAR_ECHO_PIN Pin_1 // RX8 (PB1) - only 3.3v ( add a 1K Ohms resistor )
138 #define SONAR_ECHO_GPIO GPIOB
139 #define SONAR_EXTI_LINE EXTI_Line1
140 #define SONAR_EXTI_PIN_SOURCE GPIO_PinSource1
141 #define SONAR_EXTI_IRQN EXTI1_IRQn
142 #endif
143 
144 #define USE_UART1
145 #define USE_UART2
146 #define USE_UART3
147 #define USE_SOFTSERIAL1
148 #define USE_SOFTSERIAL2
149 #define SERIAL_PORT_COUNT 5
150 
151 #define SOFTSERIAL_1_TIMER TIM3
152 #define SOFTSERIAL_1_TIMER_RX_HARDWARE 4 // PWM 5
153 #define SOFTSERIAL_1_TIMER_TX_HARDWARE 5 // PWM 6
154 #define SOFTSERIAL_2_TIMER TIM3
155 #define SOFTSERIAL_2_TIMER_RX_HARDWARE 6 // PWM 7
156 #define SOFTSERIAL_2_TIMER_TX_HARDWARE 7 // PWM 8
157 
158 // UART3 only on NAZE32_SP - Flex Port
159 #define UART3_RX_PIN Pin_11
160 #define UART3_TX_PIN Pin_10
161 #define UART3_GPIO GPIOB
162 #define UART3_APB1_PERIPHERALS RCC_APB1Periph_USART3
163 #define UART3_APB2_PERIPHERALS RCC_APB2Periph_GPIOB
164 
165 #define USE_I2C
166 #define I2C_DEVICE (I2CDEV_2)
167 
168 // #define SOFT_I2C // enable to test software i2c
169 // #define SOFT_I2C_PB1011 // If SOFT_I2C is enabled above, need to define pinout as well (I2C1 = PB67, I2C2 = PB1011)
170 // #define SOFT_I2C_PB67
171 
172 #define USE_ADC
173 
174 #define CURRENT_METER_ADC_GPIO GPIOB
175 #define CURRENT_METER_ADC_GPIO_PIN GPIO_Pin_1
176 #define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
177 
178 #define VBAT_ADC_GPIO GPIOA
179 #define VBAT_ADC_GPIO_PIN GPIO_Pin_4
180 #define VBAT_ADC_CHANNEL ADC_Channel_4
181 
182 #define RSSI_ADC_GPIO GPIOA
183 #define RSSI_ADC_GPIO_PIN GPIO_Pin_1
184 #define RSSI_ADC_CHANNEL ADC_Channel_1
185 
186 #define EXTERNAL1_ADC_GPIO GPIOA
187 #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_5
188 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
189 
190 
191 #define LED_STRIP
192 #define LED_STRIP_TIMER TIM3
193 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC6
194 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH6_HANDLER
195 
196 //#define GPS
197 //#define GTUNE
198 //#define BLACKBOX
199 //#define TELEMETRY
200 //#define SERIAL_RX
201 #define USE_SERVOS
202 #define USE_CLI
203 #define USE_TILT 1
204 
205 //#define SPEKTRUM_BIND
206 // UART2, PA3
207 #define BIND_PORT GPIOA
208 #define BIND_PIN Pin_3
209 
210 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
211 
212 // alternative defaults for AlienFlight F1 target
213 #ifdef ALIENFLIGHT
214 #undef TARGET_BOARD_IDENTIFIER
215 #define TARGET_BOARD_IDENTIFIER "AFF1" // AlienFlight F1.
216 #undef BOARD_HAS_VOLTAGE_DIVIDER
217 
218 #define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
219 #define DEFAULT FEATURES FEATURE_MOTOR_STOP
220 
221 #define HARDWARE_BIND_PLUG
222 
223 // Hardware bind plug at PB5 (Pin 41)
224 #define BINDPLUG_PORT GPIOB
225 #define BINDPLUG_PIN Pin_5
226 #endif