ChibiOS/HAL 9.0.0
HAL Driver

Hardware Abstraction Layer. More...

Detailed Description

Hardware Abstraction Layer.

The HAL (Hardware Abstraction Layer) driver performs the system initialization and includes the platform support code shared by the other drivers. This driver does contain any API function except for a general initialization function halInit() that must be invoked before any HAL service can be used, usually the HAL initialization should be performed immediately before the kernel initialization.
Some HAL driver implementations also offer a custom early clock setup function that can be invoked before the C runtime initialization in order to accelerate the startup time.

Collaboration diagram for HAL Driver:

ChibiOS/HAL version identification

#define CH_HAL_VERSION   "9.0.0"
 HAL version string.
#define CH_HAL_MAJOR   9
 HAL version major number.
#define CH_HAL_MINOR   0
 HAL version minor number.
#define CH_HAL_PATCH   0
 HAL version patch number.

Return codes

#define HAL_SUCCESS   false
 HAL operation success.
#define HAL_FAILED   true
 HAL operation failed.

Return codes for HAL functions

#define HAL_RET_SUCCESS   MSG_OK
#define HAL_RET_CONFIG_ERROR   (msg_t)-16
 Configuration error.
#define HAL_RET_NO_RESOURCE   (msg_t)-17
 A required resource is not available.
#define HAL_RET_HW_BUSY   (msg_t)-18
 The peripheral is busy.
#define HAL_RET_HW_FAILURE   (msg_t)-19
 Peripheral failure.
#define HAL_RET_UNKNOWN_CTL   (msg_t)-20
 Unknown control code.
#define HAL_RET_IS_INVALID   (msg_t)-21
 Invalid instance pointer.

Platform identification macros

#define PLATFORM_NAME   "templates"

Data Structures

struct  halclkcfg_t
 Type of a clock configuration structure. More...

Macros

#define __CHIBIOS_HAL__
 ChibiOS/HAL identification macro.
#define CH_HAL_STABLE   1
 Stable release flag.
#define HAL_USE_PAL   FALSE
#define HAL_USE_ADC   FALSE
#define HAL_USE_CAN   FALSE
#define HAL_USE_CRY   FALSE
#define HAL_USE_DAC   FALSE
#define HAL_USE_EFL   FALSE
#define HAL_USE_GPT   FALSE
#define HAL_USE_I2C   FALSE
#define HAL_USE_I2S   FALSE
#define HAL_USE_ICU   FALSE
#define HAL_USE_MAC   FALSE
#define HAL_USE_PWM   FALSE
#define HAL_USE_RTC   FALSE
#define HAL_USE_SERIAL   FALSE
#define HAL_USE_SDC   FALSE
#define HAL_USE_SIO   FALSE
#define HAL_USE_SPI   FALSE
#define HAL_USE_TRNG   FALSE
#define HAL_USE_UART   FALSE
#define HAL_USE_USB   FALSE
#define HAL_USE_WDG   FALSE
#define HAL_USE_WSPI   FALSE
#define HAL_LLD_SELECT_SPI_V2   TRUE
 Requires use of SPIv2 driver model.
#define HAL_LLD_USE_CLOCK_MANAGEMENT
 Specifies implementation of dynamic clock management.

Typedefs

typedef unsigned halclkpt_t
 Type of a clock point identifier.
typedef uint32_t halfreq_t
 Type of a clock point frequency in Hz.

Functions

void halInit (void)
 HAL initialization.
static halfreq_t halClockGetPointX (halclkpt_t clkpt)
 Returns the frequency of a clock point in Hz.
static bool halClockSwitchMode (const halclkcfg_t *ccp)
 Switches to a different clock configuration.
void hal_lld_init (void)
 Low level HAL driver initialization.
bool hal_lld_clock_switch_mode (const halclkcfg_t *ccp)
 Switches to a different clock configuration.
halfreq_t hal_lld_get_clock_point (halclkpt_t clkpt)
 Returns the frequency of a clock point in Hz.

Macro Definition Documentation

◆ __CHIBIOS_HAL__

#define __CHIBIOS_HAL__

ChibiOS/HAL identification macro.

Definition at line 41 of file hal.h.

◆ CH_HAL_STABLE

