dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_hal.h
Go to the documentation of this file.
1 #ifndef PIOS_HAL_H
2 #define PIOS_HAL_H
3 
4 #include <uavobjectmanager.h> /* XXX TODO */
5 #include <hwshared.h>
6 
7 #ifdef PIOS_INCLUDE_USART
8 #include <pios_usart_priv.h>
9 #include <pios_sbus_priv.h>
10 #include <pios_dsm_priv.h>
11 #include <pios_ppm_priv.h>
12 #include <pios_pwm_priv.h>
13 #endif
14 
15 #ifdef PIOS_INCLUDE_I2C
16 #include <pios_i2c_priv.h>
17 #else
19 #endif
20 
21 #include <pios_usb_cdc_priv.h>
22 #include <pios_usb_hid_priv.h>
23 
24 #if defined(PIOS_INCLUDE_OPENLRS)
25 #include <pios_openlrs_priv.h>
26 #endif /* PIOS_INCLUDE_OPENLRS */
27 
28 struct pios_dsm_cfg;
29 struct pios_sbus_cfg;
30 struct pios_usb_cdc_cfg;
31 struct pios_usb_hid_cfg;
32 struct pios_usart_cfg;
33 struct pios_usart_params;
35 struct pios_ppm_cfg;
36 struct pios_pwm_cfg;
37 
42  // start at 2, so that panic codes are obvious to user
43  // PLEASE ENSURE USER DOCUMENTATION IS UPDATED IF MODIFYING THIS ENUM!!
44  // avoid changing the numbers if possible as it will break docs for old releases
56 };
57 
58 #define PIOS_COM_TELEM_SER (pios_com_telem_serial_id)
59 
60 /* One slot per selectable receiver group.
61  * eg. PWM, PPM, GCS, SPEKTRUM1, SPEKTRUM2, SBUS
62  * NOTE: No slot in this map for NONE.
63  */
64 extern uintptr_t pios_rcvr_group_map[];
65 
66 #if defined(PIOS_INCLUDE_SBUS) || defined(PIOS_INCLUDE_DSM) || defined(PIOS_INCLUDE_HOTT) || defined(PIOS_INCLUDE_GPS) || defined(PIOS_INCLUDE_OPENLRS) || defined(PIOS_INCLUDE_USB_CDC) || defined(PIOS_INCLUDE_USB_HID) || defined(PIOS_INCLUDE_MAVLINK)
67 
68 #ifndef PIOS_INCLUDE_COM
69 #error Options defined that require PIOS_INCLUDE_COM!
70 #endif
71 
72 #if !defined(PIOS_INCLUDE_USART) && !defined(FLIGHT_POSIX)
73 #error Options defined that require PIOS_INCLUDE_USART!
74 #endif
75 
76 #endif
77 
78 void PIOS_HAL_CriticalError(uint32_t led_id, enum pios_hal_panic code);
79 
80 #ifdef PIOS_INCLUDE_USART
81 /* USART here is used as a proxy for hardware-ish capabilities... Hacky */
82 
83 void PIOS_HAL_ConfigureCom(const struct pios_usart_cfg *usart_port_cfg, struct pios_usart_params *usart_port_params,
84  size_t rx_buf_len, size_t tx_buf_len,
85  const struct pios_com_driver *com_driver, uintptr_t *com_id);
86 
87 void PIOS_HAL_ConfigurePort(HwSharedPortTypesOptions port_type,
88  const struct pios_usart_cfg *usart_port_cfg,
89  const struct pios_com_driver *com_driver,
90  pios_i2c_t *i2c_id,
91  const struct pios_i2c_adapter_cfg *i2c_cfg,
92  const struct pios_ppm_cfg *ppm_cfg,
93  const struct pios_pwm_cfg *pwm_cfg,
94  uint32_t led_id,
95  /* TODO: future work to factor most of these away */
96  const struct pios_dsm_cfg *dsm_cfg,
97  HwSharedDSMxModeOptions dsm_mode,
98  const struct pios_sbus_cfg *sbus_cfg);
99 #endif
100 
101 #ifdef PIOS_INCLUDE_I2C
102 int PIOS_HAL_ConfigureExternalBaro(HwSharedExtBaroOptions baro,
103  pios_i2c_t *i2c_id,
104  const struct pios_i2c_adapter_cfg *i2c_cfg);
105 
106 int PIOS_HAL_ConfigureExternalMag(HwSharedMagOptions mag,
107  HwSharedMagOrientationOptions orientation,
108  pios_i2c_t *i2c_id,
109  const struct pios_i2c_adapter_cfg *i2c_cfg);
110 #endif
111 
112 void PIOS_HAL_ConfigureCDC(HwSharedUSB_VCPPortOptions port_type,
113  uintptr_t usb_id,
114  const struct pios_usb_cdc_cfg *cdc_cfg);
115 
116 void PIOS_HAL_ConfigureHID(HwSharedUSB_HIDPortOptions port_type,
117  uintptr_t usb_id,
118  const struct pios_usb_hid_cfg *hid_cfg);
119 
120 #if defined(PIOS_INCLUDE_OPENLRS)
121 #include <pios_openlrs.h>
122 
123 void PIOS_HAL_ConfigureRFM22B(pios_spi_t spi_dev,
124  uint8_t board_type, uint8_t board_rev,
125  HwSharedRfBandOptions rf_band,
126  HwSharedMaxRfPowerOptions rf_power,
127  const struct pios_openlrs_cfg *openlrs_cfg,
128  pios_openlrs_t *handle);
129 #endif /* PIOS_INCLUDE_RFM22B */
130 
131 void PIOS_HAL_ConfigureSerialSpeed(uintptr_t com_id,
132  HwSharedSpeedBpsOptions speed);
133 
134 void PIOS_HAL_SetReceiver(int receiver_type, uintptr_t value);
135 uintptr_t PIOS_HAL_GetReceiver(int receiver_type);
137 
138 #ifdef PIOS_INCLUDE_DAC
139 #include <pios_fskdac.h>
140 #include <pios_annuncdac.h>
141 
142 int PIOS_HAL_ConfigureDAC(dac_dev_t dac);
143 #endif
144 
145 #endif
uint16_t speed
Definition: msp_messages.h:101
void PIOS_HAL_ConfigureCDC(HwSharedUSB_VCPPortOptions port_type, uintptr_t usb_id, const struct pios_usb_cdc_cfg *cdc_cfg)
struct _msp_pid_item mag
Definition: msp_messages.h:104
void PIOS_HAL_InitUAVTalkReceiver()
Definition: pios_hal.c:1435
static uint8_t board_rev
Definition: firmwareiap.c:71
int PIOS_HAL_ConfigureExternalBaro(HwSharedExtBaroOptions baro, pios_i2c_t *i2c_id, const struct pios_i2c_adapter_cfg *i2c_cfg)
Definition: pios_hal.c:1242
int PIOS_HAL_ConfigureExternalMag(HwSharedMagOptions mag, HwSharedMagOrientationOptions orientation, pios_i2c_t *i2c_id, const struct pios_i2c_adapter_cfg *i2c_cfg)
Definition: pios_hal.c:1298
void PIOS_HAL_ConfigureSerialSpeed(uintptr_t com_id, HwSharedSpeedBpsOptions speed)
Definition: pios_hal.c:1115
USART private definitions.
Spektrum/JR DSMx satellite receiver private structures.
struct pios_i2c_adapter * pios_i2c_t
Definition: pios_i2c.h:48
ppm private structures.
USB COM HID private definitions.
uintptr_t pios_rcvr_group_map[]
Definition: pios_hal.c:73
uint16_t value
Definition: storm32bgc.c:155
void PIOS_HAL_ConfigureHID(HwSharedUSB_HIDPortOptions port_type, uintptr_t usb_id, const struct pios_usb_hid_cfg *hid_cfg)
uintptr_t PIOS_HAL_GetReceiver(int receiver_type)
pios_hal_panic
Definition: pios_hal.h:41
Futaba S.Bus Private structures.
uint8_t board_type
struct dac_dev_s * dac_dev_t
Definition: pios_dac.h:40
Implements an OpenLRS driver for the RFM22B.
void PIOS_HAL_CriticalError(uint32_t led_id, enum pios_hal_panic code)
Flash a blink code.
Definition: pios_hal.c:291
USB COM CDC private definitions.
void PIOS_HAL_SetReceiver(int receiver_type, uintptr_t value)
Implements an OpenLRS driver for the RFM22B.