Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / pios / inc / pios_board_io.h
blob1f8500fd948de1ddc9d7bae3bbf2917de57ec3e4
1 /**
2 ******************************************************************************
4 * @file pios_board_io.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 * @brief board io setup
7 * --
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
20 * for more details.
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
26 #ifndef PIOS_BOARD_IO_H
27 #define PIOS_BOARD_IO_H
29 #include "pios.h"
32 #ifdef PIOS_INCLUDE_USB
33 #include <pios_usb_priv.h>
34 #endif
36 #ifdef PIOS_INCLUDE_USART
37 #include <pios_usart_priv.h>
38 #endif
40 #ifdef PIOS_INCLUDE_PWM
41 #include <pios_pwm_priv.h>
42 #endif
44 #ifdef PIOS_INCLUDE_PPM
45 #include <pios_ppm_priv.h>
46 #endif
48 #ifdef PIOS_INCLUDE_OPENLRS
49 #include <pios_openlrs_priv.h>
50 #endif
52 #ifdef PIOS_INCLUDE_RCVR
53 extern uint32_t pios_rcvr_group_map[]; /* Receivers */
54 #endif
56 /* GPS */
57 #ifdef PIOS_INCLUDE_GPS
58 extern uint32_t pios_com_gps_id;
59 # define PIOS_COM_GPS (pios_com_gps_id)
60 # ifndef PIOS_COM_GPS_RX_BUF_LEN
61 # define PIOS_COM_GPS_RX_BUF_LEN 128
62 # endif
63 # ifndef PIOS_COM_GPS_TX_BUF_LEN
64 # define PIOS_COM_GPS_TX_BUF_LEN 32
65 # endif
66 #endif /* PIOS_INCLUDE_GPS */
69 /* ComUsbBridge */
70 extern uint32_t pios_com_bridge_id;
71 #define PIOS_COM_BRIDGE (pios_com_bridge_id)
72 #ifndef PIOS_COM_BRIDGE_RX_BUF_LEN
73 # define PIOS_COM_BRIDGE_RX_BUF_LEN 65
74 #endif
75 #ifndef PIOS_COM_BRIDGE_TX_BUF_LEN
76 # define PIOS_COM_BRIDGE_TX_BUF_LEN 12
77 #endif
80 /* USB telemetry */
81 extern uint32_t pios_com_telem_usb_id;
82 #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
83 #ifndef PIOS_COM_TELEM_USB_RX_BUF_LEN
84 # define PIOS_COM_TELEM_USB_RX_BUF_LEN 65
85 #endif
86 #ifndef PIOS_COM_TELEM_USB_TX_BUF_LEN
87 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 65
88 #endif
90 /* Serial port telemetry */
91 extern uint32_t pios_com_telem_rf_id;
92 #define PIOS_COM_TELEM_RF (pios_com_telem_rf_id)
93 #ifndef PIOS_COM_TELEM_RF_RX_BUF_LEN
94 # define PIOS_COM_TELEM_RF_RX_BUF_LEN 256
95 #endif
96 #ifndef PIOS_COM_TELEM_RF_TX_BUF_LEN
97 # define PIOS_COM_TELEM_RF_TX_BUF_LEN 256
98 #endif
100 /* RFM22B telemetry */
101 #ifdef PIOS_INCLUDE_RFM22B
102 extern uint32_t pios_rfm22b_id; /* RFM22B handle */
103 extern uint32_t pios_com_pri_radio_id; /* oplink primary com stream */
104 extern uint32_t pios_com_aux_radio_id; /* oplink aux com stream */
105 # define PIOS_COM_RF (pios_com_pri_radio_id)
106 # define PIOS_COM_PRI_RADIO (pios_com_pri_radio_id)
107 # define PIOS_COM_AUX_RADIO (pios_com_aux_radio_id)
108 # ifndef PIOS_COM_PRI_RADIO_RX_BUF_LEN
109 # define PIOS_COM_PRI_RADIO_RX_BUF_LEN 256
110 # endif
111 # ifndef PIOS_COM_PRI_RADIO_TX_BUF_LEN
112 # define PIOS_COM_PRI_RADIO_TX_BUF_LEN 256
113 # endif
114 # ifndef PIOS_COM_AUX_RADIO_RX_BUF_LEN
115 # define PIOS_COM_AUX_RADIO_RX_BUF_LEN 256
116 # endif
117 # ifndef PIOS_COM_AUX_RADIO_TX_BUF_LEN
118 # define PIOS_COM_AUX_RADIO_TX_BUF_LEN 256
119 # endif
120 #endif
122 #ifdef PIOS_INCLUDE_OPENLRS
123 extern uint32_t pios_openlrs_id; /* openlrs handle */
124 #endif
127 /* HK OSD ?? */
128 extern uint32_t pios_com_hkosd_id;
129 #define PIOS_COM_OSDHK (pios_com_hkosd_id)
130 #ifndef PIOS_COM_HKOSD_RX_BUF_LEN
131 # define PIOS_COM_HKOSD_RX_BUF_LEN 22
132 #endif
133 #ifndef PIOS_COM_HKOSD_TX_BUF_LEN
134 # define PIOS_COM_HKOSD_TX_BUF_LEN 22
135 #endif
137 /* MSP */
138 extern uint32_t pios_com_msp_id;
139 #define PIOS_COM_MSP (pios_com_msp_id)
140 #ifndef PIOS_COM_MSP_TX_BUF_LEN
141 # define PIOS_COM_MSP_TX_BUF_LEN 128
142 #endif
143 #ifndef PIOS_COM_MSP_RX_BUF_LEN
144 # define PIOS_COM_MSP_RX_BUF_LEN 64
145 #endif
147 /* MAVLink */
148 extern uint32_t pios_com_mavlink_id;
149 #define PIOS_COM_MAVLINK (pios_com_mavlink_id)
150 #ifndef PIOS_COM_MAVLINK_TX_BUF_LEN
151 # define PIOS_COM_MAVLINK_TX_BUF_LEN 128
152 #endif
153 #ifndef PIOS_COM_MAVLINK_RX_BUF_LEN
154 # define PIOS_COM_MAVLINK_RX_BUF_LEN 128
155 #endif
157 /* HoTT Telemetry */
158 #ifdef PIOS_INCLUDE_HOTT_BRIDGE
159 # ifndef PIOS_COM_HOTT_BRIDGE_RX_BUF_LEN
160 # define PIOS_COM_HOTT_BRIDGE_RX_BUF_LEN 512
161 # endif
162 # ifndef PIOS_COM_HOTT_BRIDGE_TX_BUF_LEN
163 # define PIOS_COM_HOTT_BRIDGE_TX_BUF_LEN 512
164 # endif
165 extern uint32_t pios_com_hott_id;
166 # define PIOS_COM_HOTT (pios_com_hott_id)
167 #endif
169 /* Frsky Sensorhub */
170 extern uint32_t pios_com_frsky_sensorhub_id;
171 #define PIOS_COM_FRSKY_SENSORHUB (pios_com_frsky_sensorhub_id)
172 #ifndef PIOS_COM_FRSKY_SENSORHUB_TX_BUF_LEN
173 # define PIOS_COM_FRSKY_SENSORHUB_TX_BUF_LEN 128
174 #endif
176 /* USB VCP */
177 extern uint32_t pios_com_vcp_id;
178 #define PIOS_COM_VCP (pios_com_vcp_id)
181 #ifdef PIOS_INCLUDE_DEBUG_CONSOLE
182 extern uint32_t pios_com_debug_id;
183 #define PIOS_COM_DEBUG (pios_com_debug_id)
184 #ifndef PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN
185 # define PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN 40
186 #endif
187 #endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
189 #ifdef PIOS_INCLUDE_USB_RCTX
190 extern uint32_t pios_usb_rctx_id;
191 #endif /* PIOS_INCLUDE_USB_RCTX */
193 #if defined(PIOS_INCLUDE_HMC5X83) && defined(PIOS_HMC5X83_HAS_GPIOS)
194 #include <pios_hmc5x83.h>
195 extern pios_hmc5x83_dev_t pios_hmc5x83_internal_id;
196 #endif
198 typedef enum {
199 PIOS_BOARD_IO_UART_NONE = 0,
200 PIOS_BOARD_IO_UART_TELEMETRY, /* com */
201 PIOS_BOARD_IO_UART_MAVLINK, /* com */
202 PIOS_BOARD_IO_UART_MSP, /* com */
203 PIOS_BOARD_IO_UART_GPS, /* com */
204 PIOS_BOARD_IO_UART_COMBRIDGE, /* com */
205 PIOS_BOARD_IO_UART_DEBUGCONSOLE, /* com */
206 PIOS_BOARD_IO_UART_OSDHK, /* com */
207 PIOS_BOARD_IO_UART_SBUS, /* rcvr, normal vs not-inverted from HwSettings.SBusMode */
208 PIOS_BOARD_IO_UART_SBUS_NORMAL, /* helper only */
209 PIOS_BOARD_IO_UART_SBUS_NOT_INVERTED, /* helper only */
210 PIOS_BOARD_IO_UART_DSM_MAIN, /* rcvr */
211 PIOS_BOARD_IO_UART_DSM_FLEXI, /* rcvr */
212 PIOS_BOARD_IO_UART_DSM_RCVR, /* rcvr */
213 PIOS_BOARD_IO_UART_HOTT_SUMD, /* rcvr */
214 PIOS_BOARD_IO_UART_HOTT_SUMH, /* rcvr */
215 PIOS_BOARD_IO_UART_SRXL, /* rcvr */
216 PIOS_BOARD_IO_UART_IBUS, /* rcvr */
217 PIOS_BOARD_IO_UART_EXBUS, /* rcvr */
218 // PIOS_BOARD_IO_UART_FRSKY_SPORT_TELEMETRY, /* com */
219 PIOS_BOARD_IO_UART_HOTT_BRIDGE, /* com */
220 PIOS_BOARD_IO_UART_FRSKY_SENSORHUB, /* com */
221 } PIOS_BOARD_IO_UART_Function;
224 #ifdef PIOS_INCLUDE_USB
225 # ifndef BOOTLOADER
226 # include "uavobjectmanager.h"
227 # include "hwsettings.h"
229 void PIOS_BOARD_IO_Configure_USB();
231 typedef enum {
232 PIOS_BOARD_IO_USB_HID_NONE = HWSETTINGS_USB_HIDPORT_DISABLED,
233 PIOS_BOARD_IO_USB_HID_TELEMETRY = HWSETTINGS_USB_HIDPORT_USBTELEMETRY,
234 PIOS_BOARD_IO_USB_HID_RCTX = HWSETTINGS_USB_HIDPORT_RCTRANSMITTER,
235 } PIOS_BOARD_IO_USB_HID_Function;
237 typedef enum {
238 PIOS_BOARD_IO_USB_VCP_NONE = HWSETTINGS_USB_VCPPORT_DISABLED,
239 PIOS_BOARD_IO_USB_VCP_TELEMETRY = HWSETTINGS_USB_VCPPORT_USBTELEMETRY,
240 PIOS_BOARD_IO_USB_VCP_COMBRIDGE = HWSETTINGS_USB_VCPPORT_COMBRIDGE,
241 PIOS_BOARD_IO_USB_VCP_DEBUGCONSOLE = HWSETTINGS_USB_VCPPORT_DEBUGCONSOLE,
242 PIOS_BOARD_IO_USB_VCP_MAVLINK = HWSETTINGS_USB_VCPPORT_MAVLINK,
243 } PIOS_BOARD_IO_USB_VCP_Function;
245 void PIOS_BOARD_IO_Configure_USB_Function(PIOS_BOARD_IO_USB_HID_Function hid_function, PIOS_BOARD_IO_USB_VCP_Function vcp_function);
246 # endif // ifndef BOOTLOADER
247 #endif // ifdef PIOS_INCLUDE_USB
248 #ifdef PIOS_INCLUDE_PWM
249 void PIOS_BOARD_IO_Configure_PWM_RCVR(const struct pios_pwm_cfg *pwm_cfg);
250 #endif
251 #ifdef PIOS_INCLUDE_PPM
252 void PIOS_BOARD_IO_Configure_PPM_RCVR(const struct pios_ppm_cfg *ppm_cfg);
253 #endif
254 #ifdef PIOS_INCLUDE_USART
255 void PIOS_BOARD_IO_Configure_UART(const struct pios_usart_cfg *usart_cfg, PIOS_BOARD_IO_UART_Function function);
256 void PIOS_BOARD_IO_Configure_UART_COM(const struct pios_usart_cfg *hw_config,
257 uint16_t rx_buf_len,
258 uint16_t tx_buf_len,
259 uint32_t *com_id);
260 #endif
262 #ifdef PIOS_INCLUDE_RFM22B
263 void PIOS_BOARD_IO_Configure_RFM22B();
264 void PIOS_BOARD_IO_Configure_RadioAuxStream(HwSettingsRadioAuxStreamOptions radioaux); /* not for OPLM */
265 #endif
267 #ifdef PIOS_INCLUDE_GCSRCVR
268 void PIOS_BOARD_IO_Configure_GCS_RCVR();
269 #endif
271 #ifdef PIOS_INCLUDE_OPLINKRCVR
272 void PIOS_BOARD_IO_Configure_OPLink_RCVR();
273 #endif
275 #endif /* PIOS_BOARD_IO_H */