Hal's functions are mainly composed of three types, initialization functions (initialization function Calls), service access functions (Services access function Calls), and callback functions (Callback function Calls )。 Or is accustomed to look at English, feel their Chinese translation sometimes neither nondescript, misled the pro.
And look at the document definition:
Initialization Function Calls:
These function calls is used to initialize a service and/or to setup optional parameters for platform-specific data. Initialization functions is often called at the beginning stage when the device is powers up.
See, the initialization function is used primarily for initialization, and after power-up, not in the system. And look at the Zstack, the main function on the initialization of some of the functions,
int main (void)
{
...
Initialization for board related stuff such as LEDs
Hal_board_init ();
...
Initialze HAL Drivers
Haldriverinit ();
...
}//Main ()
So most of the HAL's initialization functions are called here, and the rest of the positions are not displayed with the HAL layer's function initialization, which is not listed here.
Service Access Function Calls:
These function calls can directly access hardware registers to get/set certain value of the hardware (i.e.
ADC) or control the hardware components (i.e. LED).
Mainly used to access or control the hardware, directly from the hardware to read the value of the hardware register, it seems that this is still very sharp.
Callback Function Calls:
These functions must is implemented by the application and is used to pass events that is generated by
The hardware (interrupts, counters, timers ...) or by polling mechanism (UART poll, Timer poll ...) to Upper
Layers. Data accessed through callback function parameters (such as a pointer to data) is only valid for the execution of the Ction and should not being considered valid when the function returns. If These functions execute in the context of the interrupt, it must is efficient and not perform cpu-intensive operations or use critical sections.
The third is the callback function type, and the callback function is still dealing with the system at this time. So this is a little bit more complicated. Such functions are implemented by tasks and are used to pass events. Here we do not first in-depth understanding, just understand a bit simple, follow-up about the serial port when the use of such functions, I will talk about.
Three kinds of functions of HAL layer and their functions