2 * This file is part of Cleanflight.
4 * Cleanflight 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.
9 * Cleanflight 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.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
19 #define TARGET_BOARD_IDENTIFIER "AFF4"
21 #define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8)
23 #define USBD_PRODUCT_STRING "AlienFlight F4"
31 #define INVERTER_USART USART2
34 //#define DEBUG_MPU_DATA_READY_INTERRUPT
35 #define USE_MPU_DATA_READY_SIGNAL
36 #define ENSURE_MPU_DATA_READY_IS_LOW
37 #define EXTI_CALLBACK_HANDLER_COUNT 1 // MPU data ready
38 #define MPU_INT_EXTI PC14
41 #define MPU6500_CS_PIN PA4
42 #define MPU6500_SPI_INSTANCE SPI1
45 #define USE_ACC_SPI_MPU6500
46 #define ACC_MPU6500_ALIGN CW270_DEG
49 #define USE_GYRO_SPI_MPU6500
50 #define GYRO_MPU6500_ALIGN CW270_DEG
53 #define USE_MAG_HMC5883
54 #define USE_MAG_AK8963
56 #define MAG_HMC5883_ALIGN CW180_DEG
57 #define MAG_AK8963_ALIGN CW270_DEG
60 #define USE_BARO_MS5611
61 #define USE_BARO_BMP280
65 //#define SDCARD_DETECT_INVERTED
67 #define SDCARD_DETECT_PIN PB10
68 #define SDCARD_DETECT_EXTI_LINE EXTI_Line10
69 #define SDCARD_DETECT_EXTI_PIN_SOURCE EXTI_PinSource10
70 #define SDCARD_DETECT_EXTI_PORT_SOURCE EXTI_PortSourceGPIOB
71 #define SDCARD_DETECT_EXTI_IRQn EXTI15_10_IRQn
73 #define SDCARD_SPI_INSTANCE SPI2
74 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
76 // SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
77 #define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
78 // Divide to under 25MHz for normal operation:
79 #define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
81 #define SDCARD_DMA_CHANNEL_TX DMA1_Stream4
82 #define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF4
83 #define SDCARD_DMA_CLK RCC_AHB1Periph_DMA1
84 #define SDCARD_DMA_CHANNEL DMA_Channel_0
86 // Performance logging for SD card operations:
87 // #define AFATFS_USE_INTROSPECTIVE_LOGGING
89 //#define M25P16_CS_PIN SPI2_NSS_PIN
90 //#define M25P16_SPI_INSTANCE SPI2
93 //#define USE_FLASH_M25P16
95 #define USABLE_TIMER_CHANNEL_COUNT 13
100 #define USART1_RX_PIN PA10
101 #define USART1_TX_PIN PA9
102 #define USART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2
105 #define USART2_RX_PIN PA3
106 #define USART2_TX_PIN PA2 //inverter
109 //#define USART3_RX_PIN PB11
110 //#define USART3_TX_PIN PB10
113 #define USART4_RX_PIN PC10
114 #define USART4_TX_PIN PC11
117 //#define USART5_RX_PIN PD2
118 //#define USART5_TX_PIN PC12
120 #define SERIAL_PORT_COUNT 4
124 #define USE_SPI_DEVICE_1
126 #define USE_SPI_DEVICE_2
127 #define SPI2_NSS_PIN PB12
128 #define SPI2_SCK_PIN PB13
129 #define SPI2_MISO_PIN PC2
130 #define SPI2_MOSI_PIN PC3
132 #define USE_SPI_DEVICE_3
135 #define I2C_DEVICE (I2CDEV_1)
136 //#define I2C_DEVICE_EXT (I2CDEV_2)
141 //#define BOARD_HAS_VOLTAGE_DIVIDER
142 #define VBAT_ADC_PIN PC0
143 #define CURRENT_METER_ADC_PIN PC1
144 #define RSSI_ADC_PIN PC4
145 #define EXTERNAL1_ADC_GPIO_PIN PC5
147 // LED strip configuration using RC5 pin.
150 //#define USE_LED_STRIP_ON_DMA1_CHANNEL3
151 //#define WS2811_PIN PB15 // TIM8_CH3
152 //#define WS2811_TIMER TIM8
153 //#define WS2811_DMA_CHANNEL DMA1_Channel3
154 //#define WS2811_IRQ DMA1_Channel3_IRQn
156 // alternative defaults for AlienFlight F4 target
159 #define SPEKTRUM_BIND
163 #define HARDWARE_BIND_PLUG
164 // Hardware bind plug at PB2 (Pin 28)
165 #define BINDPLUG_PIN PB2
167 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
169 #define BRUSHED_MOTORS
170 #define DEFAULT_FEATURES (FEATURE_MOTOR_STOP | FEATURE_BLACKBOX)
171 #define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
172 #define SERIALRX_PROVIDER SERIALRX_SPEKTRUM2048
173 #define SERIALRX_UART SERIAL_PORT_USART3
175 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
177 #define TARGET_IO_PORTA 0xffff
178 #define TARGET_IO_PORTB 0xffff
179 #define TARGET_IO_PORTC 0xffff
180 #define TARGET_IO_PORTD (BIT(2))
182 #define USED_TIMERS ( TIM_N(1) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(8) )