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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 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 /* SYSCLK = 32MHz (no need to go faster than CPU) */
31 #define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3)
33 /* HCLK = 32MHz (CPU clock) */
34 #define AO_AHB_PRESCALER 1
35 #define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
37 /* Run APB1 at 16MHz (HCLK/2) */
38 #define AO_APB1_PRESCALER 2
39 #define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2
41 /* Run APB2 at 16MHz (HCLK/2) */
42 #define AO_APB2_PRESCALER 2
43 #define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2
45 #define HAS_SERIAL_1 1
46 #define USE_SERIAL_1_STDIN 0
47 #define SERIAL_1_PB6_PB7 0
48 #define SERIAL_1_PA9_PA10 1
50 #define HAS_SERIAL_2 0
51 #define USE_SERIAL_2_STDIN 0
52 #define SERIAL_2_PA2_PA3 0
53 #define SERIAL_2_PD5_PD6 0
55 #define HAS_SERIAL_3 0
56 #define USE_SERIAL_3_STDIN 0
57 #define SERIAL_3_PB10_PB11 0
58 #define SERIAL_3_PC10_PC11 1
59 #define SERIAL_3_PD8_PD9 0
62 #define USE_INTERNAL_FLASH 0
66 #define HAS_TELEMETRY 0
69 #define SPI_1_PA5_PA6_PA7 0
70 #define SPI_1_PB3_PB4_PB5 0
71 #define SPI_1_PE13_PE14_PE15 1 /* */
72 #define SPI_1_OSPEEDR STM_OSPEEDR_10MHz
75 #define SPI_2_PB13_PB14_PB15 1 /* */
76 #define SPI_2_PD1_PD3_PD4 0
77 #define SPI_2_OSPEEDR STM_OSPEEDR_10MHz
78 #define HAS_STORAGE_DEBUG 1
80 #define SPI_2_PORT (&stm_gpiob)
81 #define SPI_2_SCK_PIN 13
82 #define SPI_2_MISO_PIN 14
83 #define SPI_2_MOSI_PIN 15
86 #define I2C_1_PB6_PB7 1
87 #define I2C_1_PB8_PB9 0
90 #define I2C_2_PB10_PB11 1
92 #define PACKET_HAS_SLAVE 0
93 #define PACKET_HAS_MASTER 0
95 #define LOW_LEVEL_DEBUG 0
97 #define LED_PORT_0_ENABLE STM_RCC_AHBENR_GPIOCEN
98 #define LED_PORT_0 (&stm_gpioc)
99 #define LED_PORT_0_MASK (0xff)
100 #define LED_PORT_0_SHIFT 0
101 #define LED_PIN_RED 6
102 #define LED_PIN_GREEN 7
103 #define LED_PIN_RED_2 8
104 #define LED_PIN_GREEN_2 9
105 #define AO_LED_RED (1 << LED_PIN_RED)
106 #define AO_LED_GREEN (1 << LED_PIN_GREEN)
107 #define AO_LED_RED_2 (1 << LED_PIN_RED_2)
108 #define AO_LED_GREEN_2 (1 << LED_PIN_GREEN_2)
110 #define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN | AO_LED_RED_2 | AO_LED_GREEN_2)
115 #define HAS_ADC_TEMP 1
121 #define AO_DATA_RING 32
124 int16_t tx_pa_current; /* 0 ADC_IN0 */
125 int16_t tx_temp; /* 1 ADC_IN1 */
126 int16_t exp4_temp; /* 2 ADC_IN2 */
127 int16_t rx_temp; /* 3 ADC_IN3 */
128 int16_t tx_analog_1; /* 4 ADC_IN4 */
129 int16_t sense_batt; /* 5 ADC_IN5 */
130 int16_t rx_analog_1; /* 6 ADC_IN6 */
131 int16_t rx_rssi; /* 7 ADC_IN8 */
132 int16_t rx_cd; /* 8 ADC_IN9 */
133 int16_t ant_sense_1; /* 9 ADC_IN10 */
134 int16_t ant_sense_2; /* 10 ADC_IN11 */
135 int16_t gyro_x_1; /* 11 ADC_IN12 */
136 int16_t gyro_z_1; /* 12 ADC_IN13 */
137 int16_t gyro_vref_1; /* 13 ADC_IN24 */
138 int16_t gyro_x_2; /* 14 ADC_IN14 */
139 int16_t gyro_z_2; /* 15 ADC_IN15 */
140 int16_t gyro_vref_2; /* 16 ADC_IN25 */
143 #define AO_ADC_TX_PA_CURRENT 0
144 #define AO_ADC_TX_PA_CURRENT_PORT (&stm_gpioa)
145 #define AO_ADC_TX_PA_CURRENT_PIN 0
147 #define AO_ADC_TX_TEMP 1
148 #define AO_ADC_TX_TEMP_PORT (&stm_gpioa)
149 #define AO_ADC_TX_TEMP_PIN 1
151 #define AO_ADC_EXP4_TEMP 2
152 #define AO_ADC_EXP4_TEMP_PORT (&stm_gpioa)
153 #define AO_ADC_EXP4_TEMP_PIN 2
155 #define AO_ADC_RX_TEMP 3
156 #define AO_ADC_RX_TEMP_PORT (&stm_gpioa)
157 #define AO_ADC_RX_TEMP_PIN 3
159 #define AO_ADC_TX_ANALOG_1 4
160 #define AO_ADC_TX_ANALOG_1_PORT (&stm_gpioa)
161 #define AO_ADC_TX_ANALOG_1_PIN 4
163 #define AO_ADC_SENSE_BATT 5
164 #define AO_ADC_SENSE_BATT_PORT (&stm_gpioa)
165 #define AO_ADC_SENSE_BATT_PIN 5
167 #define AO_ADC_RX_ANALOG_1 6
168 #define AO_ADC_RX_ANALOG_1_PORT (&stm_gpioa)
169 #define AO_ADC_RX_ANALOG_1_PIN 6
171 #define AO_ADC_RX_RSSI 8
172 #define AO_ADC_RX_RSSI_PORT (&stm_gpiob)
173 #define AO_ADC_RX_RSSI_PIN 0
175 #define AO_ADC_RX_CD 9
176 #define AO_ADC_RX_CD_PORT (&stm_gpiob)
177 #define AO_ADC_RX_CD_PIN 1
179 #define AO_ADC_ANT_SENSE_1 10
180 #define AO_ADC_ANT_SENSE_1_PORT (&stm_gpioc)
181 #define AO_ADC_ANT_SENSE_1_PIN 0
183 #define AO_ADC_ANT_SENSE_2 11
184 #define AO_ADC_ANT_SENSE_2_PORT (&stm_gpioc)
185 #define AO_ADC_ANT_SENSE_2_PIN 1
187 #define AO_ADC_GYRO_X_1 12
188 #define AO_ADC_GYRO_X_1_PORT (&stm_gpioc)
189 #define AO_ADC_GYRO_X_1_PIN 2
191 #define AO_ADC_GYRO_Z_1 13
192 #define AO_ADC_GYRO_Z_1_PORT (&stm_gpioc)
193 #define AO_ADC_GYRO_Z_1_PIN 3
195 #define AO_ADC_GYRO_VREF_1 24
196 #define AO_ADC_GYRO_VREF_1_PORT (&stm_gpioe)
197 #define AO_ADC_GYRO_VREF_1_PIN 9
199 #define AO_ADC_GYRO_X_2 14
200 #define AO_ADC_GYRO_X_2_PORT (&stm_gpioc)
201 #define AO_ADC_GYRO_X_2_PIN 4
203 #define AO_ADC_GYRO_Z_2 15
204 #define AO_ADC_GYRO_Z_2_PORT (&stm_gpioc)
205 #define AO_ADC_GYRO_Z_2_PIN 5
207 #define AO_ADC_GYRO_VREF_2 25
208 #define AO_ADC_GYRO_VREF_2_PORT (&stm_gpioe)
209 #define AO_ADC_GYRO_VREF_2_PIN 10
211 #define AO_ADC_TEMP 16
213 #define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \
214 (1 << STM_RCC_AHBENR_GPIOBEN) | \
215 (1 << STM_RCC_AHBENR_GPIOCEN) | \
216 (1 << STM_RCC_AHBENR_GPIOEEN))
218 #define AO_NUM_ADC_PIN (17)
220 #define AO_ADC_PIN0_PORT AO_ADC_TX_PA_CURRENT_PORT
221 #define AO_ADC_PIN0_PIN AO_ADC_TX_PA_CURRENT_PIN
222 #define AO_ADC_PIN1_PORT AO_ADC_TX_TEMP_PORT
223 #define AO_ADC_PIN1_PIN AO_ADC_TX_TEMP_PIN
224 #define AO_ADC_PIN2_PORT AO_ADC_EXP4_TEMP_PORT
225 #define AO_ADC_PIN2_PIN AO_ADC_EXP4_TEMP_PIN
226 #define AO_ADC_PIN3_PORT AO_ADC_RX_TEMP_PORT
227 #define AO_ADC_PIN3_PIN AO_ADC_RX_TEMP_PIN
228 #define AO_ADC_PIN4_PORT AO_ADC_TX_ANALOG_1_PORT
229 #define AO_ADC_PIN4_PIN AO_ADC_TX_ANALOG_1_PIN
230 #define AO_ADC_PIN5_PORT AO_ADC_SENSE_BATT_PORT
231 #define AO_ADC_PIN5_PIN AO_ADC_SENSE_BATT_PIN
232 #define AO_ADC_PIN6_PORT AO_ADC_RX_ANALOG_1_PORT
233 #define AO_ADC_PIN6_PIN AO_ADC_RX_ANALOG_1_PIN
234 #define AO_ADC_PIN7_PORT AO_ADC_RX_RSSI_PORT
235 #define AO_ADC_PIN7_PIN AO_ADC_RX_RSSI_PIN
236 #define AO_ADC_PIN8_PORT AO_ADC_RX_CD_PORT
237 #define AO_ADC_PIN8_PIN AO_ADC_RX_CD_PIN
238 #define AO_ADC_PIN9_PORT AO_ADC_ANT_SENSE_1_PORT
239 #define AO_ADC_PIN9_PIN AO_ADC_ANT_SENSE_1_PIN
240 #define AO_ADC_PIN10_PORT AO_ADC_ANT_SENSE_2_PORT
241 #define AO_ADC_PIN10_PIN AO_ADC_ANT_SENSE_2_PIN
242 #define AO_ADC_PIN11_PORT AO_ADC_GYRO_X_1_PORT
243 #define AO_ADC_PIN11_PIN AO_ADC_GYRO_X_1_PIN
244 #define AO_ADC_PIN12_PORT AO_ADC_GYRO_Z_1_PORT
245 #define AO_ADC_PIN12_PIN AO_ADC_GYRO_Z_1_PIN
246 #define AO_ADC_PIN13_PORT AO_ADC_GYRO_VREF_1_PORT
247 #define AO_ADC_PIN13_PIN AO_ADC_GYRO_VREF_1_PIN
248 #define AO_ADC_PIN14_PORT AO_ADC_GYRO_X_2_PORT
249 #define AO_ADC_PIN14_PIN AO_ADC_GYRO_X_2_PIN
250 #define AO_ADC_PIN15_PORT AO_ADC_GYRO_Z_2_PORT
251 #define AO_ADC_PIN15_PIN AO_ADC_GYRO_Z_2_PIN
252 #define AO_ADC_PIN16_PORT AO_ADC_GYRO_VREF_2_PORT
253 #define AO_ADC_PIN16_PIN AO_ADC_GYRO_VREF_2_PIN
255 #define AO_NUM_ADC (AO_NUM_ADC_PIN + 1) /* Add internal temp sensor */
257 #define AO_ADC_SQ1 AO_ADC_TX_PA_CURRENT
258 #define AO_ADC_SQ1_NAME "tx_pa_current"
259 #define AO_ADC_SQ2 AO_ADC_TX_TEMP
260 #define AO_ADC_SQ2_NAME "tx_temp"
261 #define AO_ADC_SQ3 AO_ADC_EXP4_TEMP
262 #define AO_ADC_SQ3_NAME "expr_temp"
263 #define AO_ADC_SQ4 AO_ADC_RX_TEMP
264 #define AO_ADC_SQ4_NAME "rx_temp"
265 #define AO_ADC_SQ5 AO_ADC_TX_ANALOG_1
266 #define AO_ADC_SQ5_NAME "tx_analog_1"
267 #define AO_ADC_SQ6 AO_ADC_SENSE_BATT
268 #define AO_ADC_SQ6_NAME "sense_batt"
269 #define AO_ADC_SQ7 AO_ADC_RX_ANALOG_1
270 #define AO_ADC_SQ7_NAME "rx_analog_1"
271 #define AO_ADC_SQ8 AO_ADC_RX_RSSI
272 #define AO_ADC_SQ8_NAME "rx_rssi"
273 #define AO_ADC_SQ9 AO_ADC_RX_CD
274 #define AO_ADC_SQ9_NAME "rx_cd"
275 #define AO_ADC_SQ10 AO_ADC_ANT_SENSE_1
276 #define AO_ADC_SQ10_NAME "ant_sense_1"
277 #define AO_ADC_SQ11 AO_ADC_ANT_SENSE_2
278 #define AO_ADC_SQ11_NAME "ant_sense_2"
279 #define AO_ADC_SQ12 AO_ADC_GYRO_X_1
280 #define AO_ADC_SQ12_NAME "gyro_x_1"
281 #define AO_ADC_SQ13 AO_ADC_GYRO_Z_1
282 #define AO_ADC_SQ13_NAME "gyro_z_1"
283 #define AO_ADC_SQ14 AO_ADC_GYRO_VREF_1
284 #define AO_ADC_SQ14_NAME "gyro_vref_1"
285 #define AO_ADC_SQ15 AO_ADC_GYRO_X_2
286 #define AO_ADC_SQ15_NAME "gyro_x_2"
287 #define AO_ADC_SQ16 AO_ADC_GYRO_Z_2
288 #define AO_ADC_SQ16_NAME "gyro_z_2"
289 #define AO_ADC_SQ17 AO_ADC_GYRO_VREF_2
290 #define AO_ADC_SQ17_NAME "gyro_vref_2"
291 #define AO_ADC_SQ18 AO_ADC_TEMP
292 #define AO_ADC_SQ18_NAME "temp"
296 #define AO_WATCHDOG_INTERVAL AO_MS_TO_TICKS(40)
297 #define AO_WATCHDOG_PORT (&stm_gpiod)
298 #define AO_WATCHDOG_BIT 3
302 #define AO_MR25_SPI_CS_PORT (&stm_gpiod)
303 #define AO_MR25_SPI_CS_PIN 0
304 #define AO_MR25_SPI_BUS AO_SPI_2_PB13_PB14_PB15
308 #define AO_SDCARD_SPI_CS_PORT (&stm_gpiod)
309 #define AO_SDCARD_SPI_CS_PIN 1
310 #define AO_SDCARD_SPI_BUS AO_SPI_2_PB13_PB14_PB15
311 #define AO_SDCARD_SPI_PORT (&stm_gpiob)
312 #define AO_SDCARD_SPI_SCK_PIN 13
313 #define AO_SDCARD_SPI_MISO_PIN 14
314 #define AO_SDCARD_SPI_MOSI_PIN 15
316 #endif /* _AO_PINS_H_ */