2 ******************************************************************************
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
7 * @brief Defines PiOS board hardware for the OpenPilot OPLink Mini board.
8 * @see The GNU Public License (GPL) Version 3
10 *****************************************************************************/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 // ------------------------
32 // Timers and Channels Used
33 // ------------------------
35 Timer | Channel 1 | Channel 2 | Channel 3 | Channel 4
36 ------+-----------+-----------+-----------+----------
38 TIM2 | RC In 5 | RC In 6 | Servo 6 |
39 TIM3 | Servo 5 | RC In 2 | RC In 3 | RC In 4
40 TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
41 ------+-----------+-----------+-----------+----------
44 // ------------------------
46 // ------------------------
61 // ------------------------
62 // BOOTLOADER_SETTINGS
63 // ------------------------
64 #define BOARD_READABLE TRUE
65 #define BOARD_WRITABLE TRUE
66 #define MAX_DEL_RETRYS 3
69 // ------------------------
71 // ------------------------
72 #define PIOS_WATCHDOG_TIMEOUT 500
73 #define PIOS_WDG_REGISTER BKP_DR4
74 #define PIOS_WDG_TELEMETRYTX 0x0001
75 #define PIOS_WDG_TELEMETRYRX 0x0002
76 #define PIOS_WDG_TELEMRADIOTX 0x0004
77 #define PIOS_WDG_TELEMRADIORX 0x0008
78 #define PIOS_WDG_RFM22B 0x000f
79 #define PIOS_WDG_PPMINPUT 0x0010
81 // ------------------------
83 // ------------------------
84 #define TELEM_QUEUE_SIZE 20
86 // ------------------------
88 // ------------------------
89 #define PIOS_LED_USB 0
90 #define PIOS_LED_LINK 1
93 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
100 #define PIOS_LED_HEARTBEAT PIOS_LED_LINK
101 #define PIOS_LED_ALARM PIOS_LED_TX
103 #define USB_LED_ON PIOS_LED_On(PIOS_LED_USB)
104 #define USB_LED_OFF PIOS_LED_Off(PIOS_LED_USB)
105 #define USB_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_USB)
107 #define LINK_LED_ON PIOS_LED_On(PIOS_LED_LINK)
108 #define LINK_LED_OFF PIOS_LED_Off(PIOS_LED_LINK)
109 #define LINK_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_LINK)
111 #define RX_LED_ON PIOS_LED_On(PIOS_LED_RX)
112 #define RX_LED_OFF PIOS_LED_Off(PIOS_LED_RX)
113 #define RX_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_RX)
115 #define TX_LED_ON PIOS_LED_On(PIOS_LED_TX)
116 #define TX_LED_OFF PIOS_LED_Off(PIOS_LED_TX)
117 #define TX_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_TX)
119 #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
120 #define D1_LED_ON PIOS_LED_On(PIOS_LED_D1)
121 #define D1_LED_OFF PIOS_LED_Off(PIOS_LED_D1)
122 #define D1_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D1)
124 #define D2_LED_ON PIOS_LED_On(PIOS_LED_D2)
125 #define D2_LED_OFF PIOS_LED_Off(PIOS_LED_D2)
126 #define D2_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D2)
128 #define D3_LED_ON PIOS_LED_On(PIOS_LED_D3)
129 #define D3_LED_OFF PIOS_LED_Off(PIOS_LED_D3)
130 #define D3_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D3)
132 #define D4_LED_ON PIOS_LED_On(PIOS_LED_D4)
133 #define D4_LED_OFF PIOS_LED_Off(PIOS_LED_D4)
134 #define D4_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_D4)
137 // -------------------------
139 // -------------------------
140 #define PIOS_MASTER_CLOCK 72000000
142 // -------------------------
143 // Interrupt Priorities
144 // -------------------------
145 #define PIOS_IRQ_PRIO_LOW 12 // lower than RTOS
146 #define PIOS_IRQ_PRIO_MID 8 // higher than RTOS
147 #define PIOS_IRQ_PRIO_HIGH 5 // for SPI, ADC, I2C etc...
148 #define PIOS_IRQ_PRIO_HIGHEST 4 // for USART etc...
150 // ------------------------
152 // See also pios_board.c
153 // ------------------------
154 #define PIOS_I2C_MAX_DEVS 1
155 extern uint32_t pios_i2c_flexi_adapter_id
;
156 #define PIOS_I2C_MAIN_ADAPTER (pios_i2c_flexi_adapter_id)
158 // ------------------------
160 // See also pios_board.c
161 // ------------------------
162 #define PIOS_SPI_MAX_DEVS 1
163 #define PIOS_SPI_RFM22B_ADAPTER (pios_spi_rfm22b_id)
165 // -------------------------
167 // -------------------------
168 #define PIOS_USART_MAX_DEVS 3
170 // -------------------------
173 // See also pios_board.c
174 // -------------------------
175 #define PIOS_COM_MAX_DEVS 5
178 #define PIOS_COM_TELEM_USB_RX_BUF_LEN 256
179 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 256
182 #define PIOS_COM_TELEM_VCP_RX_BUF_LEN 128
183 #define PIOS_COM_TELEM_VCP_TX_BUF_LEN 128
185 // The direct com ports
186 extern uint32_t pios_com_hid_id
;
187 extern uint32_t pios_com_vcp_id
;
188 extern uint32_t pios_com_main_id
;
189 extern uint32_t pios_com_flexi_id
;
190 extern uint32_t pios_com_pri_radio_id
;
191 extern uint32_t pios_com_aux_radio_id
;
192 // The port that the GCS is connected to
193 extern uint32_t pios_com_gcs_id
;
194 // The destination port from the GCS port
195 extern uint32_t pios_com_gcs_out_id
;
196 // The destination port from the VCP com bridge
197 extern uint32_t pios_com_bridge_id
;
198 // The destination port for the primary radio port
199 extern uint32_t pios_com_pri_radio_out_id
;
200 // The destination port for the auxiliary radio port.
201 extern uint32_t pios_com_aux_radio_out_id
;
203 extern uint32_t pios_ppm_out_id
;
204 #define PIOS_COM_HID (pios_com_hid_id)
205 #define PIOS_COM_VCP (pios_com_vcp_id)
206 #define PIOS_COM_MAIN (pios_com_main_id)
207 #define PIOS_COM_FLEXI (pios_com_flexi_id)
208 #define PIOS_COM_PRI_RADIO (pios_com_pri_radio_id)
209 #define PIOS_COM_AUX_RADIO (pios_com_aux_radio_id)
210 #define PIOS_COM_PRI_RADIO_OUT (pios_com_pri_radio_out_id)
211 #define PIOS_COM_AUX_RADIO_OUT (pios_com_aux_radio_out_id)
212 #define PIOS_COM_GCS (pios_com_gcs_id)
213 #define PIOS_COM_GCS_OUT (pios_com_gcs_out_id)
214 #define PIOS_COM_BRIDGE (pios_com_bridge_id)
215 #define PIOS_PPM_OUTPUT (pios_ppm_out_id)
216 #define RFM22_DEBUG 1
218 // -------------------------
221 // -------------------------
222 // #define PIOS_ADC_OVERSAMPLING_RATE 1
223 #define PIOS_ADC_USE_TEMP_SENSOR 0
224 #define PIOS_ADC_TEMP_SENSOR_ADC ADC1
225 #define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
227 #define PIOS_ADC_NUM_PINS 0
229 #define PIOS_ADC_PORTS {}
230 #define PIOS_ADC_PINS {}
231 #define PIOS_ADC_CHANNELS {}
232 #define PIOS_ADC_MAPPING {}
233 #define PIOS_ADC_CHANNEL_MAPPING {}
234 #define PIOS_ADC_NUM_CHANNELS (PIOS_ADC_NUM_PINS + PIOS_ADC_USE_TEMP_SENSOR)
235 #define PIOS_ADC_NUM_ADC_CHANNELS 0
236 #define PIOS_ADC_USE_ADC2 0
237 #define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE)
238 #define PIOS_ADC_ADCCLK RCC_PCLK2_Div8
239 /* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */
240 /* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */
241 /* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */
242 /* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */
243 #define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5
245 /* With an ADCCLK = 14 MHz and a sampling time of 239.5 cycles: */
246 /* Tconv = 239.5 + 12.5 = 252 cycles = 18�s */
247 /* (1 / (ADCCLK / CYCLES)) = Sample Time (�S) */
248 #define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_LOW
250 // Currently analog acquistion hard coded at 480 Hz
252 // ADCCLK = PCLK2 / 2
253 #define PIOS_ADC_RATE (72.0e6 / 1.0 / 8.0 / 252.0 / (PIOS_ADC_NUM_CHANNELS >> PIOS_ADC_USE_ADC2))
254 #define PIOS_ADC_MAX_OVERSAMPLING 36
256 #define PIOS_ADC_TEMPERATURE_PIN 0
258 // ------------------------
260 // See also pios_board.c
261 // ------------------------
262 #define PIOS_RCVR_MAX_DEVS 3
263 #define PIOS_RCVR_MAX_CHANNELS 12
264 #define PIOS_GCSRCVR_TIMEOUT_MS 100
266 // -------------------------
267 // Receiver PPM input
268 // -------------------------
269 #define PIOS_PPM_MAX_DEVS 1
270 #define PIOS_PPM_NUM_INPUTS 12
272 // -------------------------
273 // Receiver PWM inputs
274 // -------------------------
275 #define PIOS_PWM_NUM_INPUTS 4
277 // -------------------------
279 // -------------------------
280 #define PIOS_SERVO_UPDATE_HZ 50
281 #define PIOS_SERVOS_INITIAL_POSITION 0 /* dont want to start motors, have no pulse till settings loaded */
282 #define PIOS_SERVO_BANKS 6
284 // --------------------------
285 // Timer controller settings
286 // --------------------------
287 #define PIOS_TIM_MAX_DEVS 3
289 // -------------------------
291 // -------------------------
292 #define PIOS_GPIO_PORTS {}
293 #define PIOS_GPIO_PINS {}
294 #define PIOS_GPIO_CLKS {}
295 #define PIOS_GPIO_NUM 0
297 // -------------------------
299 // -------------------------
300 #define PIOS_USB_HID_MAX_DEVS 1
301 #define PIOS_USB_ENABLED 1
302 #define PIOS_USB_HID_MAX_DEVS 1
303 #define PIOS_USB_MAX_DEVS 1
304 #define PIOS_USB_DETECT_GPIO_PORT GPIOC
305 #define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_15
306 #define PIOS_USB_DETECT_EXTI_LINE EXTI_Line15
308 // -------------------------
310 // -------------------------
312 #if defined(PIOS_INCLUDE_RFM22B)
313 extern uint32_t pios_spi_rfm22b_id
;
314 #define PIOS_RFM22_SPI_PORT (pios_spi_rfm22b_id)
315 extern uint32_t pios_rfm22b_id
;
316 #endif /* PIOS_INCLUDE_RFM22B */
318 // -------------------------
320 // -------------------------
321 extern uint32_t pios_packet_handler
;
322 #define PIOS_PACKET_HANDLER (pios_packet_handler)
323 #define PIOS_PH_MAX_PACKET 255
324 #define PIOS_PH_WIN_SIZE 3
325 #define PIOS_PH_MAX_CONNECTIONS 1
326 #define RS_ECC_NPARITY 4
328 // -------------------------
330 // -------------------------
332 #define RS_ECC_NPARITY 4
334 // -------------------------
335 // Flash EEPROM Emulation
336 // -------------------------
338 #define PIOS_FLASH_SIZE 0x20000
339 #define PIOS_FLASH_EEPROM_START_ADDR 0x08000000
340 #define PIOS_FLASH_PAGE_SIZE 1024
341 #define PIOS_FLASH_EEPROM_ADDR (PIOS_FLASH_EEPROM_START_ADDR + PIOS_FLASH_SIZE - PIOS_FLASH_PAGE_SIZE)
342 #define PIOS_FLASH_EEPROM_LEN PIOS_FLASH_PAGE_SIZE
344 #endif /* PIOS_BOARD_H */