zoukankan      html  css  js  c++  java
  • HAL层三类函数及其作用

           HAL的函数主要由三种,初始化函数(Initialization Function Calls)、服务访问函数(Service Access Function Calls )、以及回调函数(Callback Function Calls )。还是习惯看英文,觉得自己的中文翻译有的时候不伦不类,误导了亲们。

    且看document定义:

    Initialization Function Calls :

    These function calls are used to initialize a service and /or to setup optional parameters for platform-specific data. Initialization functions are often called at the beginning stage when the device powers up. 

    看到了吧,初始化函数主要是用于初始化,且是在上电后,而不是在系统中。且看在zstack中,main函数上电后的初始化中的一些函数吧,

    int main( void )

    {

    ...

      // Initialization for board related stuff such as LEDs

    HAL_BOARD_INIT();

    ...

      // Initialze HAL drivers

      HalDriverInit();

    ...

    } // main()

    所以HAL的初始化函数大多数在这里调用,其余的位置没有显示的用HAL层的函数初始化,这里就不一一列举。

    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).

    主要是用于访问或者控制硬件的,直接从硬件读取硬件寄存器的值,看来这个还是很犀利的。

    Callback Function Calls:

    These functions must be implemented by the application and are used to pass events that are 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) are only valid for the execution of the function and should not be considered valid when the function returns.  If these functions execute in the context of the interrupt, it must be efficient and not perform CPU-intensive operations or use critical sections. 

      第三个是回调函数类型,回调函数这个时候还是系统打交道了。所以这个就相对复杂一点。这类函数由任务来实现,并用于传递事件。在这里我们先不先深入了解,只是了解一点简单的,后续讲有关串口的时候会用到这类函数,我会再讲讲。

  • 相关阅读:
    SpringBoot连接数据库
    String、StringBuffer、StringBulider的区别和解析
    异常This application has no explicit mapping for /error
    node使用
    JS总结defer与async(一)
    前端项目搭建与知识框架
    git ssh配置总结
    JS算法
    JS数据结构
    Http与Http2与Https区别和联系
  • 原文地址:https://www.cnblogs.com/farbeyond/p/5204605.html
Copyright © 2011-2022 走看看