dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 
31 #ifndef PIOS_H
32 #define PIOS_H
33 
34 /* PIOS Feature Selection */
35 #include "pios_config.h"
36 
37 #ifdef FLIGHT_POSIX
38 #include <pios_posix.h>
39 #endif
40 
41 #if defined(PIOS_INCLUDE_CHIBIOS)
42 /* @note This is required because of difference in chip define between ChibiOS and ST libs.
43  * It is also used to force inclusion of chibios_transition defines. */
44 #include "hal.h"
45 
46 #define PIOS_INCLUDE_RTOS
47 
48 #endif /* defined(PIOS_INCLUDE_CHIBIOS) */
49 
50 /* C Lib Includes */
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <stdarg.h>
54 #include <stdint.h>
55 #include <stdbool.h>
56 #include <string.h>
57 #include <math.h>
58 
59 /* STM32 Std Periph Lib */
60 #if defined(STM32F4XX)
61 # include <stm32f4xx.h>
62 # include <stm32f4xx_rcc.h>
63 #elif defined(STM32F30X)
64 #include <stm32f30x.h>
65 #include <stm32f30x_rcc.h>
66 #elif defined(STM32F2XX)
67 #include <stm32f2xx.h>
68 #include <stm32f2xx_syscfg.h>
69 #elif defined(STM32F0XX)
70 #include <stm32f0xx.h>
71 #elif defined(STM32F10X_MD)
72 #include <stm32f10x.h>
73 #elif !defined(FLIGHT_POSIX) && !defined(PIOS_NO_HW)
74 #error Must define a hardware type or PIOS_NO_HW
75 #endif
76 
77 /* PIOS Board Specific Device Configuration */
78 #include "pios_board.h"
79 
80 /* Generic initcall infrastructure */
81 #if defined(PIOS_INCLUDE_INITCALL)
82 #include "pios_initcall.h"
83 #endif
84 
85 /* PIOS Hardware Includes */
86 #include <pios_sys.h>
87 #include <pios_delay.h>
88 #include <pios_annunc.h>
89 #include <pios_irq.h>
90 #include <pios_adc.h>
91 #include <pios_internal_adc.h>
92 #include <pios_servo.h>
93 #include <pios_rtc.h>
94 #include <pios_i2c.h>
95 #include <pios_can.h>
96 #include <pios_spi.h>
97 #include <pios_ppm.h>
98 #include <pios_pwm.h>
99 #include <pios_rcvr.h>
100 #include <pios_reset.h>
101 #if defined(PIOS_INCLUDE_DMA_CB_SUBSCRIBING_FUNCTION)
102 #include <pios_dma.h>
103 #endif
104 #if defined(PIOS_INCLUDE_RTOS)
105 #include <pios_sensors.h>
106 #endif
107 #include <pios_wdg.h>
108 
109 #if !defined(FLIGHT_POSIX) && !defined(PIOS_NO_HW)
110 #include <pios_exti.h>
111 #include <pios_usart.h>
112 #include <pios_srxl.h>
113 #endif // !FLIGHT_POSIX && ! PIOS_NO_HW
114 
115 /* PIOS Hardware Includes (Common) */
116 #include <pios_debug.h>
117 #include <pios_heap.h>
118 #include <pios_com.h>
119 #if defined(PIOS_INCLUDE_MPXV7002)
120 #include <pios_mpxv7002.h>
121 #endif
122 #if defined(PIOS_INCLUDE_MPXV5004)
123 #include <pios_mpxv5004.h>
124 #endif
125 #if defined(PIOS_INCLUDE_ETASV3)
126 #include <pios_etasv3.h>
127 #endif
128 #if defined(PIOS_INCLUDE_BMP280) || defined(PIOS_INCLUDE_BMP280_SPI)
129 #include <pios_bmp280.h>
130 #endif
131 #if defined(PIOS_INCLUDE_HCSR04)
132 #include <pios_hcsr04.h>
133 #endif
134 #if defined(PIOS_INCLUDE_HMC5983)
135 #include <pios_hmc5983.h>
136 #endif
137 #if defined(PIOS_INCLUDE_MPU)
138 #include <pios_mpu.h>
139 #endif
140 #if defined(PIOS_INCLUDE_L3GD20)
141 #include <pios_l3gd20.h>
142 #endif
143 #if defined(PIOS_INCLUDE_LSM303)
144 #include <pios_lsm303.h>
145 #endif
146 #if defined(PIOS_INCLUDE_MS5611)
147 #include <pios_ms5611.h>
148 #endif
149 #if defined(PIOS_INCLUDE_MS5611_SPI)
150 #include <pios_ms5611_spi.h>
151 #endif
152 #if defined(PIOS_INCLUDE_IAP)
153 #include <pios_iap.h>
154 #endif
155 #if defined(PIOS_INCLUDE_VIDEO)
156 #include <pios_video.h>
157 #endif
158 
159 #if defined(PIOS_INCLUDE_FLASH)
160 #include <pios_flash.h>
161 #include <pios_flashfs.h>
162 #endif
163 
164 #if defined(PIOS_INCLUDE_BL_HELPER)
165 #include <pios_bl_helper.h>
166 #endif
167 
168 #if defined(PIOS_INCLUDE_USB)
169 #include <pios_usb.h>
170 #endif
171 
172 #if defined(PIOS_INCLUDE_IBUS)
173 #include <pios_ibus.h>
174 #endif
175 
176 #if defined(PIOS_INCLUDE_CROSSFIRE)
177 #include <pios_crossfire.h>
178 #endif
179 
180 #if defined(PIOS_INCLUDE_MAX7456)
181 #include <pios_max7456.h>
182 #endif
183 
184 #if defined(PIOS_INCLUDE_WS2811)
185 #include <pios_ws2811.h>
186 #endif
187 
188 #include <pios_modules.h>
189 
190 #include <pios_crc.h>
191 
192 #define NELEMENTS(x) (sizeof(x) / sizeof(*(x)))
193 #define DONT_BUILD_IF(COND,MSG) typedef char static_assertion_##MSG[(COND)?-1:1]
194 
195 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
196  #define CPU_TO_LE16(x) (x)
197  #define CPU_TO_LE32(x) (x)
198 
199  #define CPU_TO_BE16(x) ( (((x) & 0xff00) >> 8) | \
200  (((x) & 0x00ff) << 8) )
201  #define CPU_TO_BE32(x) ( (((x) & 0xff000000) >> 24) | \
202  (((x) & 0x00ff0000) >> 8) | \
203  (((x) & 0x0000ff00) << 8) | \
204  (((x) & 0x000000ff) << 24) )
205 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
206  #define CPU_TO_LE16(x) ( (((x) & 0xff00) >> 8) | \
207  (((x) & 0x00ff) << 8) )
208  #define CPU_TO_LE32(x) ( (((x) & 0xff000000) >> 24) | \
209  (((x) & 0x00ff0000) >> 8) | \
210  (((x) & 0x0000ff00) << 8) | \
211  (((x) & 0x000000ff) << 24) )
212 
213  #define CPU_TO_BE16(x) (x)
214  #define CPU_TO_BE32(x) (x)
215 #else
216  #error Unsupported architecture!
217 #endif /* __BYTE_ORDER__ */
218 
219 #define LE16_TO_CPU(x) CPU_TO_LE16(x)
220 #define LE32_TO_CPU(x) CPU_TO_LE32(x)
221 #define BE16_TO_CPU(x) CPU_TO_BE16(x)
222 #define BE32_TO_CPU(x) CPU_TO_BE32(x)
223 
224 #endif /* PIOS_H */
225 
CRC functions header.
USART functions header.
HMC5983 functions header.
COM layer functions header.
OSD gen module, handles OSD draw. Parts from CL-OSD and SUPEROSD projects.
ETASV3 Airspeed Sensor Driver.
Debug helper functions header.
MS5611 functions header.
MS5611 functions header.
SPI functions header.
RTC functions header.
ETASV3 Airspeed Sensor Driver.
ADC layer functions header.
SPI functions header.
HCSR04 functions header.
RCVR layer functions header.
USB HID layer functions header.
PWM Input functions header.
ADC functions header.
PWM Input functions header.
PiOS CAN interface header.
Generic interface for sensors.
External Interrupts Handlers header.
Annunciator functions header.
Reset information.
ETASV3 Airspeed Sensor Driver.
RC Servo functions header.
In application programming functions.