Configurable SDCARD, and clean up of DMA.
[betaflight.git] / src / main / target / MATEKF405 / target.h
blob552421aaf7b1f86bf2e13b080a8e5e9732bda458
1 /*
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/>.
18 #pragma once
20 #define TARGET_BOARD_IDENTIFIER "MKF4"
21 #define USBD_PRODUCT_STRING "MatekF4"
23 #define LED0_PIN PB9
24 #define LED1_PIN PA14
26 #define BEEPER PC13
27 #define BEEPER_INVERTED
29 #define USE_DSHOT_DMAR
31 // *************** Gyro & ACC **********************
32 #define USE_SPI
33 #define USE_SPI_DEVICE_1
35 #define SPI1_SCK_PIN PA5
36 #define SPI1_MISO_PIN PA6
37 #define SPI1_MOSI_PIN PA7
39 #define MPU6000_CS_PIN PC2
40 #define MPU6000_SPI_INSTANCE SPI1
42 #define MPU6500_CS_PIN PC2
43 #define MPU6500_SPI_INSTANCE SPI1
45 #define USE_EXTI
46 #define MPU_INT_EXTI PC3
47 #define USE_MPU_DATA_READY_SIGNAL
49 #define USE_GYRO
50 #define USE_GYRO_SPI_MPU6000
51 #define GYRO_MPU6000_ALIGN CW270_DEG
53 #define USE_GYRO_SPI_MPU6500
54 #define GYRO_MPU6500_ALIGN CW180_DEG
56 #define USE_ACC
57 #define USE_ACC_SPI_MPU6000
58 #define ACC_MPU6000_ALIGN CW270_DEG
60 #define USE_ACC_SPI_MPU6500
61 #define ACC_MPU6500_ALIGN CW180_DEG
63 #define USE_MAG
64 #define USE_MAG_HMC5883
66 // *************** Baro **************************
67 #define USE_I2C
69 #if defined(BARO_I2C1)
70 // Useful for MATEKF405_OSD, since it does not have the SCL / SDA pads
71 #define USE_I2C_DEVICE_3
73 #define I2C_DEVICE (I2CDEV_3)
74 #define I2C3_SCL PC9 // S4 pad
75 #define I2C3_SDA PA8 // S6 pad
76 #define BARO_I2C_INSTANCE (I2CDEV_3)
77 #else
78 #define USE_I2C_DEVICE_1
79 #define I2C_DEVICE (I2CDEV_1)
80 #define I2C1_SCL PB6 // SCL pad
81 #define I2C1_SDA PB7 // SDA pad
82 #define BARO_I2C_INSTANCE (I2CDEV_1)
83 #endif
85 #define USE_BARO
86 #define USE_BARO_BMP280
87 #define USE_BARO_MS5611
88 #define USE_BARO_BMP085
90 #define USE_SPI_DEVICE_3
91 #define SPI3_SCK_PIN PB3
92 #define SPI3_MISO_PIN PB4
93 #define SPI3_MOSI_PIN PB5
95 #define USE_FLASHFS
96 #define USE_FLASH_M25P16
97 #define M25P16_CS_PIN PC0
98 #define M25P16_SPI_INSTANCE SPI3
100 // *************** SD Card **************************
101 #define USE_SDCARD
102 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
104 #define SDCARD_SPI_INSTANCE SPI3
105 #define SDCARD_SPI_CS_PIN PC1
107 // SPI3 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
108 #define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
109 // Divide to under 25MHz for normal operation:
110 #define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
112 #define SDCARD_DMA_CHANNEL_TX DMA1_Stream7
113 #define SDCARD_DMA_CHANNEL 0
115 // *************** OSD *****************************
116 #define USE_SPI_DEVICE_2
117 #define SPI2_SCK_PIN PB13
118 #define SPI2_MISO_PIN PB14
119 #define SPI2_MOSI_PIN PB15
121 #define USE_OSD
122 #define USE_MAX7456
123 #define MAX7456_SPI_INSTANCE SPI2
124 #define MAX7456_SPI_CS_PIN PB10
126 // *************** UART *****************************
127 #define USE_VCP
128 #define VBUS_SENSING_PIN PB12
129 #define VBUS_SENSING_ENABLED
131 #define USE_UART1
132 #define UART1_RX_PIN PA10
133 #define UART1_TX_PIN PA9
135 #define USE_UART2
136 #define UART2_RX_PIN PA3
137 #define UART2_TX_PIN PA2
139 #define USE_UART3
140 #define UART3_RX_PIN PC11
141 #define UART3_TX_PIN PC10
143 #define USE_UART4
144 #define UART4_RX_PIN PA1
145 #define UART4_TX_PIN PA0
147 #define USE_UART5
148 #define UART5_RX_PIN PD2
149 #define UART5_TX_PIN PC12
151 #define USE_SOFTSERIAL1
152 #define USE_SOFTSERIAL2
154 #define SERIAL_PORT_COUNT 8
156 #define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
157 #define SERIALRX_PROVIDER SERIALRX_SBUS
158 #define SERIALRX_UART SERIAL_PORT_USART2
160 // *************** ADC *****************************
161 #define USE_ADC
162 #define ADC1_DMA_STREAM DMA2_Stream0
163 #define VBAT_ADC_PIN PC5
164 #define CURRENT_METER_ADC_PIN PC4
165 #define RSSI_ADC_PIN PB1
167 #define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY | FEATURE_SOFTSERIAL)
168 #define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
169 #define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
170 #define CURRENT_METER_SCALE_DEFAULT 179
172 #define USE_ESCSERIAL
173 #define ESCSERIAL_TIMER_TX_PIN PA3
174 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
176 #define TARGET_IO_PORTA 0xffff
177 #define TARGET_IO_PORTB 0xffff
178 #define TARGET_IO_PORTC 0xffff
179 #define TARGET_IO_PORTD (BIT(2))
181 #define USABLE_TIMER_CHANNEL_COUNT 12
182 #define USED_TIMERS (TIM_N(1)|TIM_N(2)|TIM_N(3)|TIM_N(4)|TIM_N(5)|TIM_N(8)|TIM_N(9))