Fixed CONFIG_FASTLOOP_PREFERRED_ACC related magic numbers
[betaflight.git] / src / main / target / SPARKY / target.h
blob7e3e2ed9dd902c7d4d821000b608a92c335a269d
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 "SPKY" // SParKY
22 #define CONFIG_FASTLOOP_PREFERRED_ACC ACC_NONE
24 #define LED0 PB4 // Blue (Rev 1 & 2) - PB4
25 #define LED1 PB5 // Green (Rev 1) / Red (Rev 2) - PB5
27 #define BEEPER PA1
28 #define BEEPER_INVERTED
30 #define USABLE_TIMER_CHANNEL_COUNT 11
32 // MPU6050 interrupts
33 #define USE_EXTI
34 #define MPU_INT_EXTI PA15
35 #define EXTI15_10_CALLBACK_HANDLER_COUNT 1 // MPU data ready
36 #define USE_MPU_DATA_READY_SIGNAL
38 // MPU 9150 INT connected to PA15, pulled up to VCC by 10K Resistor, contains MPU6050 and AK8975 in single component.
39 #define GYRO
40 #define USE_GYRO_MPU6050
42 #define GYRO_MPU6050_ALIGN CW270_DEG
44 #define ACC
45 #define USE_ACC_MPU6050
47 #define ACC_MPU6050_ALIGN CW270_DEG
49 #define BARO
50 #define USE_BARO_MS5611
51 #define USE_BARO_BMP280
53 #define MAG
54 #define USE_MAG_AK8975
56 #define MAG_AK8975_ALIGN CW180_DEG_FLIP
58 #define USE_VCP
59 #define USE_USART1 // Conn 1 - TX (PB6) RX PB7 (AF7)
60 #define USE_USART2 // Input - RX (PA3)
61 #define USE_USART3 // Servo out - 10/RX (PB11) 11/TX (PB10)
62 #define SERIAL_PORT_COUNT 4
64 #define UART1_TX_PIN GPIO_Pin_6 // PB6
65 #define UART1_RX_PIN GPIO_Pin_7 // PB7
66 #define UART1_GPIO GPIOB
67 #define UART1_GPIO_AF GPIO_AF_7
68 #define UART1_TX_PINSOURCE GPIO_PinSource6
69 #define UART1_RX_PINSOURCE GPIO_PinSource7
71 #define UART2_TX_PIN GPIO_Pin_2 // PA2 - Clashes with PWM6 input.
72 #define UART2_RX_PIN GPIO_Pin_3 // PA3
73 #define UART2_GPIO GPIOA
74 #define UART2_GPIO_AF GPIO_AF_7
75 #define UART2_TX_PINSOURCE GPIO_PinSource2
76 #define UART2_RX_PINSOURCE GPIO_PinSource3
78 #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7)
79 #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7)
80 #define UART3_GPIO_AF GPIO_AF_7
81 #define UART3_GPIO GPIOB
82 #define UART3_TX_PINSOURCE GPIO_PinSource10
83 #define UART3_RX_PINSOURCE GPIO_PinSource11
85 // Note: PA5 and PA0 are N/C on the sparky - potentially use for ADC or LED STRIP?
87 #define USE_I2C
88 #define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4)
90 #define I2C2_SCL_GPIO GPIOA
91 #define I2C2_SCL_GPIO_AF GPIO_AF_4
92 #define I2C2_SCL_PIN GPIO_Pin_9
93 #define I2C2_SCL_PIN_SOURCE GPIO_PinSource9
94 #define I2C2_SCL_CLK_SOURCE RCC_AHBPeriph_GPIOA
95 #define I2C2_SDA_GPIO GPIOA
96 #define I2C2_SDA_GPIO_AF GPIO_AF_4
97 #define I2C2_SDA_PIN GPIO_Pin_10
98 #define I2C2_SDA_PIN_SOURCE GPIO_PinSource10
99 #define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA
101 #define USE_ADC
103 #define ADC_INSTANCE ADC2
104 #define ADC_DMA_CHANNEL DMA2_Channel1
105 #define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
107 #define VBAT_ADC_GPIO GPIOA
108 #define VBAT_ADC_GPIO_PIN GPIO_Pin_4
109 #define VBAT_ADC_CHANNEL ADC_Channel_1
111 #define CURRENT_METER_ADC_GPIO GPIOA
112 #define CURRENT_METER_ADC_GPIO_PIN GPIO_Pin_7
113 #define CURRENT_METER_ADC_CHANNEL ADC_Channel_4
115 #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
117 #define LED_STRIP
118 #if 1
119 // LED strip configuration using PWM motor output pin 5.
120 #define LED_STRIP_TIMER TIM16
122 #define USE_LED_STRIP_ON_DMA1_CHANNEL3
123 #define WS2811_GPIO GPIOA
124 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
125 #define WS2811_GPIO_AF GPIO_AF_1
126 #define WS2811_PIN GPIO_Pin_6 // TIM16_CH1
127 #define WS2811_PIN_SOURCE GPIO_PinSource6
128 #define WS2811_TIMER TIM16
129 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16
130 #define WS2811_DMA_CHANNEL DMA1_Channel3
131 #define WS2811_IRQ DMA1_Channel3_IRQn
132 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC3
133 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH3_HANDLER
134 #endif
136 #if 0
137 // Alternate LED strip pin
138 // FIXME DMA IRQ Transfer Complete is never called because the TIM17_DMA_RMP needs to be set in SYSCFG_CFGR1
139 #define LED_STRIP_TIMER TIM17
141 #define USE_LED_STRIP_ON_DMA1_CHANNEL7
142 #define WS2811_GPIO GPIOA
143 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
144 #define WS2811_GPIO_AF GPIO_AF_1
145 #define WS2811_PIN GPIO_Pin_7 // TIM17_CH1
146 #define WS2811_PIN_SOURCE GPIO_PinSource7
147 #define WS2811_TIMER TIM17
148 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM17
149 #define WS2811_DMA_CHANNEL DMA1_Channel7
150 #define WS2811_IRQ DMA1_Channel7_IRQn
151 #endif
153 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
155 #define SPEKTRUM_BIND
156 // USART2, PA3
157 #define BIND_PIN PA3
160 // available IO pins (from schematics)
161 //#define TARGET_IO_PORTA (BIT(1)|BIT(2)|BIT(3)|BIT(4)|BIT(6)|BIT(7)|BIT(8)|BIT(9)|BIT(10)|BIT(11)|BIT(12)|BIT(13)|BIT(14)|BIT(15))
162 //#define TARGET_IO_PORTB (BIT(0)|BIT(1)|BIT(10)|BIT(11)|BIT(14)|BIT(15)|BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7)|BIT(8)|BIT(9))
163 // !!TODO - check following lines are correct
164 #define TARGET_IO_PORTA (BIT(1)|BIT(2)|BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7)|BIT(8)|BIT(9)|BIT(10)|BIT(11)|BIT(12)|BIT(13)|BIT(14)|BIT(15))
165 #define TARGET_IO_PORTB (BIT(0)|BIT(1)|BIT(6)|BIT(10)|BIT(11)|BIT(14)|BIT(15)|BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7)|BIT(8)|BIT(9)|BIT(12)|BIT(13))
166 #define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4))
169 #define USED_TIMERS (TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(15) | TIM_N(17))
171 #define TIMER_APB1_PERIPHERALS (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3)
172 #define TIMER_APB2_PERIPHERALS (RCC_APB2Periph_TIM1 | RCC_APB2Periph_TIM15 | RCC_APB2Periph_TIM17)
173 #define TIMER_AHB_PERIPHERALS (RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB)