Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
px4io_2.4.h
Go to the documentation of this file.
1 #ifndef CONFIG_PX4IO_2_4_H
2 #define CONFIG_PX4IO_2_4_H
3 
4 #define BOARD_PX4IO
5 //STM32F103c8t6 (medium density!)
6 
7 /* Pixhawk board (PX4FIOv2 has a 24MHz external clock and 24MHz internal. */
8 #define EXT_CLK 24000000 //this osc is actually outside of the specs (max 16MHz)
9 #define AHB_CLK 24000000
10 
11 
12 /*
13  * LEDs
14  */
15 /* blue led, a.k.a. ACT */
16 #ifndef USE_LED_1
17 #define USE_LED_1 1
18 #endif
19 #define LED_1_GPIO GPIOB
20 #define LED_1_GPIO_PIN GPIO14
21 #define LED_1_GPIO_ON gpio_clear
22 #define LED_1_GPIO_OFF gpio_set
23 #define LED_1_AFIO_REMAP ((void)0)
24 
25 //led Amber a.k.a b/e led
26 #ifndef USE_LED_2
27 #define USE_LED_2 1
28 #endif
29 #define LED_2_GPIO GPIOB
30 #define LED_2_GPIO_PIN GPIO15
31 #define LED_2_GPIO_ON gpio_clear
32 #define LED_2_GPIO_OFF gpio_set
33 #define LED_2_AFIO_REMAP ((void)0)
34 
35 //safety led in the switch, red
36 #ifndef USE_LED_3
37 #define USE_LED_3 1
38 #endif
39 #define LED_3_GPIO GPIOB
40 #define LED_3_GPIO_PIN GPIO13
41 #define LED_3_GPIO_ON gpio_clear
42 #define LED_3_GPIO_OFF gpio_set
43 #define LED_3_AFIO_REMAP ((void)0)
44 
45 //TODO: safety switch is on PB5!
46 
47 /*
48  * UART
49 */
50 
51 // fmu debug / spektrum receiver (only rx)
52 #define UART1_GPIO_AF 0
53 #define UART1_GPIO_PORT_RX GPIOA
54 #define UART1_GPIO_RX GPIO10
55 #define UART1_GPIO_PORT_TX GPIOA
56 #define UART1_GPIO_TX GPIO9
57 // intermcu fmu
58 #define UART2_GPIO_AF 0
59 #define UART2_GPIO_PORT_RX GPIOA
60 #define UART2_GPIO_RX GPIO3
61 #define UART2_GPIO_PORT_TX GPIOA
62 #define UART2_GPIO_TX GPIO2
63 
64 
65 /*
66  * Spektrum
67  */
68 /* The line that is pulled low at power up to initiate the bind process */
69 #define RADIO_CONTROL_POWER GPIOC
70 #define RADIO_CONTROL_POWER_PIN GPIO13
71 #define RADIO_CONTROL_POWER_ON gpio_clear
72 #define RADIO_CONTROL_POWER_OFF gpio_set
73 
74 #define SPEKTRUM_TIMER 3
75 
76 #define SPEKTRUM_UART1_RCC RCC_USART1
77 #define SPEKTRUM_UART1_BANK GPIOA
78 #define SPEKTRUM_UART1_PIN GPIO10
79 #define SPEKTRUM_UART1_AF 0
80 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
81 #define SPEKTRUM_UART1_ISR usart1_isr
82 #define SPEKTRUM_UART1_DEV USART1
83 
84 
85 /*
86  * PPM input
87  */
88 #define USE_PPM_TIM1 1
89 #define PPM_CHANNEL TIM_IC1
90 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
91 #define PPM_IRQ NVIC_TIM1_UP_IRQ
92 #define PPM_IRQ2 NVIC_TIM1_CC_IRQ
93 // Capture/Compare InteruptEnable and InterruptFlag
94 #define PPM_CC_IE TIM_DIER_CC1IE
95 #define PPM_CC_IF TIM_SR_CC1IF
96 #define PPM_GPIO_PORT GPIOA
97 #define PPM_GPIO_PIN GPIO8
98 #define PPM_GPIO_AF 0
99 
100 //#define USE_AD_TIM1 1
101 #ifndef USE_ADC_1
102 #define USE_ADC_1 0
103 #endif
104 #if USE_ADC_1 // VDD servo ADC12_IN4, untested
105 #define AD1_1_CHANNEL 12
106 #define ADC_1 AD1_4
107 #define ADC_1_GPIO_PORT GPIOA
108 #define ADC_1_GPIO_PIN GPIO4
109 #endif
110 
111 /*
112  * PWM
113  *
114  */
115 //sevo outputs on px4io f1:
116 //chn: 1 2 3 4 5 6 7 8
117 //pin: A0 A1 B8 B9 A6 A7 B0 B1
118 //timer/channel: 2/1 2/2 4/3 4/4 3/1 3/2 3/3 3/4
119 #define PWM_USE_TIM2 1
120 //#define PWM_USE_TIM3 1 // spektrum already uses tim3
121 #define PWM_USE_TIM4 1
122 
123 //#define ACTUATORS_PWM_NB 4
124 
125 #define USE_PWM1 1
126 #define USE_PWM2 1
127 #define USE_PWM3 1
128 #define USE_PWM4 1
129 //#define USE_PWM5 1
130 //#define USE_PWM6 1
131 //#define USE_PWM7 1
132 //#define USE_PWM8 1
133 
134 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
135 #if USE_PWM1
136 #define PWM_SERVO_1 0
137 #define PWM_SERVO_1_TIMER TIM2
138 #define PWM_SERVO_1_GPIO GPIOA
139 #define PWM_SERVO_1_PIN GPIO0
140 #define PWM_SERVO_1_AF 0
141 #define PWM_SERVO_1_OC TIM_OC1
142 #define PWM_SERVO_1_OC_BIT (1<<0)
143 #else
144 #define PWM_SERVO_1_OC_BIT 0
145 #endif
146 
147 #if USE_PWM2
148 #define PWM_SERVO_2 1
149 #define PWM_SERVO_2_TIMER TIM2
150 #define PWM_SERVO_2_GPIO GPIOA
151 #define PWM_SERVO_2_PIN GPIO1
152 #define PWM_SERVO_2_AF 0
153 #define PWM_SERVO_2_OC TIM_OC2
154 #define PWM_SERVO_2_OC_BIT (1<<1)
155 #else
156 #define PWM_SERVO_2_OC_BIT 0
157 #endif
158 
159 #if USE_PWM3
160 #define PWM_SERVO_3 2
161 #define PWM_SERVO_3_TIMER TIM4
162 #define PWM_SERVO_3_GPIO GPIOB
163 #define PWM_SERVO_3_PIN GPIO8
164 #define PWM_SERVO_3_AF 0
165 #define PWM_SERVO_3_OC TIM_OC3
166 #define PWM_SERVO_3_OC_BIT (1<<2)
167 #else
168 #define PWM_SERVO_3_OC_BIT 0
169 #endif
170 
171 #if USE_PWM4
172 #define PWM_SERVO_4 3
173 #define PWM_SERVO_4_TIMER TIM4
174 #define PWM_SERVO_4_GPIO GPIOB
175 #define PWM_SERVO_4_PIN GPIO9
176 #define PWM_SERVO_4_AF 0
177 #define PWM_SERVO_4_OC TIM_OC4
178 #define PWM_SERVO_4_OC_BIT (1<<3)
179 #else
180 #define PWM_SERVO_4_OC_BIT 0
181 #endif
182 
183 #if USE_PWM5
184 #define PWM_SERVO_5 4
185 #define PWM_SERVO_5_TIMER TIM3
186 #define PWM_SERVO_5_GPIO GPIOA
187 #define PWM_SERVO_5_PIN GPIO6
188 #define PWM_SERVO_5_AF 0
189 #define PWM_SERVO_5_OC TIM_OC1
190 #define PWM_SERVO_5_OC_BIT (1<<0)
191 #else
192 #define PWM_SERVO_5_OC_BIT 0
193 #endif
194 
195 #if USE_PWM6
196 #define PWM_SERVO_6 5
197 #define PWM_SERVO_6_TIMER TIM3
198 #define PWM_SERVO_6_GPIO GPIOA
199 #define PWM_SERVO_6_PIN GPIO7
200 #define PWM_SERVO_6_AF 0
201 #define PWM_SERVO_6_OC TIM_OC2
202 #define PWM_SERVO_6_OC_BIT (1<<1)
203 #else
204 #define PWM_SERVO_6_OC_BIT 0
205 #endif
206 
207 #if USE_PWM7
208 #define PWM_SERVO_7 6
209 #define PWM_SERVO_7_TIMER TIM3
210 #define PWM_SERVO_7_GPIO GPIOB
211 #define PWM_SERVO_7_PIN GPIO0
212 #define PWM_SERVO_7_AF 0
213 #define PWM_SERVO_7_OC TIM_OC3
214 #define PWM_SERVO_7_OC_BIT (1<<2)
215 #else
216 #define PWM_SERVO_7_OC_BIT 0
217 #endif
218 
219 #if USE_PWM8
220 #define PWM_SERVO_8 7
221 #define PWM_SERVO_8_TIMER TIM3
222 #define PWM_SERVO_8_GPIO GPIOB
223 #define PWM_SERVO_8_PIN GPIO1
224 #define PWM_SERVO_8_AF 0
225 #define PWM_SERVO_8_OC TIM_OC4
226 #define PWM_SERVO_8_OC_BIT (1<<3)
227 #else
228 #define PWM_SERVO_8_OC_BIT 0
229 #endif
230 
231 /* servos 1-2 on TIM2 */
232 #define PWM_TIM2_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT)
233 /* servos 3-4 on TIM4 */
234 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
235 /* servos 5-8 on TIM3 */
236 //#define PWM_TIM3_CHAN_MASK (PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT|PWM_SERVO_7_OC_BIT|PWM_SERVO_8_OC_BIT)
237 
238 /* Default actuators driver */
239 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
240 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
241 #define ActuatorsDefaultInit() ActuatorsPwmInit()
242 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
243 
244 
245 #endif /* CONFIG_PX4IO_2_4_H */