ChibiOS/HAL 9.0.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 "ccportab.h"
29
30#include "osal.h"
31#include "board.h"
32#include "halconf.h"
33
34/*===========================================================================*/
35/* Driver constants. */
36/*===========================================================================*/
37
38/**
39 * @brief ChibiOS/HAL identification macro.
40 */
41#define __CHIBIOS_HAL__
42
43/**
44 * @brief Stable release flag.
45 */
46#define CH_HAL_STABLE 1
47
48/**
49 * @name ChibiOS/HAL version identification
50 * @{
51 */
52/**
53 * @brief HAL version string.
54 */
55#define CH_HAL_VERSION "9.0.0"
56
57/**
58 * @brief HAL version major number.
59 */
60#define CH_HAL_MAJOR 9
61
62/**
63 * @brief HAL version minor number.
64 */
65#define CH_HAL_MINOR 0
66
67/**
68 * @brief HAL version patch number.
69 */
70#define CH_HAL_PATCH 0
71/** @} */
72
73/**
74 * @name Return codes
75 * @{
76 */
77/**
78 * @brief HAL operation success.
79 * @deprecated
80 */
81#define HAL_SUCCESS false
82/**
83 * @brief HAL operation failed.
84 * @deprecated
85 */
86#define HAL_FAILED true
87/** @} */
88
89/**
90 * @name Return codes for HAL functions
91 * @{
92 */
93#define HAL_RET_SUCCESS MSG_OK
94/**
95 * @brief Configuration error.
96 * @details An error has been detected in the driver configuration structure.
97 */
98#define HAL_RET_CONFIG_ERROR (msg_t)-16
99/**
100 * @brief A required resource is not available.
101 * @details One of the resources required for driver operations is not
102 * available.
103 */
104#define HAL_RET_NO_RESOURCE (msg_t)-17
105/**
106 * @brief The peripheral is busy.
107 * @details The peripheral is not available or taken by some other system
108 * actor.
109 */
110#define HAL_RET_HW_BUSY (msg_t)-18
111/**
112 * @brief Peripheral failure.
113 * @details Peripheral failed, for example HW timeouts.
114 */
115#define HAL_RET_HW_FAILURE (msg_t)-19
116/**
117 * @brief Unknown control code.
118 */
119#define HAL_RET_UNKNOWN_CTL (msg_t)-20
120/**
121 * @brief Invalid instance pointer.
122 */
123#define HAL_RET_IS_INVALID (msg_t)-21
124/** @} */
125
126/*===========================================================================*/
127/* Driver pre-compile time settings. */
128/*===========================================================================*/
129
130/*===========================================================================*/
131/* Derived constants and error checks. */
132/*===========================================================================*/
133
134/* Configuration file checks.*/
135#if !defined(_CHIBIOS_HAL_CONF_)
136#error "invalid configuration file"
137#endif
138
139#if !defined(_CHIBIOS_HAL_CONF_VER_9_0_)
140#error "obsolete or unknown configuration file"
141#endif
142
143/* Error checks on the configuration header file.*/
144#if !defined(HAL_USE_PAL)
145#define HAL_USE_PAL FALSE
146#endif
147
148#if !defined(HAL_USE_ADC)
149#define HAL_USE_ADC FALSE
150#endif
151
152#if !defined(HAL_USE_CAN)
153#define HAL_USE_CAN FALSE
154#endif
155
156#if !defined(HAL_USE_CRY)
157#define HAL_USE_CRY FALSE
158#endif
159
160#if !defined(HAL_USE_DAC)
161#define HAL_USE_DAC FALSE
162#endif
163
164#if !defined(HAL_USE_EFL)
165#define HAL_USE_EFL FALSE
166#endif
167
168#if !defined(HAL_USE_GPT)
169#define HAL_USE_GPT FALSE
170#endif
171
172#if !defined(HAL_USE_I2C)
173#define HAL_USE_I2C FALSE
174#endif
175
176#if !defined(HAL_USE_I2S)
177#define HAL_USE_I2S FALSE
178#endif
179
180#if !defined(HAL_USE_ICU)
181#define HAL_USE_ICU FALSE
182#endif
183
184#if !defined(HAL_USE_MAC)
185#define HAL_USE_MAC FALSE
186#endif
187
188#if !defined(HAL_USE_PWM)
189#define HAL_USE_PWM FALSE
190#endif
191
192#if !defined(HAL_USE_RTC)
193#define HAL_USE_RTC FALSE
194#endif
195
196#if !defined(HAL_USE_SERIAL)
197#define HAL_USE_SERIAL FALSE
198#endif
199
200#if !defined(HAL_USE_SDC)
201#define HAL_USE_SDC FALSE
202#endif
203
204#if !defined(HAL_USE_SIO)
205#define HAL_USE_SIO FALSE
206#endif
207
208#if !defined(HAL_USE_SPI)
209#define HAL_USE_SPI FALSE
210#endif
211
212#if !defined(HAL_USE_TRNG)
213#define HAL_USE_TRNG FALSE
214#endif
215
216#if !defined(HAL_USE_UART)
217#define HAL_USE_UART FALSE
218#endif
219
220#if !defined(HAL_USE_USB)
221#define HAL_USE_USB FALSE
222#endif
223
224#if !defined(HAL_USE_WDG)
225#define HAL_USE_WDG FALSE
226#endif
227
228#if !defined(HAL_USE_WSPI)
229#define HAL_USE_WSPI FALSE
230#endif
231
232/*===========================================================================*/
233/* Driver data structures and types. */
234/*===========================================================================*/
235
236/**
237 * @brief Type of a clock point identifier.
238 */
239typedef unsigned halclkpt_t;
240
241/**
242 * @brief Type of a clock point frequency in Hz.
243 */
244typedef uint32_t halfreq_t;
245
246/*===========================================================================*/
247/* Driver macros. */
248/*===========================================================================*/
249
250/*===========================================================================*/
251/* External declarations. */
252/*===========================================================================*/
253
254#ifdef __cplusplus
255extern "C" {
256#endif
257 void halInit(void);
258#ifdef __cplusplus
259}
260#endif
261
262/* Low Level HAL support.*/
263#include "hal_lld.h"
264
265/*===========================================================================*/
266/* Driver inline functions. */
267/*===========================================================================*/
268
269/**
270 * @brief Returns the frequency of a clock point in Hz.
271 *
272 * @param[in] clkpt clock point to be returned
273 * @return The clock point frequency in Hz or zero if the
274 * frequency is unknown.
275 *
276 * @xclass
277 */
279
280 (void)clkpt; /* LLD macro could not use it.*/
281
282 return hal_lld_get_clock_point(clkpt);
283}
284
285#if defined(HAL_LLD_USE_CLOCK_MANAGEMENT) || defined(__DOXYGEN__)
286/**
287 * @brief Switches to a different clock configuration
288 *
289 * @param[in] ccp pointer to clock a @p halclkcfg_t structure
290 * @return The clock switch result.
291 * @retval false if the clock switch succeeded
292 * @retval true if the clock switch failed
293 *
294 * @special
295 */
296static inline bool halClockSwitchMode(const halclkcfg_t *ccp) {
297
298 return hal_lld_clock_switch_mode(ccp);
299}
300#endif /* defined(HAL_LLD_USE_CLOCK_MANAGEMENT) */
301
302/*===========================================================================*/
303/* Driver late inclusions. */
304/*===========================================================================*/
305
306/* Abstract interfaces.*/
307#include "hal_objects.h"
308#include "hal_streams.h"
309#include "hal_channels.h"
310#include "hal_files.h"
311#include "hal_ioblock.h"
312#include "hal_mmcsd.h"
313#include "hal_persistent.h"
314#include "hal_flash.h"
315
316/* Shared headers.*/
317#include "hal_buffers.h"
318#include "hal_queues.h"
319#include "hal_buffered_serial.h"
320
321/* Normal drivers.*/
322#include "hal_pal.h"
323#include "hal_adc.h"
324#include "hal_can.h"
325#include "hal_crypto.h"
326#include "hal_dac.h"
327#include "hal_efl.h"
328#include "hal_gpt.h"
329#include "hal_i2c.h"
330#include "hal_i2s.h"
331#include "hal_icu.h"
332#include "hal_mac.h"
333#include "hal_pwm.h"
334#include "hal_rtc.h"
335#include "hal_serial.h"
336#include "hal_sdc.h"
337#include "hal_sio.h"
338#include "hal_spi.h"
339#include "hal_trng.h"
340#include "hal_uart.h"
341#include "hal_usb.h"
342#include "hal_wdg.h"
343#include "hal_wspi.h"
344
345/*
346 * The ST driver is a special case, it is only included if the OSAL is
347 * configured to require it.
348 */
349#if OSAL_ST_MODE != OSAL_ST_MODE_NONE
350#include "hal_st.h"
351#endif
352
353/* Complex drivers.*/
354#include "hal_mmc_spi.h"
355#include "hal_serial_usb.h"
356
357/* Community drivers.*/
358#if defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
359#if (HAL_USE_COMMUNITY == TRUE) || defined(__DOXYGEN__)
360#include "hal_community.h"
361#endif
362#endif
363
364#endif /* HAL_H */
365
366/** @} */
Compiler portability layer.
unsigned halclkpt_t
Type of a clock point identifier.
Definition hal.h:239
static bool halClockSwitchMode(const halclkcfg_t *ccp)
Switches to a different clock configuration.
Definition hal.h:296
halfreq_t hal_lld_get_clock_point(halclkpt_t clkpt)
Returns the frequency of a clock point in Hz.
Definition hal_lld.c:103
static halfreq_t halClockGetPointX(halclkpt_t clkpt)
Returns the frequency of a clock point in Hz.
Definition hal.h:278
uint32_t halfreq_t
Type of a clock point frequency in Hz.
Definition hal.h:244
bool hal_lld_clock_switch_mode(const halclkcfg_t *ccp)
Switches to a different clock configuration.
Definition hal_lld.c:87
void halInit(void)
HAL initialization.
Definition hal.c:56
ADC Driver macros and structures.
Buffered Serial Driver code.
I/O Buffers macros and structures.
CAN Driver macros and structures.
I/O channels access.
Cryptographic Driver macros and structures.
DAC Driver macros and structures.
Embedded Flash Driver macros and structures.
Data files.
Generic flash driver class header.
GPT Driver macros and structures.
I2C Driver macros and structures.
I2S Driver macros and structures.
ICU Driver macros and structures.
I/O block devices access.
PLATFORM HAL subsystem low level driver header.
MAC Driver macros and structures.
MMC over SPI driver header.
MMC/SD cards common header.
Base object.
I/O Ports Abstraction Layer macros, types and structures.
Generic persistent storage class header.
PWM Driver macros and structures.
I/O Queues macros and structures.
RTC Driver macros and structures.
SDC Driver macros and structures.
Serial Driver macros and structures.
Serial over USB Driver macros and structures.
SIO Driver macros and structures.
SPI Driver selector macros and structures.
ST Driver macros and structures.
Data streams.
TRNG Driver macros and structures.
UART Driver macros and structures.
USB Driver macros and structures.
WDG Driver macros and structures.
WSPI Driver macros and structures.
HAL configuration header.
OSAL module header.
Type of a clock configuration structure.
Definition hal_lld.h:78