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 "SPKY" // SParKY
22 
23 #define USE_TILT 0
24 #define LED0_GPIO GPIOB
25 #define LED0_PIN Pin_4 // Blue (Rev 1 & 2) - PB4
26 #define LED0_PERIPHERAL RCC_AHBPeriph_GPIOB
27 #define LED1_GPIO GPIOB
28 #define LED1_PIN Pin_5 // Green (Rev 1) / Red (Rev 2) - PB5
29 #define LED1_PERIPHERAL RCC_AHBPeriph_GPIOB
30 
31 #define USABLE_TIMER_CHANNEL_COUNT 11
32 
33 // MPU 9150 INT connected to PA15, pulled up to VCC by 10K Resistor, contains MPU6050 and AK8975 in single component.
34 #define GYRO
35 #define USE_GYRO_MPU6050
36 
37 #define GYRO_MPU6050_ALIGN CW270_DEG
38 
39 #define ACC
40 #define USE_ACC_MPU6050
41 
42 #define ACC_MPU6050_ALIGN CW270_DEG
43 
44 #define BARO
45 #define USE_BARO_MS5611
46 
47 #define USE_MAG 1
48 #define USE_MAG_AK8975
49 
50 #define MAG_AK8975_ALIGN CW180_DEG_FLIP
51 
52 #define LED0
53 #define LED1
54 
55 #define USB_IO
56 
57 #define USE_VCP
58 #define USE_UART1 // Conn 1 - TX (PB6) RX PB7 (AF7)
59 #define USE_UART2 // Input - RX (PA3)
60 #define USE_UART3 // Servo out - 10/RX (PB11) 11/TX (PB10)
61 #define SERIAL_PORT_COUNT 4
62 
63 #define UART1_TX_PIN GPIO_Pin_6 // PB6
64 #define UART1_RX_PIN GPIO_Pin_7 // PB7
65 #define UART1_GPIO GPIOB
66 #define UART1_GPIO_AF GPIO_AF_7
67 #define UART1_TX_PINSOURCE GPIO_PinSource6
68 #define UART1_RX_PINSOURCE GPIO_PinSource7
69 
70 #define UART2_TX_PIN GPIO_Pin_2 // PA2 - Clashes with PWM6 input.
71 #define UART2_RX_PIN GPIO_Pin_3 // PA3
72 #define UART2_GPIO GPIOA
73 #define UART2_GPIO_AF GPIO_AF_7
74 #define UART2_TX_PINSOURCE GPIO_PinSource2
75 #define UART2_RX_PINSOURCE GPIO_PinSource3
76 
77 #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7)
78 #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7)
79 #define UART3_GPIO_AF GPIO_AF_7
80 #define UART3_GPIO GPIOB
81 #define UART3_TX_PINSOURCE GPIO_PinSource10
82 #define UART3_RX_PINSOURCE GPIO_PinSource11
83 
84 // Note: PA5 and PA0 are N/C on the sparky - potentially use for ADC or LED STRIP?
85 
86 #define USE_I2C
87 #define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4)
88 
89 #define I2C2_SCL_GPIO GPIOA
90 #define I2C2_SCL_GPIO_AF GPIO_AF_4
91 #define I2C2_SCL_PIN GPIO_Pin_9
92 #define I2C2_SCL_PIN_SOURCE GPIO_PinSource9
93 #define I2C2_SCL_CLK_SOURCE RCC_AHBPeriph_GPIOA
94 #define I2C2_SDA_GPIO GPIOA
95 #define I2C2_SDA_GPIO_AF GPIO_AF_4
96 #define I2C2_SDA_PIN GPIO_Pin_10
97 #define I2C2_SDA_PIN_SOURCE GPIO_PinSource10
98 #define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA
99 
100 #define USE_ADC
101 
102 #define ADC_INSTANCE ADC2
103 #define ADC_DMA_CHANNEL DMA2_Channel1
104 #define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
105 
106 #define VBAT_ADC_GPIO GPIOA
107 #define VBAT_ADC_GPIO_PIN GPIO_Pin_4
108 #define VBAT_ADC_CHANNEL ADC_Channel_1
109 
110 #define CURRENT_METER_ADC_GPIO GPIOA
111 #define CURRENT_METER_ADC_GPIO_PIN GPIO_Pin_7
112 #define CURRENT_METER_ADC_CHANNEL ADC_Channel_4
113 
114 #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
115 
116 #define BLACKBOX
117 #define GPS
118 #define GTUNE
119 #define DISPLAY
120 #define SERIAL_RX
121 #define TELEMETRY
122 #define USE_SERVOS
123 #define USE_CLI
124 
125 #define SONAR
126 #define SONAR_TRIGGER_PIN Pin_2 // PWM6 (PA2) - only 3.3v ( add a 1K Ohms resistor )
127 #define SONAR_TRIGGER_GPIO GPIOA
128 #define SONAR_ECHO_PIN Pin_1 // PWM7 (PB1) - only 3.3v ( add a 1K Ohms resistor )
129 #define SONAR_ECHO_GPIO GPIOB
130 #define SONAR_EXTI_LINE EXTI_Line1
131 #define SONAR_EXTI_PIN_SOURCE EXTI_PinSource1
132 #define SONAR_EXTI_IRQN EXTI1_IRQn
133 
134 #define LED_STRIP
135 #if 1
136 // LED strip configuration using PWM motor output pin 5.
137 #define LED_STRIP_TIMER TIM16
138 
139 #define WS2811_GPIO GPIOA
140 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
141 #define WS2811_GPIO_AF GPIO_AF_1
142 #define WS2811_PIN GPIO_Pin_6 // TIM16_CH1
143 #define WS2811_PIN_SOURCE GPIO_PinSource6
144 #define WS2811_TIMER TIM16
145 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16
146 #define WS2811_DMA_CHANNEL DMA1_Channel3
147 #define WS2811_IRQ DMA1_Channel3_IRQn
148 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC3
149 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH3_HANDLER
150 
151 #endif
152 
153 #if 0
154 // Alternate LED strip pin
155 // FIXME DMA IRQ Transfer Complete is never called because the TIM17_DMA_RMP needs to be set in SYSCFG_CFGR1
156 #define LED_STRIP_TIMER TIM17
157 
158 #define WS2811_GPIO GPIOA
159 #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA
160 #define WS2811_GPIO_AF GPIO_AF_1
161 #define WS2811_PIN GPIO_Pin_7 // TIM17_CH1
162 #define WS2811_PIN_SOURCE GPIO_PinSource7
163 #define WS2811_TIMER TIM17
164 #define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM17
165 #define WS2811_DMA_CHANNEL DMA1_Channel7
166 #define WS2811_IRQ DMA1_Channel7_IRQn
167 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC7
168 #define WS2811_DMA_HANDLER_IDENTIFER DMA1_CH7_HANDLER
169 
170 
171 #endif
172 
173 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
174 
175 #define SPEKTRUM_BIND
176 // UART2, PA3
177 #define BIND_PORT GPIOA
178 #define BIND_PIN Pin_3