Add Nucleo-F303RE support
[betaflight.git] / src / main / target / NUCLEOF303RE / target.h
blob9b24c8948ad5d3988c038be40d13d87f08aec25c
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #define TARGET_BOARD_IDENTIFIER "F3RE"
24 #define USE_TARGET_CONFIG
26 //#define LED0_PIN PB8
27 #define LED0_PIN PA5
29 #define USE_BEEPER
30 #define BEEPER_PIN PC15
31 #define BEEPER_INVERTED
33 #define USE_EXTI
34 #define USE_GYRO_EXTI
35 #define GYRO_1_EXTI_PIN PC13
36 #define USE_MPU_DATA_READY_SIGNAL
37 #define ENSURE_MPU_DATA_READY_IS_LOW
39 #define USE_MAG_DATA_READY_SIGNAL
40 #define ENSURE_MAG_DATA_READY_IS_HIGH
42 #define USE_GYRO
43 #define USE_GYRO_SPI_MPU6500
44 #define USE_FAKE_GYRO
46 #define USE_ACC
47 #define USE_ACC_SPI_MPU6500
48 #define USE_FAKE_ACC
50 #define GYRO_1_ALIGN CW180_DEG
52 #define USE_BARO
53 #define USE_BARO_BMP280
55 #define USE_MAG
56 #define USE_MAG_AK8963
57 //#define USE_MAG_HMC5883 // External
59 #define MAG_AK8963_ALIGN CW270_DEG_FLIP
61 //#define USE_RANGEFINDER
62 //#define USE_RANGEFINDER_HCSR04
64 //#define USE_VCP // Not working (yet)
65 #define USE_UART1
66 #define USE_UART2
67 #define USE_UART3
68 #define USE_UART4 // Use UART4 or UART5 for configurator MSP instead of non-working VCP
69 #define USE_UART5 // Use UART5 or UART5 for configurator MSP instead of non-working VCP
70 #define USE_SOFTSERIAL1
71 #define USE_SOFTSERIAL2
73 #define SOFTSERIAL1_RX_PIN PA6 // PWM 5
74 #define SOFTSERIAL1_TX_PIN PA7 // PWM 6
76 #define SOFTSERIAL2_RX_PIN PB0 // PWM 7
77 #define SOFTSERIAL2_TX_PIN PB1 // PWM 8
79 #define SERIAL_PORT_COUNT 7
81 #define USE_ESCSERIAL
82 #define ESCSERIAL_TIMER_TX_PIN PA15 // (HARDARE=0,PPM)
84 #define UART1_TX_PIN PA9
85 #define UART1_RX_PIN PA10
87 #define UART2_TX_PIN PA14 // PA14 / SWCLK
88 #define UART2_RX_PIN PA15
90 #define UART3_TX_PIN PB10 // PB10 (AF7)
91 #define UART3_RX_PIN PB11 // PB11 (AF7)
93 #define UART5_TX_PIN PC12
94 #define UART5_RX_PIN PD2
96 #define USE_I2C
97 #define USE_I2C_DEVICE_1
98 #define I2C_DEVICE (I2CDEV_1)
100 #define USE_SPI
101 #define USE_SPI_DEVICE_1 // PB9,3,4,5 on AF5 SPI1 (MPU)
102 #define USE_SPI_DEVICE_2 // PB12,13,14,15 on AF5 SPI2 (SDCard)
104 #define SPI1_NSS_PIN PB9
105 #define SPI1_SCK_PIN PB3
106 #define SPI1_MISO_PIN PB4
107 #define SPI1_MOSI_PIN PB5
109 #define SPI2_NSS_PIN PB12
110 #define SPI2_SCK_PIN PB13
111 #define SPI2_MISO_PIN PB14
112 #define SPI2_MOSI_PIN PB15
114 #define USE_SDCARD
115 #define USE_SDCARD_SPI
116 #define SDCARD_DETECT_INVERTED
117 #define SDCARD_DETECT_PIN PC14
118 #define SDCARD_SPI_INSTANCE SPI2
119 #define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
121 // Note, this is the same DMA channel as UART1_RX. Luckily we don't use DMA for USART Rx.
122 #define SDCARD_DMA_CHANNEL_TX DMA1_Channel5
124 #define GYRO_1_CS_PIN PB9
125 #define GYRO_1_SPI_INSTANCE SPI1
127 #define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
129 #define USE_ADC
130 #define ADC_INSTANCE ADC2
131 #define RSSI_ADC_PIN PB2
132 #define VBAT_ADC_PIN PA4
133 //#define CURRENT_METER_ADC_PIN PA5
135 #define USE_OSD
136 #define USE_OSD_OVER_MSP_DISPLAYPORT
137 #define USE_MSP_CURRENT_METER
139 #define USE_TRANSPONDER
141 #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
143 #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
144 #define DEFAULT_FEATURES (FEATURE_TRANSPONDER | FEATURE_RSSI_ADC | FEATURE_TELEMETRY)
146 // IO - STM32F303RE in 64pin package
147 #define TARGET_IO_PORTA 0xffff
148 #define TARGET_IO_PORTB 0xffff
149 #define TARGET_IO_PORTC 0xffff
150 #define TARGET_IO_PORTD BIT(2)
152 #define USABLE_TIMER_CHANNEL_COUNT 12 // PPM, 8 PWM, UART3 RX/TX, LED Strip
153 #define USED_TIMERS (TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(8) | TIM_N(15) | TIM_N(16))