#define CH_HAL_STABLE   1

Stable release flag.

Definition at line 46 of file hal.h.

◆ CH_HAL_VERSION

#define CH_HAL_VERSION   "9.0.0"

HAL version string.

Definition at line 55 of file hal.h.

◆ CH_HAL_MAJOR

#define CH_HAL_MAJOR   9

HAL version major number.

Definition at line 60 of file hal.h.

◆ CH_HAL_MINOR

#define CH_HAL_MINOR   0

HAL version minor number.

Definition at line 65 of file hal.h.

◆ CH_HAL_PATCH

#define CH_HAL_PATCH   0

HAL version patch number.

Definition at line 70 of file hal.h.

◆ HAL_SUCCESS

◆ HAL_FAILED

◆ HAL_RET_SUCCESS

◆ HAL_RET_CONFIG_ERROR

#define HAL_RET_CONFIG_ERROR   (msg_t)-16

Configuration error.

An error has been detected in the driver configuration structure.

Definition at line 98 of file hal.h.

◆ HAL_RET_NO_RESOURCE

#define HAL_RET_NO_RESOURCE   (msg_t)-17

A required resource is not available.

One of the resources required for driver operations is not available.

Definition at line 104 of file hal.h.

◆ HAL_RET_HW_BUSY

#define HAL_RET_HW_BUSY   (msg_t)-18

The peripheral is busy.

The peripheral is not available or taken by some other system actor.

Definition at line 110 of file hal.h.

◆ HAL_RET_HW_FAILURE

#define HAL_RET_HW_FAILURE   (msg_t)-19

Peripheral failure.

Peripheral failed, for example HW timeouts.

Definition at line 115 of file hal.h.

◆ HAL_RET_UNKNOWN_CTL

#define HAL_RET_UNKNOWN_CTL   (msg_t)-20

Unknown control code.

Definition at line 119 of file hal.h.

Referenced by __buffered_serial_ctl_impl(), __ctl(), and _ctl().

◆ HAL_RET_IS_INVALID

#define HAL_RET_IS_INVALID   (msg_t)-21

Invalid instance pointer.

Definition at line 123 of file hal.h.

Referenced by sio_lld_start(), and spi_lld_start().

◆ HAL_USE_PAL

#define HAL_USE_PAL   FALSE

Definition at line 145 of file hal.h.

◆ HAL_USE_ADC

#define HAL_USE_ADC   FALSE

Definition at line 149 of file hal.h.

◆ HAL_USE_CAN

#define HAL_USE_CAN   FALSE

Definition at line 153 of file hal.h.

◆ HAL_USE_CRY

#define HAL_USE_CRY   FALSE

Definition at line 157 of file hal.h.

◆ HAL_USE_DAC

#define HAL_USE_DAC   FALSE

Definition at line 161 of file hal.h.

◆ HAL_USE_EFL

#define HAL_USE_EFL   FALSE

Definition at line 165 of file hal.h.

◆ HAL_USE_GPT

#define HAL_USE_GPT   FALSE

Definition at line 169 of file hal.h.

◆ HAL_USE_I2C

#define HAL_USE_I2C   FALSE

Definition at line 173 of file hal.h.

◆ HAL_USE_I2S

#define HAL_USE_I2S   FALSE

Definition at line 177 of file hal.h.

◆ HAL_USE_ICU

#define HAL_USE_ICU   FALSE

Definition at line 181 of file hal.h.

◆ HAL_USE_MAC

#define HAL_USE_MAC   FALSE

Definition at line 185 of file hal.h.

◆ HAL_USE_PWM

#define HAL_USE_PWM   FALSE

Definition at line 189 of file hal.h.

◆ HAL_USE_RTC

#define HAL_USE_RTC   FALSE

Definition at line 193 of file hal.h.

◆ HAL_USE_SERIAL

#define HAL_USE_SERIAL   FALSE

Definition at line 197 of file hal.h.

◆ HAL_USE_SDC

#define HAL_USE_SDC   FALSE

Definition at line 201 of file hal.h.

◆ HAL_USE_SIO

#define HAL_USE_SIO   FALSE

Definition at line 205 of file hal.h.

◆ HAL_USE_SPI

