2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program 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 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 /* 8MHz High speed external crystal */
23 #define AO_HSE 8000000
25 /* PLLVCO = 96MHz (so that USB will work) */
27 #define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12)
29 #define AO_CC1200_FOSC 32000000
31 /* SYSCLK = 32MHz (no need to go faster than CPU) */
33 #define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3)
35 /* HCLK = 32MHz (CPU clock) */
36 #define AO_AHB_PRESCALER 1
37 #define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
39 /* Run APB1 at 16MHz (HCLK/2) */
40 #define AO_APB1_PRESCALER 2
41 #define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2
43 /* Run APB2 at 16MHz (HCLK/2) */
44 #define AO_APB2_PRESCALER 2
45 #define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2
48 #define USE_INTERNAL_FLASH 1
49 #define USE_EEPROM_CONFIG 1
50 #define USE_STORAGE_CONFIG 0
53 #define BEEPER_TIMER 3
54 #define BEEPER_CHANNEL 1
55 #define BEEPER_PORT (&stm_gpioc)
58 #define HAS_RADIO_RATE 1
59 #define HAS_TELEMETRY 0
61 #define HAS_STATIC_TEST 0
65 #define SPI_1_PA5_PA6_PA7 0
66 #define SPI_1_PB3_PB4_PB5 0
67 #define SPI_1_PE13_PE14_PE15 0
69 #define HAS_SPI_2 1 /* CC1120 */
70 #define SPI_2_PB13_PB14_PB15 0
71 #define SPI_2_PD1_PD3_PD4 1
72 #define SPI_2_GPIO (&stm_gpiod)
76 #define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
82 #define PACKET_HAS_SLAVE 0
83 #define PACKET_HAS_MASTER 0
85 #define FAST_TIMER_FREQ 10000 /* .1ms for debouncing */
88 * Radio is a cc1200 connected via SPI
91 #define AO_RADIO_CAL_DEFAULT 5695733
93 #define AO_FEC_DEBUG 0
94 #define AO_CC1200_SPI_CS_PORT (&stm_gpiod)
95 #define AO_CC1200_SPI_CS_PIN 0
96 #define AO_CC1200_SPI_BUS AO_SPI_2_PD1_PD3_PD4
97 #define AO_CC1200_SPI stm_spi2
99 #define AO_CC1200_INT_PORT (&stm_gpioc)
100 #define AO_CC1200_INT_PIN (15)
102 #define AO_CC1200_INT_GPIO 2
103 #define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2
105 #define LOW_LEVEL_DEBUG 0
107 #define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOCEN
108 #define LED_PORT (&stm_gpioc)
109 #define LED_PIN_RED 7
110 #define LED_PIN_AMBER 8
111 #define LED_PIN_GREEN 9
112 #define LED_PIN_CONTINUITY_3 10
113 #define LED_PIN_CONTINUITY_2 11
114 #define LED_PIN_CONTINUITY_1 12
115 #define LED_PIN_CONTINUITY_0 13
116 #define LED_PIN_REMOTE_ARM 14
117 #define AO_LED_RED (1 << LED_PIN_RED)
118 #define AO_LED_AMBER (1 << LED_PIN_AMBER)
119 #define AO_LED_GREEN (1 << LED_PIN_GREEN)
120 #define AO_LED_CONTINUITY_3 (1 << LED_PIN_CONTINUITY_3)
121 #define AO_LED_CONTINUITY_2 (1 << LED_PIN_CONTINUITY_2)
122 #define AO_LED_CONTINUITY_1 (1 << LED_PIN_CONTINUITY_1)
123 #define AO_LED_CONTINUITY_0 (1 << LED_PIN_CONTINUITY_0)
125 #define AO_LED_CONTINUITY_NUM 4
127 #define AO_LED_REMOTE_ARM (1 << LED_PIN_REMOTE_ARM)
129 #define LEDS_AVAILABLE (AO_LED_RED | \
132 AO_LED_CONTINUITY_3 | \
133 AO_LED_CONTINUITY_2 | \
134 AO_LED_CONTINUITY_1 | \
135 AO_LED_CONTINUITY_0 | \
141 #define SEVEN_SEGMENT_DEBUG 0
143 #define AO_LCD_STM_SEG_ENABLED_0 ( \
144 (1 << 0) | /* PA1 */ \
145 (1 << 1) | /* PA2 */ \
146 (1 << 2) | /* PA3 */ \
147 (1 << 3) | /* PA6 */ \
148 (1 << 4) | /* PA7 */ \
149 (1 << 5) | /* PB0 */ \
150 (1 << 6) | /* PB1 */ \
151 (1 << 7) | /* PB3 */ \
152 (1 << 8) | /* PB4 */ \
153 (1 << 9) | /* PB5 */ \
154 (1 << 10) | /* PB10 */ \
155 (1 << 11) | /* PB11 */ \
156 (1 << 12) | /* PB12 */ \
157 (1 << 13) | /* PB13 */ \
158 (1 << 14) | /* PB14 */ \
159 (1 << 15) | /* PB15 */ \
160 (1 << 16) | /* PB8 */ \
161 (1 << 17) | /* PA15 */ \
162 (1 << 18) | /* PC0 */ \
163 (1 << 19) | /* PC1 */ \
164 (1 << 20) | /* PC2 */ \
165 (1 << 21) | /* PC3 */ \
166 (1 << 22) | /* PC4 */ \
167 (1 << 23) | /* PC5 */ \
168 (0 << 24) | /* PC6 */ \
169 (0 << 25) | /* PC7 */ \
170 (0 << 26) | /* PC8 */ \
171 (0 << 27) | /* PC9 */ \
172 (0 << 28) | /* PC10 or PD8 */ \
173 (0 << 29) | /* PC11 or PD9 */ \
174 (0 << 30) | /* PC12 or PD10 */ \
175 (0 << 31)) /* PD2 or PD11 */
177 #define AO_LCD_STM_SEG_ENABLED_1 ( \
178 (0 << 0) | /* PD12 */ \
179 (0 << 1) | /* PD13 */ \
180 (0 << 2) | /* PD14 */ \
181 (0 << 3) | /* PD15 */ \
182 (0 << 4) | /* PE0 */ \
183 (0 << 5) | /* PE1 */ \
184 (0 << 6) | /* PE2 */ \
187 #define AO_LCD_STM_COM_ENABLED ( \
188 (1 << 0) | /* PA8 */ \
189 (0 << 1) | /* PA9 */ \
190 (0 << 2) | /* PA10 */ \
191 (0 << 3) | /* PB9 */ \
192 (0 << 4) | /* PC10 */ \
193 (0 << 5) | /* PC11 */ \
196 #define AO_LCD_28_ON_C 0
198 #define AO_LCD_DUTY STM_LCD_CR_DUTY_STATIC
200 #define AO_LCD_PER_DIGIT 1
202 #define AO_LCD_DIGITS 3
203 #define AO_LCD_SEGMENTS 8
205 #define AO_SEGMENT_MAP { \
215 /* box1 segments */ \
224 /* box0 segments */ \
236 * Use event queue for input devices
245 #define AO_QUADRATURE_COUNT 2
247 #define AO_QUADRATURE_0_PORT &stm_gpioe
248 #define AO_QUADRATURE_0_A 3
249 #define AO_QUADRATURE_0_B 2
251 #define AO_QUADRATURE_PAD 0
253 #define AO_QUADRATURE_1_PORT &stm_gpioe
254 #define AO_QUADRATURE_1_A 1
255 #define AO_QUADRATURE_1_B 0
257 #define AO_QUADRATURE_BOX 1
258 #define AO_QUADRATURE_DEBOUNCE 10
264 #define AO_BUTTON_COUNT 2
265 #define AO_BUTTON_MODE AO_EXTI_MODE_PULL_UP
267 #define AO_BUTTON_0_PORT &stm_gpioe
268 #define AO_BUTTON_0 4
270 #define AO_BUTTON_ARM 0
272 #define AO_BUTTON_1_PORT &stm_gpioe
273 #define AO_BUTTON_1 5
275 #define AO_BUTTON_FIRE 1
279 #define HAS_ADC_SINGLE 1
280 #define HAS_BATTERY_REPORT 1
289 #define AO_ADC_DUMP(p) \
290 printf("batt: %5d temp: %5d v_ref: %5d\n", \
291 (p)->v_batt, (p)->temp, (p)->v_ref)
294 #define AO_ADC_DUMP(p) \
295 printf("%5d: batt: %5d temp %5d v_ref %5d\n", \
296 (p)->tick, (p)->adc.v_batt, (p)->adc.temp, (p)->adc.v_ref)
299 #define HAS_ADC_TEMP 1
301 #define AO_ADC_V_BATT 0
302 #define AO_ADC_V_BATT_PORT (&stm_gpioa)
303 #define AO_ADC_V_BATT_PIN 0
305 #define AO_ADC_RCC_AHBENR (1 << STM_RCC_AHBENR_GPIOAEN)
307 #define AO_ADC_PIN0_PORT AO_ADC_V_BATT_PORT
308 #define AO_ADC_PIN0_PIN AO_ADC_V_BATT_PIN
310 #define AO_ADC_SQ1 AO_ADC_V_BATT
311 #define AO_ADC_SQ2 STM_ADC_SQ_TEMP
312 #define AO_ADC_SQ3 STM_ADC_SQ_V_REF
317 * Voltage divider on ADC battery sampler
319 #define AO_BATTERY_DIV_PLUS 15 /* 15k */
320 #define AO_BATTERY_DIV_MINUS 27 /* 27k */
323 * ADC reference in decivolts
325 #define AO_ADC_REFERENCE_DV 33
327 #endif /* _AO_PINS_H_ */