Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
cc3d.h
Go to the documentation of this file.
1 #ifndef CONFIG_CC3D_H
2 #define CONFIG_CC3D_H
3 
4 /* CC3D has a 8MHz external clock and 72MHz internal. */
5 #define EXT_CLK 8000000
6 #define AHB_CLK 72000000
7 
8 /*
9  * Onboard LEDs
10  */
11 
12 /* blue status led, on PB3 */
13 #ifndef USE_LED_1
14 #define USE_LED_1 1
15 #endif
16 #define LED_1_GPIO GPIOB
17 #define LED_1_GPIO_PIN GPIO3
18 #define LED_1_GPIO_ON gpio_clear
19 #define LED_1_GPIO_OFF gpio_set
20 #define LED_1_AFIO_REMAP { \
21  rcc_periph_clock_enable(RCC_AFIO); \
22  AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON; \
23  }
24 
25 
26 /* SPI slave mapping */
27 /* MPU600 on spi1 */
28 #define SPI_SELECT_SLAVE0_PORT GPIOA
29 #define SPI_SELECT_SLAVE0_PIN GPIO4
30 
31 /* 16Mbit flash on spi2 */
32 #define SPI_SELECT_SLAVE1_PORT GPIOB
33 #define SPI_SELECT_SLAVE1_PIN GPIO12
34 
35 /*
36  * UART pin configuration
37  *
38  * sets on which pins the UARTs are connected
39  */
40 /* UART1 on main port */
41 #define UART1_GPIO_AF 0
42 #define UART1_GPIO_PORT_RX GPIO_BANK_USART1_RX
43 #define UART1_GPIO_RX GPIO_USART1_RX
44 #define UART1_GPIO_PORT_TX GPIO_BANK_USART1_TX
45 #define UART1_GPIO_TX GPIO_USART1_TX
46 
47 /* UART3 on Flexi Port */
48 #define UART3_GPIO_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
49 #define UART3_GPIO_PORT_RX GPIO_BANK_USART3_PR_RX
50 #define UART3_GPIO_RX GPIO_USART3_PR_RX
51 #define UART3_GPIO_PORT_TX GPIO_BANK_USART3_PR_TX
52 #define UART3_GPIO_TX GPIO_USART3_PR_TX
53 
54 /*
55  * Spektrum
56  */
57 /* The line that is pulled low at power up to initiate the bind process */
58 /* set to ppm/servo6 input pin on RC connector for now */
59 #define SPEKTRUM_BIND_PIN GPIO1
60 #define SPEKTRUM_BIND_PIN_PORT GPIOA
61 
62 #define SPEKTRUM_UART1_RCC RCC_USART1
63 #define SPEKTRUM_UART1_BANK GPIO_BANK_USART1_RX
64 #define SPEKTRUM_UART1_PIN GPIO_USART1_RX
65 #define SPEKTRUM_UART1_AF 0
66 #define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
67 #define SPEKTRUM_UART1_ISR usart1_isr
68 #define SPEKTRUM_UART1_DEV USART1
69 
70 #define SPEKTRUM_UART3_RCC RCC_USART3
71 #define SPEKTRUM_UART3_BANK GPIO_BANK_USART3_PR_RX
72 #define SPEKTRUM_UART3_PIN GPIO_USART3_PR_RX
73 #define SPEKTRUM_UART3_AF AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP
74 #define SPEKTRUM_UART3_IRQ NVIC_USART3_IRQ
75 #define SPEKTRUM_UART3_ISR usart3_isr
76 #define SPEKTRUM_UART3_DEV USART3
77 
78 
79 /* Pint to set Uart1 RX polarity, on PB2, output high inverts, low doesn't */
80 #define RC_POLARITY_GPIO_PORT GPIOB
81 #define RC_POLARITY_GPIO_PIN GPIO2
82 
83 
84 /* PPM
85  *
86  * Default is PPM config 2, input on GPIOA1: RC input pin 8 (S6_IN)
87  */
88 #ifndef PPM_CONFIG
89 #define PPM_CONFIG 2
90 #endif
91 
92 #if PPM_CONFIG == 1
93 /* input on PB6 (S1_IN) */
94 #define USE_PPM_TIM4 1
95 #define PPM_CHANNEL TIM_IC1
96 #define PPM_TIMER_INPUT TIM_IC_IN_TI1
97 #define PPM_IRQ NVIC_TIM4_UP_IRQ
98 // Capture/Compare InteruptEnable and InterruptFlag
99 #define PPM_CC_IE TIM_DIER_CC1IE
100 #define PPM_CC_IF TIM_SR_CC1IF
101 #define PPM_GPIO_PORT GPIOB
102 #define PPM_GPIO_PIN GPIO6
103 #define PPM_GPIO_AF 0
104 
105 #elif PPM_CONFIG == 2
106 /* input on PA1 (S6_IN) */
107 #define USE_PPM_TIM2 1
108 #define PPM_CHANNEL TIM_IC2
109 #define PPM_TIMER_INPUT TIM_IC_IN_TI2
110 #define PPM_IRQ NVIC_TIM2_IRQ
111 // Capture/Compare InteruptEnable and InterruptFlag
112 #define PPM_CC_IE TIM_DIER_CC2IE
113 #define PPM_CC_IF TIM_SR_CC2IF
114 #define PPM_GPIO_PORT GPIOA
115 #define PPM_GPIO_PIN GPIO1
116 #define PPM_GPIO_AF 0
117 
118 #else
119 #error "Unknown PPM config"
120 #endif // PPM_CONFIG
121 
122 
123 /*
124  * ADC
125  * noting yet, board doesn't seem to have voltage devider for bat measurement
126  */
127 
128 
129 /*
130  * I2C
131  */
132 /* flexi port */
133 #define I2C2_GPIO_PORT GPIOB
134 #define I2C2_GPIO_SCL GPIO10
135 #define I2C2_GPIO_SDA GPIO11
136 
137 
138 /*
139  * PWM
140  * only servos 1-4 enabled for now
141  */
142 /* servos 1-3 */
143 #define PWM_USE_TIM4 1
144 #define USE_PWM1 1
145 #define USE_PWM2 1
146 #define USE_PWM3 1
147 /* servo 4 */
148 #define PWM_USE_TIM1 1
149 #define USE_PWM4 1
150 
151 /* servo 5 */
152 #define PWM_USE_TIM3 0
153 #define USE_PWM5 0
154 /* servo 6 */
155 #define PWM_USE_TIM2 0
156 #define USE_PWM6 0
157 
158 #define ACTUATORS_PWM_NB 4
159 
160 // Servo output numbering on silkscreen starts with 1
161 
162 // PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
163 #if USE_PWM1
164 #define PWM_SERVO_1 0
165 #define PWM_SERVO_1_TIMER TIM4
166 #define PWM_SERVO_1_GPIO GPIOB
167 #define PWM_SERVO_1_PIN GPIO9
168 #define PWM_SERVO_1_AF 0
169 #define PWM_SERVO_1_OC TIM_OC4
170 #define PWM_SERVO_1_OC_BIT (1<<3)
171 #else
172 #define PWM_SERVO_1_OC_BIT 0
173 #endif
174 
175 #if USE_PWM2
176 #define PWM_SERVO_2 1
177 #define PWM_SERVO_2_TIMER TIM4
178 #define PWM_SERVO_2_GPIO GPIOB
179 #define PWM_SERVO_2_PIN GPIO8
180 #define PWM_SERVO_2_AF 0
181 #define PWM_SERVO_2_OC TIM_OC3
182 #define PWM_SERVO_2_OC_BIT (1<<2)
183 #else
184 #define PWM_SERVO_2_OC_BIT 0
185 #endif
186 
187 #if USE_PWM3
188 #define PWM_SERVO_3 2
189 #define PWM_SERVO_3_TIMER TIM4
190 #define PWM_SERVO_3_GPIO GPIOB
191 #define PWM_SERVO_3_PIN GPIO7
192 #define PWM_SERVO_3_AF 0
193 #define PWM_SERVO_3_OC TIM_OC2
194 #define PWM_SERVO_3_OC_BIT (1<<1)
195 #else
196 #define PWM_SERVO_3_OC_BIT 0
197 #endif
198 
199 #if USE_PWM4
200 #define PWM_SERVO_4 3
201 #define PWM_SERVO_4_TIMER TIM1
202 #define PWM_SERVO_4_GPIO GPIOA
203 #define PWM_SERVO_4_PIN GPIO1
204 #define PWM_SERVO_4_AF 0
205 #define PWM_SERVO_4_OC TIM_OC1
206 #define PWM_SERVO_4_OC_BIT (1<<0)
207 #else
208 #define PWM_SERVO_4_OC_BIT 0
209 #endif
210 
211 #if USE_PWM5
212 #define PWM_SERVO_5 4
213 #define PWM_SERVO_5_TIMER TIM3
214 #define PWM_SERVO_5_GPIO GPIOB
215 #define PWM_SERVO_5_PIN GPIO4
216 #define PWM_SERVO_5_AF 0
217 #define PWM_SERVO_5_OC TIM_OC1
218 #define PWM_SERVO_5_OC_BIT (1<<0)
219 #else
220 #define PWM_SERVO_5_OC_BIT 0
221 #endif
222 
223 #if USE_PWM6
224 #define PWM_SERVO_6 5
225 #define PWM_SERVO_6_TIMER TIM2
226 #define PWM_SERVO_6_GPIO GPIOA
227 #define PWM_SERVO_6_PIN GPIO2
228 #define PWM_SERVO_6_AF 0
229 #define PWM_SERVO_6_OC TIM_OC3
230 #define PWM_SERVO_6_OC_BIT (1<<2)
231 #else
232 #define PWM_SERVO_6_OC_BIT 0
233 #endif
234 
235 /* servos 1-3 on TIM4 */
236 #define PWM_TIM4_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_2_OC_BIT|PWM_SERVO_3_OC_BIT)
237 /* servo 4 on TIM1 */
238 #define PWM_TIM1_CHAN_MASK PWM_SERVO_4_OC_BIT
239 /* servo 5 on TIM3 */
240 #define PWM_TIM3_CHAN_MASK PWM_SERVO_5_OC_BIT
241 /* servo 6 on TIM2 */
242 #define PWM_TIM2_CHAN_MASK PWM_SERVO_6_OC_BIT
243 
244 
245 /* Default actuators driver */
246 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
247 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
248 #define ActuatorsDefaultInit() ActuatorsPwmInit()
249 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
250 
251 
252 /* simply always return 5V for now */
253 #define DefaultVoltageOfAdc(adc) (50)
254 
255 
256 #endif /* CONFIG_CC3D_H */