#define HAL_USE_SPI   FALSE

Definition at line 209 of file hal.h.

◆ HAL_USE_TRNG

#define HAL_USE_TRNG   FALSE

Definition at line 213 of file hal.h.

◆ HAL_USE_UART

#define HAL_USE_UART   FALSE

Definition at line 217 of file hal.h.

◆ HAL_USE_USB

#define HAL_USE_USB   FALSE

Definition at line 221 of file hal.h.

◆ HAL_USE_WDG

#define HAL_USE_WDG   FALSE

Definition at line 225 of file hal.h.

◆ HAL_USE_WSPI

#define HAL_USE_WSPI   FALSE

Definition at line 229 of file hal.h.

◆ HAL_LLD_SELECT_SPI_V2

#define HAL_LLD_SELECT_SPI_V2   TRUE

Requires use of SPIv2 driver model.

Definition at line 35 of file hal_lld.h.

◆ HAL_LLD_USE_CLOCK_MANAGEMENT

#define HAL_LLD_USE_CLOCK_MANAGEMENT

Specifies implementation of dynamic clock management.

Definition at line 40 of file hal_lld.h.

◆ PLATFORM_NAME

#define PLATFORM_NAME   "templates"

Definition at line 46 of file hal_lld.h.

Typedef Documentation

◆ halclkpt_t

typedef unsigned halclkpt_t

Type of a clock point identifier.

Definition at line 239 of file hal.h.

◆ halfreq_t

typedef uint32_t halfreq_t

Type of a clock point frequency in Hz.

Definition at line 244 of file hal.h.

Function Documentation

◆ halInit()

void halInit ( void )

HAL initialization.

This function invokes the low level initialization code then initializes all the drivers enabled in the HAL. Finally the board-specific initialization is performed by invoking boardInit() (usually defined in board.c).

Function Class:
Object or module nitializer function.

Definition at line 56 of file hal.c.

References adcInit(), canInit(), cryInit(), dacInit(), eflInit(), gptInit(), hal_lld_init(), i2cInit(), i2sInit(), icuInit(), macInit(), mmcInit(), osalInit(), palInit, pwmInit(), rtcInit(), sdcInit(), sdInit(), sduInit(), sioInit(), spiInit(), stInit(), trngInit(), uartInit(), usbInit(), wdgInit(), and wspiInit().

Here is the call graph for this function:

◆ halClockGetPointX()

halfreq_t halClockGetPointX ( halclkpt_t clkpt)
inlinestatic

Returns the frequency of a clock point in Hz.

Parameters
[in]clkptclock point to be returned
Returns
The clock point frequency in Hz or zero if the frequency is unknown.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 278 of file hal.h.

References hal_lld_get_clock_point().

Here is the call graph for this function:

◆ halClockSwitchMode()

bool halClockSwitchMode ( const halclkcfg_t * ccp)
inlinestatic

Switches to a different clock configuration.

Parameters
[in]ccppointer to clock a halclkcfg_t structure
Returns
The clock switch result.
Return values
falseif the clock switch succeeded
trueif the clock switch failed
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 296 of file hal.h.

References hal_lld_clock_switch_mode().

Here is the call graph for this function:

◆ hal_lld_init()

void hal_lld_init ( void )

Low level HAL driver initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 72 of file hal_lld.c.

Referenced by halInit().

◆ hal_lld_clock_switch_mode()

bool hal_lld_clock_switch_mode ( const halclkcfg_t * ccp)

Switches to a different clock configuration.

Parameters
[in]ccppointer to clock a halclkcfg_t structure
Returns
The clock switch result.
Return values
falseif the clock switch succeeded
trueif the clock switch failed
Function Class:
Not an API, this function is for internal use only.

Definition at line 87 of file hal_lld.c.

Referenced by halClockSwitchMode().

◆ hal_lld_get_clock_point()

halfreq_t hal_lld_get_clock_point ( halclkpt_t clkpt)

Returns the frequency of a clock point in Hz.

Parameters
[in]clkptclock point to be returned
Returns
The clock point frequency in Hz or zero if the frequency is unknown.
Function Class:
Not an API, this function is for internal use only.

Definition at line 103 of file hal_lld.c.

Referenced by halClockGetPointX().