ChibiOS  21.6.0
hal.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal.h
19  * @brief HAL subsystem header.
20  *
21  * @addtogroup HAL
22  * @{
23  */
24 
25 #ifndef HAL_H
26 #define HAL_H
27 
28 #include "osal.h"
29 #include "board.h"
30 #include "halconf.h"
31 
32 /* Low Level HAL support.*/
33 #include "hal_lld.h"
34 
35 /*===========================================================================*/
36 /* Driver constants. */
37 /*===========================================================================*/
38 
39 /**
40  * @brief ChibiOS/HAL identification macro.
41  */
42 #define __CHIBIOS_HAL__
43 
44 /**
45  * @brief Stable release flag.
46  */
47 #define CH_HAL_STABLE 0
48 
49 /**
50  * @name ChibiOS/HAL version identification
51  * @{
52  */
53 /**
54  * @brief HAL version string.
55  */
56 #define HAL_VERSION "7.2.0"
57 
58 /**
59  * @brief HAL version major number.
60  */
61 #define CH_HAL_MAJOR 7
62 
63 /**
64  * @brief HAL version minor number.
65  */
66 #define CH_HAL_MINOR 2
67 
68 /**
69  * @brief HAL version patch number.
70  */
71 #define CH_HAL_PATCH 0
72 /** @} */
73 
74 /**
75  * @name Return codes
76  * @{
77  */
78 /**
79  * @brief HAL operation success.
80  */
81 #define HAL_SUCCESS false
82 /**
83  * @brief HAL operation failed.
84  */
85 #define HAL_FAILED true
86 /** @} */
87 
88 /*===========================================================================*/
89 /* Driver pre-compile time settings. */
90 /*===========================================================================*/
91 
92 /*===========================================================================*/
93 /* Derived constants and error checks. */
94 /*===========================================================================*/
95 
96 /* Configuration file checks.*/
97 #if !defined(_CHIBIOS_HAL_CONF_)
98 #error "invalid configuration file"
99 #endif
100 
101 #if !defined(_CHIBIOS_HAL_CONF_VER_7_1_)
102 #error "obsolete or unknown configuration file"
103 #endif
104 
105 /* Error checks on the configuration header file.*/
106 #if !defined(HAL_USE_PAL)
107 #define HAL_USE_PAL FALSE
108 #endif
109 
110 #if !defined(HAL_USE_ADC)
111 #define HAL_USE_ADC FALSE
112 #endif
113 
114 #if !defined(HAL_USE_CAN)
115 #define HAL_USE_CAN FALSE
116 #endif
117 
118 #if !defined(HAL_USE_CRY)
119 #define HAL_USE_CRY FALSE
120 #endif
121 
122 #if !defined(HAL_USE_DAC)
123 #define HAL_USE_DAC FALSE
124 #endif
125 
126 #if !defined(HAL_USE_EFL)
127 #define HAL_USE_EFL FALSE
128 #endif
129 
130 #if !defined(HAL_USE_GPT)
131 #define HAL_USE_GPT FALSE
132 #endif
133 
134 #if !defined(HAL_USE_I2C)
135 #define HAL_USE_I2C FALSE
136 #endif
137 
138 #if !defined(HAL_USE_I2S)
139 #define HAL_USE_I2S FALSE
140 #endif
141 
142 #if !defined(HAL_USE_ICU)
143 #define HAL_USE_ICU FALSE
144 #endif
145 
146 #if !defined(HAL_USE_MAC)
147 #define HAL_USE_MAC FALSE
148 #endif
149 
150 #if !defined(HAL_USE_PWM)
151 #define HAL_USE_PWM FALSE
152 #endif
153 
154 #if !defined(HAL_USE_RTC)
155 #define HAL_USE_RTC FALSE
156 #endif
157 
158 #if !defined(HAL_USE_SERIAL)
159 #define HAL_USE_SERIAL FALSE
160 #endif
161 
162 #if !defined(HAL_USE_SDC)
163 #define HAL_USE_SDC FALSE
164 #endif
165 
166 #if !defined(HAL_USE_SIO)
167 #define HAL_USE_SIO FALSE
168 #endif
169 
170 #if !defined(HAL_USE_SPI)
171 #define HAL_USE_SPI FALSE
172 #endif
173 
174 #if !defined(HAL_USE_TRNG)
175 #define HAL_USE_TRNG FALSE
176 #endif
177 
178 #if !defined(HAL_USE_UART)
179 #define HAL_USE_UART FALSE
180 #endif
181 
182 #if !defined(HAL_USE_USB)
183 #define HAL_USE_USB FALSE
184 #endif
185 
186 #if !defined(HAL_USE_WDG)
187 #define HAL_USE_WDG FALSE
188 #endif
189 
190 #if !defined(HAL_USE_WSPI)
191 #define HAL_USE_WSPI FALSE
192 #endif
193 
194 /*===========================================================================*/
195 /* Driver data structures and types. */
196 /*===========================================================================*/
197 
198 /*===========================================================================*/
199 /* Driver macros. */
200 /*===========================================================================*/
201 
202 /*===========================================================================*/
203 /* External declarations. */
204 /*===========================================================================*/
205 
206 #ifdef __cplusplus
207 extern "C" {
208 #endif
209  void halInit(void);
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 /*===========================================================================*/
215 /* Driver inline functions. */
216 /*===========================================================================*/
217 
218 #if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
219 /**
220  * @brief Switches to a different clock configuration
221  *
222  * @param[in] ccp pointer to clock a @p halclkcfg_t structure
223  * @return The clock switch result.
224  * @retval false if the clock switch succeeded
225  * @retval true if the clock switch failed
226  *
227  * @special
228  */
229 static inline bool halClockSwitchMode(const halclkcfg_t *ccp) {
230 
231  return hal_lld_clock_switch_mode(ccp);
232 }
233 
234 /**
235  * @brief Returns the frequency of a clock point in Hz.
236  *
237  * @param[in] clkpt clock point to be returned
238  * @return The clock point frequency in Hz or zero if the
239  * frequency is unknown.
240  *
241  * @xclass
242  */
243 static inline halfreq_t halClockGetPointX(halclkpt_t clkpt) {
244 
245  return hal_lld_get_clock_point(clkpt);
246 }
247 #endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
248 
249 /*===========================================================================*/
250 /* Driver late inclusions. */
251 /*===========================================================================*/
252 
253 /* Abstract interfaces.*/
254 #include "hal_objects.h"
255 #include "hal_streams.h"
256 #include "hal_channels.h"
257 #include "hal_files.h"
258 #include "hal_ioblock.h"
259 #include "hal_mmcsd.h"
260 #include "hal_persistent.h"
261 #include "hal_flash.h"
262 
263 /* Shared headers.*/
264 #include "hal_buffers.h"
265 #include "hal_queues.h"
266 
267 /* Normal drivers.*/
268 #include "hal_pal.h"
269 #include "hal_adc.h"
270 #include "hal_can.h"
271 #include "hal_crypto.h"
272 #include "hal_dac.h"
273 #include "hal_efl.h"
274 #include "hal_gpt.h"
275 #include "hal_i2c.h"
276 #include "hal_i2s.h"
277 #include "hal_icu.h"
278 #include "hal_mac.h"
279 #include "hal_pwm.h"
280 #include "hal_rtc.h"
281 #include "hal_serial.h"
282 #include "hal_sdc.h"
283 #include "hal_sio.h"
284 #include "hal_spi.h"
285 #include "hal_trng.h"
286 #include "hal_uart.h"
287 #include "hal_usb.h"
288 #include "hal_wdg.h"
289 #include "hal_wspi.h"
290 
291 /*
292  * The ST driver is a special case, it is only included if the OSAL is
293  * configured to require it.
294  */
295 #if OSAL_ST_MODE != OSAL_ST_MODE_NONE
296 #include "hal_st.h"
297 #endif
298 
299 /* Complex drivers.*/
300 #include "hal_mmc_spi.h"
301 #include "hal_serial_usb.h"
302 
303 /* Community drivers.*/
304 #if defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
305 #if (HAL_USE_COMMUNITY == TRUE) || defined(__DOXYGEN__)
306 #include "hal_community.h"
307 #endif
308 #endif
309 
310 #endif /* HAL_H */
311 
312 /** @} */
hal_mmc_spi.h
MMC over SPI driver header.
hal_queues.h
I/O Queues macros and structures.
hal_can.h
CAN Driver macros and structures.
hal_files.h
Data files.
hal_i2s.h
I2S Driver macros and structures.
hal_gpt.h
GPT Driver macros and structures.
hal_serial.h
Serial Driver macros and structures.
hal_flash.h
Generic flash driver class header.
hal_wdg.h
WDG Driver macros and structures.
hal_mac.h
MAC Driver macros and structures.
hal_lld_get_clock_point
halfreq_t hal_lld_get_clock_point(halclkpt_t clkpt)
Returns the frequency of a clock point in Hz.
Definition: hal_lld.c:103
halClockGetPointX
static halfreq_t halClockGetPointX(halclkpt_t clkpt)
Returns the frequency of a clock point in Hz.
Definition: hal.h:243
hal_pal.h
I/O Ports Abstraction Layer macros, types and structures.
hal_st.h
ST Driver macros and structures.
hal_pwm.h
PWM Driver macros and structures.
halfreq_t
uint32_t halfreq_t
Type of a clock point frequency in Hz.
Definition: hal_lld.h:78
halClockSwitchMode
static bool halClockSwitchMode(const halclkcfg_t *ccp)
Switches to a different clock configuration.
Definition: hal.h:229
halInit
void halInit(void)
HAL initialization.
Definition: hal.c:56
hal_adc.h
ADC Driver macros and structures.
osal.h
OSAL module header.
hal_serial_usb.h
Serial over USB Driver macros and structures.
hal_lld_clock_switch_mode
bool hal_lld_clock_switch_mode(const halclkcfg_t *ccp)
Switches to a different clock configuration.
Definition: hal_lld.c:87
hal_i2c.h
I2C Driver macros and structures.
hal_mmcsd.h
MMC/SD cards common header.
hal_channels.h
I/O channels access.
hal_sio.h
SIO Driver macros and structures.
hal_buffers.h
I/O Buffers macros and structures.
hal_spi.h
SPI Driver macros and structures.
halconf.h
HAL configuration header.
hal_efl.h
Embedded Flash Driver macros and structures.
hal_icu.h
ICU Driver macros and structures.
hal_trng.h
TRNG Driver macros and structures.
hal_streams.h
Data streams.
hal_persistent.h
Generic persistent storage class header.
hal_objects.h
Base object.
hal_wspi.h
WSPI Driver macros and structures.
halclkcfg_t
Type of a clock configuration structure.
Definition: hal_lld.h:83
halclkpt_t
unsigned halclkpt_t
Type of a clock point identifier.
Definition: hal_lld.h:72
hal_uart.h
UART Driver macros and structures.
hal_ioblock.h
I/O block devices access.
hal_usb.h
USB Driver macros and structures.
hal_sdc.h
SDC Driver macros and structures.
hal_rtc.h
RTC Driver macros and structures.
hal_crypto.h
Cryptographic Driver macros and structures.
hal_dac.h
DAC Driver macros and structures.
hal_lld.h
PLATFORM HAL subsystem low level driver header.