Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
cjmcu.h
Go to the documentation of this file.
1 #ifndef CONFIG_CJMCU_H
2 #define CONFIG_CJMCU_H
3 
4 #define BOARD_CJMCU
5 
6 /* CJMCU has a 8MHz external clock and 72MHz internal. */
7 #define EXT_CLK 8000000
8 #define AHB_CLK 72000000
9 
10 /*
11  * Onboard LEDs
12  */
13 
14 /* green */
15 #ifndef USE_LED_1
16 #define USE_LED_1 1
17 #endif
18 #define LED_1_GPIO GPIOC
19 #define LED_1_GPIO_PIN GPIO13
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 /* red */
25 #ifndef USE_LED_2
26 #define USE_LED_2 1
27 #endif
28 #define LED_2_GPIO GPIOC
29 #define LED_2_GPIO_PIN GPIO14
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 /* blue */
35 #ifndef USE_LED_3
36 #define USE_LED_3 1
37 #endif
38 #define LED_3_GPIO GPIOC
39 #define LED_3_GPIO_PIN GPIO15
40 #define LED_3_GPIO_ON gpio_clear
41 #define LED_3_GPIO_OFF gpio_set
42 #define LED_3_AFIO_REMAP ((void)0)
43 
44 
45 
46 /* Default actuators driver */
47 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
48 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
49 #define ActuatorsDefaultInit() ActuatorsPwmInit()
50 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
51 
52 
53 /*
54  * ADC
55  */
56 
57 // Internal ADC for battery on PA2 enabled by default
58 #ifndef USE_ADC_1
59 #define USE_ADC_1 1
60 #endif
61 #if USE_ADC_1
62 #define AD1_1_CHANNEL 2
63 #define ADC_1 AD1_1
64 #define ADC_1_GPIO_PORT GPIOA
65 #define ADC_1_GPIO_PIN GPIO2
66 #endif
67 
68 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
69 #ifndef ADC_CHANNEL_VSUPPLY
70 #define ADC_CHANNEL_VSUPPLY ADC_1
71 #endif
72 
73 /* 10k/2k resistor divider, 6 * 3.3V / 4096 */
74 #define DefaultVoltageOfAdc(adc) (0.0049*adc)
75 //#define DefaultVoltageOfAdc(adc) (4)
76 
77 /*
78  * UART pin configuration
79  *
80  * sets on which pins the UARTs are connected
81  */
82 /* DIAG port */
83 #define UART1_GPIO_AF 0
84 #define UART1_GPIO_PORT_RX GPIO_BANK_USART1_RX
85 #define UART1_GPIO_RX GPIO_USART1_RX
86 #define UART1_GPIO_PORT_TX GPIO_BANK_USART1_TX
87 #define UART1_GPIO_TX GPIO_USART1_TX
88 
89 /* GPS */
90 #define UART3_GPIO_AF 0
91 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_RX
92 #define UART3_GPIO_RX GPIO_USART3_RX
93 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_TX
94 #define UART3_GPIO_TX GPIO_USART3_TX
95 
96 /* LED1 & LED2 */
97 /*
98 #define UART3_GPIO_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
99 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_PR_RX
100 #define UART3_GPIO_RX GPIO_USART3_PR_RX
101 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_PR_TX
102 #define UART3_GPIO_TX GPIO_USART3_PR_TX
103 */
104 
105 /*
106  * Spektrum (none)
107  */
108 
109 /* PPM
110  */
111 
112 /*
113  * Default is PPM config 1, input on PA0
114  */
115 
116 #ifndef PPM_CONFIG
117 #define PPM_CONFIG 1
118 #endif
119 
120 
121 #if PPM_CONFIG == 1
122 /* input on PA0 */
123 #define USE_PPM_TIM2 1
124 #define PPM_CHANNEL TIM_IC1
125 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
126 #define PPM_IRQ NVIC_TIM2_IRQ
127 // Capture/Compare InteruptEnable and InterruptFlag
128 #define PPM_CC_IE TIM_DIER_CC1IE
129 #define PPM_CC_IF TIM_SR_CC1IF
130 #define PPM_GPIO_PORT GPIOA
131 #define PPM_GPIO_PIN GPIO0
132 #define PPM_GPIO_AF 0
133 
134 // Move default ADC timer
135 #if USE_AD_TIM2
136 #undef USE_AD_TIM2
137 #endif
138 #define USE_AD_TIM1 1
139 
140 #elif PPM_CONFIG == 2
141 /* input on PA1 */
142 #define USE_PPM_TIM2 1
143 #define PPM_CHANNEL TIM_IC2
144 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
145 #define PPM_IRQ NVIC_TIM2_IRQ
146 // Capture/Compare InteruptEnable and InterruptFlag
147 #define PPM_CC_IE TIM_DIER_CC2IE
148 #define PPM_CC_IF TIM_SR_CC2IF
149 #define PPM_GPIO_PORT GPIOA
150 #define PPM_GPIO_PIN GPIO1
151 #define PPM_GPIO_AF 0
152 
153 // Move default ADC timer
154 #if USE_AD_TIM2
155 #undef USE_AD_TIM2
156 #endif
157 #define USE_AD_TIM1 1
158 
159 #elif PPM_CONFIG == 3
160 /* input on PA3 */
161 #define USE_PPM_TIM2 1
162 #define PPM_CHANNEL TIM_IC4
163 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
164 #define PPM_IRQ NVIC_TIM2_IRQ
165 // Capture/Compare InteruptEnable and InterruptFlag
166 #define PPM_CC_IE TIM_DIER_CC4IE
167 #define PPM_CC_IF TIM_SR_CC4IF
168 #define PPM_GPIO_PORT GPIOA
169 #define PPM_GPIO_PIN GPIO3
170 #define PPM_GPIO_AF 0
171 
172 // Move default ADC timer
173 #if USE_AD_TIM2
174 #undef USE_AD_TIM2
175 #endif
176 #define USE_AD_TIM1 1
177 
178 #else
179 #error "Unknown PPM config"
180 
181 #endif // PPM_CONFIG
182 
183 /*
184  * I2C
185  *
186  */
187 #define I2C1_GPIO_PORT GPIOB
188 #define I2C1_GPIO_SCL GPIO6
189 #define I2C1_GPIO_SDA GPIO7
190 
191 /* GPS TX & RX */
192 #define I2C2_GPIO_PORT GPIOB
193 #define I2C2_GPIO_SCL GPIO10
194 #define I2C2_GPIO_SDA GPIO11
195 
196 /*
197  * PWM
198  *
199  */
200 #define PWM_USE_TIM4 1
201 #define PWM_USE_TIM3 1
202 
203 #define USE_PWM1 1
204 #define USE_PWM2 1
205 #define USE_PWM3 1
206 #define USE_PWM4 1
207 
208 /* PWM_SERVO_x is the index of the servo in the actuators_pwm_values array */
209 #if USE_PWM1
210 #define PWM_SERVO_1 0
211 #define PWM_SERVO_1_TIMER TIM4
212 #define PWM_SERVO_1_GPIO GPIOB
213 #define PWM_SERVO_1_PIN GPIO8
214 #define PWM_SERVO_1_AF 0
215 #define PWM_SERVO_1_OC TIM_OC3
216 #define PWM_SERVO_1_OC_BIT (1<<2)
217 #else
218 #define PWM_SERVO_1_OC_BIT 0
219 #endif
220 
221 #if USE_PWM2
222 #define PWM_SERVO_2 1
223 #define PWM_SERVO_2_TIMER TIM4
224 #define PWM_SERVO_2_GPIO GPIOB
225 #define PWM_SERVO_2_PIN GPIO9
226 #define PWM_SERVO_2_AF 0
227 #define PWM_SERVO_2_OC TIM_OC4
228 #define PWM_SERVO_2_OC_BIT (1<<3)
229 #else
230 #define PWM_SERVO_2_OC_BIT 0
231 #endif
232 
233 #if USE_PWM3
234 #define PWM_SERVO_3 2
235 #define PWM_SERVO_3_TIMER TIM3
236 #define PWM_SERVO_3_GPIO GPIOB
237 #define PWM_SERVO_3_PIN GPIO0
238 #define PWM_SERVO_3_AF 0
239 #define PWM_SERVO_3_OC TIM_OC3
240 #define PWM_SERVO_3_OC_BIT (1<<2)
241 #else
242 #define PWM_SERVO_3_OC_BIT 0
243 #endif
244 
245 #if USE_PWM4
246 #define PWM_SERVO_4 3
247 #define PWM_SERVO_4_TIMER TIM3
248 #define PWM_SERVO_4_GPIO GPIOB
249 #define PWM_SERVO_4_PIN GPIO1
250 #define PWM_SERVO_4_AF 0
251 #define PWM_SERVO_4_OC TIM_OC4
252 #define PWM_SERVO_4_OC_BIT (1<<3)
253 #else
254 #define PWM_SERVO_4_OC_BIT 0
255 #endif
256 
257 
258 
259 /* servos 1-2 on TIM4 */
260 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT)
261 /* servos 3-4 on TIM3 */
262 #define PWM_TIM3_CHAN_MASK (PWM_SERVO_3_OC_BIT|PWM_SERVO_4_OC_BIT)
263 
264 
265 #endif /* CONFIG_CJMCU_H */