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. 

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

  • 相关阅读:
    揭示同步块索引(下):总结
    关于.NET技术体系的思维导图
    嵌入式Linux中摄像头使用简要整理
    Tslib和Qt 4.8.4与在开发板上的移植
    图像处理经典图片Lena背后的故事
    Linux 下编译安装OpenCV
    Linux 下编译、安装、配置 QT
    Qt Creator的配置和开发初步测试
    OpenCV的第一个小程序:读取图像并显示
    转:智能手机Flash/DRAM选择、配置与价格大全
  • 原文地址:https://www.cnblogs.com/farbeyond/p/5204605.html
Copyright © 2011-2022 走看看