HAL Common How to Use

group HAL_How_To_Use

How to use the HAL module driver

The HAL module (also called HAL generic) can be used as follows:

This module provides 4 sets of APIs that allows to:

  1. Initialize and De-Initialize the HAL module:

    • To initialize the HAL module, use the HAL_Init() function to:

      • Make device ready for other HAL modules operation. It configures:

        • HAL time base with default parameters: HAL tick from SysTick, interrupt enable, period 1ms

        • System generic features (NVIC priority grouping configuration, …)

    • To de-initiliaze the HAL module,use the HAL_DeInit() can be called (optional) to revert HAL configuration.

    • The HAL_InitTick() function is called by HAL_Init() with HAL default parameters and by HAL RCC when system clock is updated. User can call it from application with different parameters. User can override it (function declared as __WEAK) to use HAL tick with different clock source (timer, RTC, …)

  2. Manage the HAL tick: Several APIs are available to manage the HAL tick:

    • Increment and get the uwTick global variable value:

      • This functionality is provided by HAL_IncTick() function.

      • This function is declared as __WEAK to be overridden in case of other implementations in user file.

    • Get the tick interrupttion priority and frequency:

    • Provide a delay in milliseconds:

      • This functionality is provided by HAL_Delay() function.

      • This function is declared as __WEAK to be overridden in case of other implementations in user file.

    • Suspend and resume the tick incrementation:

  3. Get the HAL driver version:

  4. Get the device identification data: