Three kinds of functions of HAL layer and their functions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.