LP-480 work in progress: revo, nano & sparky2 targets ok.
[librepilot.git] / flight / pios / inc / pios_board_io.h
blobbbcd5c2cc6c42f196291973daee5e55921273d4d
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 #include <pios_usart_priv.h>
38 #ifdef PIOS_INCLUDE_PWM
39 #include <pios_pwm_priv.h>
40 #endif
42 #ifdef PIOS_INCLUDE_PPM
43 #include <pios_ppm_priv.h>
44 #endif
46 #ifdef PIOS_INCLUDE_OPENLRS
47 #include <pios_openlrs_priv.h>
48 #endif
50 #ifdef PIOS_INCLUDE_RCVR
51 extern uint32_t pios_rcvr_group_map[]; /* Receivers */
52 #endif
54 /* GPS */
55 #ifdef PIOS_INCLUDE_GPS
56 extern uint32_t pios_com_gps_id;
57 # define PIOS_COM_GPS (pios_com_gps_id)
58 # ifndef PIOS_COM_GPS_RX_BUF_LEN
59 # define PIOS_COM_GPS_RX_BUF_LEN 128
60 # endif
61 # ifndef PIOS_COM_GPS_TX_BUF_LEN
62 # define PIOS_COM_GPS_TX_BUF_LEN 32
63 # endif
64 #endif /* PIOS_INCLUDE_GPS */
67 /* ComUsbBridge */
68 extern uint32_t pios_com_bridge_id;
69 #define PIOS_COM_BRIDGE (pios_com_bridge_id)
70 #ifndef PIOS_COM_BRIDGE_RX_BUF_LEN
71 # define PIOS_COM_BRIDGE_RX_BUF_LEN 65
72 #endif
73 #ifndef PIOS_COM_BRIDGE_TX_BUF_LEN
74 # define PIOS_COM_BRIDGE_TX_BUF_LEN 12
75 #endif
78 /* USB telemetry */
79 extern uint32_t pios_com_telem_usb_id;
80 #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
81 #ifndef PIOS_COM_TELEM_USB_RX_BUF_LEN
82 # define PIOS_COM_TELEM_USB_RX_BUF_LEN 65
83 #endif
84 #ifndef PIOS_COM_TELEM_USB_TX_BUF_LEN
85 #define PIOS_COM_TELEM_USB_TX_BUF_LEN 65
86 #endif
88 /* Serial port telemetry */
89 extern uint32_t pios_com_telem_rf_id;
90 #define PIOS_COM_TELEM_RF (pios_com_telem_rf_id)
91 #ifndef PIOS_COM_TELEM_RF_RX_BUF_LEN
92 # define PIOS_COM_TELEM_RF_RX_BUF_LEN 512
93 #endif
94 #ifndef PIOS_COM_TELEM_RF_TX_BUF_LEN
95 # define PIOS_COM_TELEM_RF_TX_BUF_LEN 512
96 #endif
99 /* RFM22B telemetry */
100 #ifdef PIOS_INCLUDE_RFM22B
101 extern uint32_t pios_com_rf_id;
102 # define PIOS_COM_RF (pios_com_rf_id)
103 # ifndef PIOS_COM_RFM22B_RF_RX_BUF_LEN
104 # define PIOS_COM_RFM22B_RF_RX_BUF_LEN 512
105 # endif
106 # ifndef PIOS_COM_RFM22B_RF_TX_BUF_LEN
107 # define PIOS_COM_RFM22B_RF_TX_BUF_LEN 512
108 # endif
109 #endif
112 /* HK OSD ?? */
113 extern uint32_t pios_com_hkosd_id;
114 #define PIOS_COM_OSDHK (pios_com_hkosd_id)
115 #ifndef PIOS_COM_HKOSD_RX_BUF_LEN
116 # define PIOS_COM_HKOSD_RX_BUF_LEN 22
117 #endif
118 #ifndef PIOS_COM_HKOSD_TX_BUF_LEN
119 # define PIOS_COM_HKOSD_TX_BUF_LEN 22
120 #endif
122 /* MSP */
123 extern uint32_t pios_com_msp_id;
124 #define PIOS_COM_MSP (pios_com_msp_id)
125 #ifndef PIOS_COM_MSP_TX_BUF_LEN
126 # define PIOS_COM_MSP_TX_BUF_LEN 128
127 #endif
128 #ifndef PIOS_COM_MSP_RX_BUF_LEN
129 # define PIOS_COM_MSP_RX_BUF_LEN 64
130 #endif
132 /* MAVLink */
133 extern uint32_t pios_com_mavlink_id;
134 #define PIOS_COM_MAVLINK (pios_com_mavlink_id)
135 #ifndef PIOS_COM_MAVLINK_TX_BUF_LEN
136 # define PIOS_COM_MAVLINK_TX_BUF_LEN 128
137 #endif
138 #ifndef PIOS_COM_MAVLINK_RX_BUF_LEN
139 # define PIOS_COM_MAVLINK_RX_BUF_LEN 128
140 #endif
142 /* USB VCP */
143 extern uint32_t pios_com_vcp_id;
144 #define PIOS_COM_VCP (pios_com_vcp_id)
147 #ifdef PIOS_INCLUDE_DEBUG_CONSOLE
148 extern uint32_t pios_com_debug_id;
149 #define PIOS_COM_DEBUG (pios_com_debug_id)
150 #ifndef PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN
151 # define PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN 40
152 #endif
153 #endif /* PIOS_INCLUDE_DEBUG_CONSOLE */
155 #ifdef PIOS_INCLUDE_USB_RCTX
156 extern uint32_t pios_usb_rctx_id;
157 #endif /* PIOS_INCLUDE_USB_RCTX */
159 #if defined(PIOS_INCLUDE_HMC5X83) && defined(PIOS_HMC5X83_HAS_GPIOS)
160 #include <pios_hmc5x83.h>
161 extern pios_hmc5x83_dev_t pios_hmc5x83_internal_id;
162 #endif
164 typedef enum {
165 PIOS_BOARD_IO_UART_NONE,
166 PIOS_BOARD_IO_UART_TELEMETRY, /* com */
167 PIOS_BOARD_IO_UART_MAVLINK, /* com */
168 PIOS_BOARD_IO_UART_MSP, /* com */
169 PIOS_BOARD_IO_UART_GPS, /* com */
170 PIOS_BOARD_IO_UART_COMBRIDGE, /* com */
171 PIOS_BOARD_IO_UART_DEBUGCONSOLE, /* com */
172 PIOS_BOARD_IO_UART_OSDHK, /* com */
173 PIOS_BOARD_IO_UART_SBUS, /* rcvr */
174 PIOS_BOARD_IO_UART_DSM_MAIN, /* rcvr */
175 PIOS_BOARD_IO_UART_DSM_FLEXI, /* rcvr */
176 PIOS_BOARD_IO_UART_DSM_RCVR, /* rcvr */
177 PIOS_BOARD_IO_UART_HOTT_SUMD, /* rcvr */
178 PIOS_BOARD_IO_UART_HOTT_SUMH, /* rcvr */
179 PIOS_BOARD_IO_UART_SRXL, /* rcvr */
180 PIOS_BOARD_IO_UART_IBUS, /* rcvr */
181 PIOS_BOARD_IO_UART_EXBUS, /* rcvr */
182 } PIOS_BOARD_IO_UART_Function;
184 #ifdef PIOS_INCLUDE_USB
185 void PIOS_BOARD_IO_Configure_USB();
186 # if defined(PIOS_INCLUDE_USB_HID)
187 # include <pios_usb_hid_priv.h>
188 extern const struct pios_usb_hid_cfg pios_usb_hid_cfg;
189 # endif /* PIOS_INCLUDE_USB_HID */
190 #endif /* PIOS_INCLUDE_USB */
191 #ifdef PIOS_INCLUDE_PWM
192 void PIOS_BOARD_IO_Configure_PWM(const struct pios_pwm_cfg *pwm_cfg);
193 #endif
194 #ifdef PIOS_INCLUDE_PPM
195 void PIOS_BOARD_IO_Configure_PPM(const struct pios_ppm_cfg *ppm_cfg);
196 #endif
198 void PIOS_BOARD_IO_Configure_UART(const struct pios_usart_cfg *usart_cfg, PIOS_BOARD_IO_UART_Function function);
200 #ifdef PIOS_INCLUDE_RFM22B
201 void PIOS_BOARD_IO_Configure_RFM22B();
202 #endif
204 #ifdef PIOS_INCLUDE_I2C
205 void PIOS_BOARD_IO_Configure_I2C(uint32_t i2c_internal_id, uint32_t i2c_external_id);
206 #endif
208 #ifdef PIOS_INCLUDE_GCSRCVR
209 void PIOS_BOARD_IO_Configure_GCSRCVR();
210 #endif
212 #ifdef PIOS_INCLUDE_WS2811
213 void PIOS_BOARD_IO_Configure_WS2811();
214 #endif
216 #ifdef PIOS_INCLUDE_ADC
217 void PIOS_BOARD_IO_Configure_ADC();
218 #endif
221 #endif /* PIOS_BOARD_IO_H */