Paparazzi UAS  v5.15_devel-112-g521f3cf
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
px4fmu_1.7.h
Go to the documentation of this file.
1 #ifndef CONFIG_PX4FMU_1_7_H
2 #define CONFIG_PX4FMU_1_7_H
3 
4 #define BOARD_PX4FMU
5 
6 /* PX4 has a 16MHz external clock and 168MHz internal. */
7 #define EXT_CLK 16000000
8 #define AHB_CLK 168000000
9 
10 
11 /*
12  * Onboard LEDs
13  */
14 /* red/amber , on PB14 */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOB
19 #define LED_1_GPIO_PIN GPIO14
20 #define LED_1_GPIO_ON gpio_clear
21 #define LED_1_GPIO_OFF gpio_set
22 #define LED_1_AFIO_REMAP ((void)0)
23 
24 /* blue, on PB15 */
25 #ifndef USE_LED_2
26 #define USE_LED_2 1
27 #endif
28 #define LED_2_GPIO GPIOB
29 #define LED_2_GPIO_PIN GPIO15
30 #define LED_2_GPIO_ON gpio_clear
31 #define LED_2_GPIO_OFF gpio_set
32 #define LED_2_AFIO_REMAP ((void)0)
33 
34 
35 
36 /*
37  * UART
38  */
39 #define UART1_GPIO_AF GPIO_AF7
40 #define UART1_GPIO_PORT_RX GPIOB
41 #define UART1_GPIO_RX GPIO7
42 #define UART1_GPIO_PORT_TX GPIOB
43 #define UART1_GPIO_TX GPIO6
44 
45 #define UART2_GPIO_AF GPIO_AF7
46 #define UART2_GPIO_PORT_RX GPIOA
47 #define UART2_GPIO_RX GPIO3
48 #define UART2_GPIO_PORT_TX GPIOA
49 #define UART2_GPIO_TX GPIO2
50 
51 #define UART6_GPIO_AF GPIO_AF8
52 #define UART6_GPIO_PORT_RX GPIOC
53 #define UART6_GPIO_RX GPIO7
54 #define UART6_GPIO_PORT_TX GPIOC
55 #define UART6_GPIO_TX GPIO6
56 
57 
58 /*
59  * SPI
60  */
61 /* SPI1 for MPU and accel/gyro if populated */
62 #define SPI1_GPIO_AF GPIO_AF5
63 #define SPI1_GPIO_PORT_MISO GPIOA
64 #define SPI1_GPIO_MISO GPIO6
65 #define SPI1_GPIO_PORT_MOSI GPIOA
66 #define SPI1_GPIO_MOSI GPIO7
67 #define SPI1_GPIO_PORT_SCK GPIOA
68 #define SPI1_GPIO_SCK GPIO5
69 
70 /* SPI3 on microSD connector */
71 #define SPI3_GPIO_AF GPIO_AF5
72 #define SPI3_GPIO_PORT_MISO GPIOC
73 #define SPI3_GPIO_MISO GPIO11
74 #define SPI3_GPIO_PORT_MOSI GPIOB
75 #define SPI3_GPIO_MOSI GPIO5
76 #define SPI3_GPIO_PORT_SCK GPIOC
77 #define SPI3_GPIO_SCK GPIO10
78 
79 /*
80  * SPI slave pin declaration
81  */
82 /* GYRO_CS on SPI1 */
83 #define SPI_SELECT_SLAVE0_PORT GPIOC
84 #define SPI_SELECT_SLAVE0_PIN GPIO14
85 
86 /* ACCEL_CS on SPI1 */
87 #define SPI_SELECT_SLAVE1_PORT GPIOC
88 #define SPI_SELECT_SLAVE1_PIN GPIO15
89 
90 /* MPU_CS on SPI1 */
91 #define SPI_SELECT_SLAVE2_PORT GPIOB
92 #define SPI_SELECT_SLAVE2_PIN GPIO0
93 
94 /* SPI3 NSS on microSD connector */
95 #define SPI_SELECT_SLAVE3_PORT GPIOA
96 #define SPI_SELECT_SLAVE3_PIN GPIO4
97 
98 
99 /* Onboard ADCs */
100 #define USE_AD_TIM4 1
101 
102 #define BOARD_ADC_CHANNEL_1 11
103 #define BOARD_ADC_CHANNEL_2 12
104 #define BOARD_ADC_CHANNEL_3 13
105 #define BOARD_ADC_CHANNEL_4 10
106 
107 /* provide defines that can be used to access the ADC_x in the code or airframe file
108  * these directly map to the index number of the 4 adc channels defined above
109  * 4th (index 3) is used for bat monitoring by default
110  */
111 #if USE_ADC_1
112 #define AD1_1_CHANNEL 11
113 #define ADC_1 AD1_1
114 #define ADC_1_GPIO_PORT GPIOC
115 #define ADC_1_GPIO_PIN GPIO1
116 #endif
117 
118 #if USE_ADC_2
119 #define AD1_2_CHANNEL 12
120 #define ADC_2 AD1_2
121 #define ADC_2_GPIO_PORT GPIOC
122 #define ADC_2_GPIO_PIN GPIO2
123 #endif
124 
125 #if USE_ADC_3
126 #define AD1_3_CHANNEL 13
127 #define ADC_3 AD1_3
128 #define ADC_3_GPIO_PORT GPIOC
129 #define ADC_3_GPIO_PIN GPIO3
130 #endif
131 
132 // Internal ADC for battery enabled by default
133 #ifndef USE_ADC_4
134 #define USE_ADC_4 1
135 #endif
136 #if USE_ADC_4
137 #define AD1_4_CHANNEL 10
138 #define ADC_4 AD1_4
139 #define ADC_4_GPIO_PORT GPIOC
140 #define ADC_4_GPIO_PIN GPIO0
141 #endif
142 
143 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
144 #ifndef ADC_CHANNEL_VSUPPLY
145 #define ADC_CHANNEL_VSUPPLY ADC_4
146 #endif
147 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
148 
149 
150 /*
151  * I2C mapping
152  */
153 #define I2C1_GPIO_PORT GPIOB
154 #define I2C1_GPIO_SCL GPIO8
155 #define I2C1_GPIO_SDA GPIO9
156 
157 #define I2C2_GPIO_PORT GPIOB
158 #define I2C2_GPIO_SCL GPIO10
159 #define I2C2_GPIO_SDA GPIO11
160 
161 #define I2C3_GPIO_PORT_SCL GPIOA
162 #define I2C3_GPIO_SCL GPIO8
163 #define I2C3_GPIO_PORT_SDA GPIOC
164 #define I2C3_GPIO_SDA GPIO9
165 
166 
167 /*
168  * PPM
169  */
170 #define USE_PPM_TIM1 1
171 
172 #define PPM_CHANNEL TIM_IC1
173 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
174 #define PPM_IRQ NVIC_TIM1_CC_IRQ
175 #define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
176 // Capture/Compare InteruptEnable and InterruptFlag
177 #define PPM_CC_IE TIM_DIER_CC1IE
178 #define PPM_CC_IF TIM_SR_CC1IF
179 #define PPM_GPIO_PORT GPIOA
180 #define PPM_GPIO_PIN GPIO10
181 #define PPM_GPIO_AF GPIO_AF1
182 
183 
184 /*
185  * Spektrum
186  */
187 /* The line that is pulled low at power up to initiate the bind process */
188 /* GPIO_EXT1 on PX4FMU */
189 #define SPEKTRUM_BIND_PIN GPIO4
190 #define SPEKTRUM_BIND_PIN_PORT GPIOC
191 
192 #define SPEKTRUM_UART2_RCC RCC_USART2
193 #define SPEKTRUM_UART2_BANK GPIOA
194 #define SPEKTRUM_UART2_PIN GPIO3
195 #define SPEKTRUM_UART2_AF GPIO_AF7
196 #define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
197 #define SPEKTRUM_UART2_ISR usart2_isr
198 #define SPEKTRUM_UART2_DEV USART2
199 
200 
201 
202 /* Activate onboard baro by default */
203 #ifndef USE_BARO_BOARD
204 #define USE_BARO_BOARD 1
205 #endif
206 
207 
208 /* Default actuators driver */
209 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
210 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
211 #define ActuatorsDefaultInit() ActuatorsPwmInit()
212 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
213 
214 /* PWM */
215 #define PWM_USE_TIM2 1
216 
217 #define USE_PWM1 1
218 #define USE_PWM2 1
219 #define USE_PWM3 1
220 #define USE_PWM4 1
221 
222 // Servo numbering on the PX4 starts with 1
223 
224 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
225 // SRV1 is also UART2_CTS
226 #if USE_PWM1
227 #define PWM_SERVO_1 0
228 #define PWM_SERVO_1_TIMER TIM2
229 #define PWM_SERVO_1_GPIO GPIOA
230 #define PWM_SERVO_1_PIN GPIO0
231 #define PWM_SERVO_1_AF GPIO_AF1
232 #define PWM_SERVO_1_OC TIM_OC1
233 #define PWM_SERVO_1_OC_BIT (1<<0)
234 #else
235 #define PWM_SERVO_1_OC_BIT 0
236 #endif
237 
238 // SRV2 is also UART2_RTS
239 #if USE_PWM2
240 #define PWM_SERVO_2 1
241 #define PWM_SERVO_2_TIMER TIM2
242 #define PWM_SERVO_2_GPIO GPIOA
243 #define PWM_SERVO_2_PIN GPIO1
244 #define PWM_SERVO_2_AF GPIO_AF1
245 #define PWM_SERVO_2_OC TIM_OC2
246 #define PWM_SERVO_2_OC_BIT (1<<1)
247 #else
248 #define PWM_SERVO_2_OC_BIT 0
249 #endif
250 
251 // SRV3 is also UART2_TX
252 #if USE_PWM3
253 #define PWM_SERVO_3_IDX 2
254 #define PWM_SERVO_3_TIMER TIM2
255 #define PWM_SERVO_3_GPIO GPIOA
256 #define PWM_SERVO_3_PIN GPIO2
257 #define PWM_SERVO_3_AF GPIO_AF1
258 #define PWM_SERVO_3_OC TIM_OC3
259 #define PWM_SERVO_3_OC_BIT (1<<2)
260 #else
261 #define PWM_SERVO_3_OC_BIT 0
262 #endif
263 
264 // SRV4 is also UART2_RX
265 #if USE_PWM4
266 #define PWM_SERVO_4 3
267 #define PWM_SERVO_4_TIMER TIM2
268 #define PWM_SERVO_4_GPIO GPIOA
269 #define PWM_SERVO_4_PIN GPIO3
270 #define PWM_SERVO_4_AF GPIO_AF1
271 #define PWM_SERVO_4_OC TIM_OC4
272 #define PWM_SERVO_4_OC_BIT (1<<3)
273 #else
274 #define PWM_SERVO_4_OC_BIT 0
275 #endif
276 
277 
278 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
279 
280 
281 #endif /* CONFIG_PX4FMU_1_7_H */