OP-1685 - OneShot support for revonano
[librepilot.git] / flight / targets / boards / revonano / pios_board.h
blob616d248837a7217b8b8d7cfb25110ae194777c23
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotSystem OpenPilot System
4 * @{
5 * @addtogroup OpenPilotCore OpenPilot Core
6 * @{
7 * @file pios_board.h
8 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
9 * @brief Defines board hardware for the OpenPilot Version 1.1 hardware.
10 * @see The GNU Public License (GPL) Version 3
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef PIOS_BOARD_H
30 #define PIOS_BOARD_H
32 #include <stdbool.h>
33 // ------------------------
34 // Timers and Channels Used
35 // ------------------------
37 Timer | Channel 1 | Channel 2 | Channel 3 | Channel 4
38 ------+-----------+-----------+-----------+----------
39 TIM1 | | | |
40 TIM2 | --------------- PIOS_DELAY -----------------
41 TIM3 | | | |
42 TIM4 | | | |
43 TIM5 | | | |
44 TIM6 | | | |
45 TIM7 | | | |
46 TIM8 | | | |
47 ------+-----------+-----------+-----------+----------
50 // ------------------------
51 // DMA Channels Used
52 // ------------------------
53 /* Channel 1 - */
54 /* Channel 2 - SPI1 RX */
55 /* Channel 3 - SPI1 TX */
56 /* Channel 4 - SPI2 RX */
57 /* Channel 5 - SPI2 TX */
58 /* Channel 6 - */
59 /* Channel 7 - */
60 /* Channel 8 - */
61 /* Channel 9 - */
62 /* Channel 10 - */
63 /* Channel 11 - */
64 /* Channel 12 - */
66 // ------------------------
67 // BOOTLOADER_SETTINGS
68 // ------------------------
69 #define BOARD_READABLE true
70 #define BOARD_WRITABLE true
71 #define MAX_DEL_RETRYS 3
73 // ------------------------
74 // PIOS_LED
75 // ------------------------
76 #define PIOS_LED_HEARTBEAT 0
77 #define PIOS_LED_ALARM 1
78 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
79 #define PIOS_LED_D1 2
80 #define PIOS_LED_D2 3
81 #define PIOS_LED_D3 4
82 #define PIOS_LED_D4 5
84 #define D1_LED_ON PIOS_LED_On(PIOS_LED_D1)
85 #define D1_LED_OFF PIOS_LED_Off(PIOS_LED_D1)
86 #define D1_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D1)
88 #define D2_LED_ON PIOS_LED_On(PIOS_LED_D2)
89 #define D2_LED_OFF PIOS_LED_Off(PIOS_LED_D2)
90 #define D2_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D2)
92 #define D3_LED_ON PIOS_LED_On(PIOS_LED_D3)
93 #define D3_LED_OFF PIOS_LED_Off(PIOS_LED_D3)
94 #define D3_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D3)
96 #define D4_LED_ON PIOS_LED_On(PIOS_LED_D4)
97 #define D4_LED_OFF PIOS_LED_Off(PIOS_LED_D4)
98 #define D4_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D4)
99 #endif /* PIOS_RFM22B_DEBUG_ON_TELEM */
101 // ------------------------
102 // PIOS_SPI
103 // See also pios_board.c
104 // ------------------------
105 #define PIOS_SPI_MAX_DEVS 3
107 // ------------------------
108 // PIOS_WDG
109 // ------------------------
110 #define PIOS_WATCHDOG_TIMEOUT 500
111 #define PIOS_WDG_REGISTER RTC_BKP_DR4
112 #define PIOS_WDG_ACTUATOR 0x0001
113 #define PIOS_WDG_STABILIZATION 0x0002
114 #define PIOS_WDG_ATTITUDE 0x0004
115 #define PIOS_WDG_MANUAL 0x0008
116 #define PIOS_WDG_SENSORS 0x0010
118 // ------------------------
119 // PIOS_I2C
120 // See also pios_board.c
121 // ------------------------
122 #define PIOS_I2C_MAX_DEVS 3
123 extern uint32_t pios_i2c_mag_pressure_adapter_id;
124 #define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_pressure_adapter_id)
125 extern uint32_t pios_i2c_flexiport_adapter_id;
126 #define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
127 #define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
128 #define PIOS_I2C_MS4525DO_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
130 // -------------------------
131 // PIOS_USART
133 // See also pios_board.c
134 // -------------------------
135 #define PIOS_USART_MAX_DEVS 5
137 // -------------------------
138 // PIOS_COM
140 // See also pios_board.c
141 // -------------------------
142 #define PIOS_COM_MAX_DEVS 4
143 extern uint32_t pios_com_telem_rf_id;
144 extern uint32_t pios_com_rf_id;
145 extern uint32_t pios_com_gps_id;
146 extern uint32_t pios_com_telem_usb_id;
147 extern uint32_t pios_com_bridge_id;
148 extern uint32_t pios_com_vcp_id;
149 extern uint32_t pios_com_hkosd_id;
150 #define PIOS_COM_GPS (pios_com_gps_id)
151 #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
152 #define PIOS_COM_TELEM_RF (pios_com_telem_rf_id)
153 #define PIOS_COM_RF (pios_com_rf_id)
154 #define PIOS_COM_BRIDGE (pios_com_bridge_id)
155 #define PIOS_COM_VCP (pios_com_vcp_id)
156 #define PIOS_COM_OSDHK (pios_com_hkosd_id)
158 #if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
159 extern uint32_t pios_com_debug_id;
160 #define PIOS_COM_DEBUG (pios_com_debug_id)
161 #endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
163 #if defined(PIOS_INCLUDE_RFM22B)
164 extern uint32_t pios_rfm22b_id;
165 extern uint32_t pios_spi_telem_flash_id;
166 #define PIOS_RFM22_SPI_PORT (pios_spi_telem_flash_id)
167 #endif /* PIOS_INCLUDE_RFM22B */
169 // -------------------------
170 // Packet Handler
171 // -------------------------
172 #define RS_ECC_NPARITY 4
173 #define PIOS_PH_MAX_PACKET 255
174 #define PIOS_PH_WIN_SIZE 3
175 #define PIOS_PH_MAX_CONNECTIONS 1
176 extern uint32_t pios_packet_handler;
177 #define PIOS_PACKET_HANDLER (pios_packet_handler)
179 // ------------------------
180 // TELEMETRY
181 // ------------------------
182 #define TELEM_QUEUE_SIZE 80
183 #define PIOS_TELEM_STACK_SIZE 800
185 // -------------------------
186 // System Settings
188 // See also System_stm32f4xx.c
189 // -------------------------
190 // These macros are deprecated
191 // please use PIOS_PERIPHERAL_APBx_CLOCK According to the table below
192 // #define PIOS_MASTER_CLOCK
193 // #define PIOS_PERIPHERAL_CLOCK
194 // #define PIOS_PERIPHERAL_CLOCK
196 #define PIOS_SYSCLK SYSCLK_FREQ
197 // Peripherals that belongs to APB1 are:
198 // DAC |PWR |CAN1,2
199 // I2C1,2,3 |UART4,5 |USART3,2
200 // I2S3Ext |SPI3/I2S3 |SPI2/I2S2
201 // I2S2Ext |IWDG |WWDG
202 // RTC/BKP reg
203 // TIM2,3,4,5,6,7,12,13,14
205 // Calculated as SYSCLK / APBPresc * (APBPre == 1 ? 1 : 2)
206 // Default APB1 Prescaler = 4
207 #define PIOS_PERIPHERAL_APB1_CLOCK (PIOS_SYSCLK / 2)
209 // Peripherals belonging to APB2
210 // SDIO |EXTI |SYSCFG |SPI1
211 // ADC1,2,3
212 // USART1,6
213 // TIM1,8,9,10,11
215 // Default APB2 Prescaler = 2
217 #define PIOS_PERIPHERAL_APB2_CLOCK PIOS_SYSCLK
219 // -------------------------
220 // Interrupt Priorities
221 // -------------------------
222 #define PIOS_IRQ_PRIO_LOW 12 // lower than RTOS
223 #define PIOS_IRQ_PRIO_MID 8 // higher than RTOS
224 #define PIOS_IRQ_PRIO_HIGH 5 // for SPI, ADC, I2C etc...
225 #define PIOS_IRQ_PRIO_HIGHEST 4 // for USART etc...
226 // ------------------------
227 // PIOS_RCVR
228 // See also pios_board.c
229 // ------------------------
230 #define PIOS_RCVR_MAX_DEVS 3
231 #define PIOS_RCVR_MAX_CHANNELS 12
232 #define PIOS_GCSRCVR_TIMEOUT_MS 100
233 #define PIOS_RFM22B_RCVR_TIMEOUT_MS 200
234 #define PIOS_OPLINK_RCVR_TIMEOUT_MS 100
236 // -------------------------
237 // Receiver PPM input
238 // -------------------------
239 #define PIOS_PPM_MAX_DEVS 1
240 #define PIOS_PPM_NUM_INPUTS 12
242 // -------------------------
243 // Receiver PWM input
244 // -------------------------
245 #define PIOS_PWM_MAX_DEVS 1
246 #define PIOS_PWM_NUM_INPUTS 8
248 // -------------------------
249 // Receiver SPEKTRUM input
250 // -------------------------
251 #define PIOS_SPEKTRUM_MAX_DEVS 2
252 #define PIOS_SPEKTRUM_NUM_INPUTS 12
254 // -------------------------
255 // Receiver S.Bus input
256 // -------------------------
257 #define PIOS_SBUS_MAX_DEVS 1
258 #define PIOS_SBUS_NUM_INPUTS (16 + 2)
260 // -------------------------
261 // Receiver DSM input
262 // -------------------------
263 #define PIOS_DSM_MAX_DEVS 2
264 #define PIOS_DSM_NUM_INPUTS 12
266 // -------------------------
267 // Servo outputs
268 // -------------------------
269 #define PIOS_SERVO_UPDATE_HZ 50
270 #define PIOS_SERVOS_INITIAL_POSITION 0 /* dont want to start motors, have no pulse till settings loaded */
271 #define PIOS_SERVO_BANKS 6
273 // --------------------------
274 // Timer controller settings
275 // --------------------------
276 #define PIOS_TIM_MAX_DEVS 6
278 // -------------------------
279 // ADC
280 // PIOS_ADC_PinGet(0) = Current sensor
281 // PIOS_ADC_PinGet(1) = Voltage sensor
282 // PIOS_ADC_PinGet(4) = VREF
283 // PIOS_ADC_PinGet(5) = Temperature sensor
284 // -------------------------
285 #define PIOS_DMA_PIN_CONFIG \
287 { GPIOC, GPIO_Pin_1, ADC_Channel_11 }, \
288 { GPIOC, GPIO_Pin_2, ADC_Channel_12 }, \
289 { NULL, 0, ADC_Channel_Vrefint }, /* Voltage reference */ \
290 { NULL, 0, ADC_Channel_TempSensor }, /* Temperature sensor */ \
293 /* we have to do all this to satisfy the PIOS_ADC_MAX_SAMPLES define in pios_adc.h */
294 /* which is annoying because this then determines the rate at which we generate buffer turnover events */
295 /* the objective here is to get enough buffer space to support 100Hz averaging rate */
296 #define PIOS_ADC_NUM_CHANNELS 4
297 #define PIOS_ADC_MAX_OVERSAMPLING 2
298 #define PIOS_ADC_USE_ADC2 0
300 #define PIOS_ADC_USE_TEMP_SENSOR
301 #define PIOS_ADC_TEMPERATURE_PIN 3
303 // -------------------------
304 // USB
305 // -------------------------
306 #define PIOS_USB_MAX_DEVS 1
307 #define PIOS_USB_ENABLED 1 /* Should remove all references to this */
308 #define PIOS_USB_HID_MAX_DEVS 1
310 #endif /* PIOS_BOARD_H */
313 * @}
314 * @}