※This article is based on ZigBee Stack 2.51.a
OSAL为:Operating System Abstraction Layer,即操作系统抽象层,支持多任务运行,它并不是一个传统意义上的操作系统,但是实现了部分类似操作系统的功能。
OSAL概念是由TI公司在ZIGBEE协议栈引入,他的意思是”模拟操作系统”,此OS,并非一个真正的OS,而是模拟OS的一些方法为广大编程者提供一种写MCU程序的方法。当有一个事件发生的时候,OSAL负责将此事件分配给能够处理此事件的任务,然后此任务判断事件的类型,调用相应的事件处理程序进行处理。
Osal主要提供如下功能:任务注册、任务间同步互斥、中断处理、存储器分配和管理、提供定时器功能
开启定时器计时。用来周期性产生某一事件
/********************************************************************* * @fn osal_start_timerEx * * @brief * * This function is called to start a timer to expire in n mSecs. * When the timer expires, the calling task will get the specified event. * * @param uint8 taskID - task id to set timer for * @param uint16 event_id - event to be notified with * @param UNINT16 timeout_value - in milliseconds. * * @return SUCCESS, or NO_TIMER_AVAIL. */ uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint16 timeout_value )
自动加载时间点和超时值。
/********************************************************************* * @fn osal_start_reload_timer * * @brief * * This function is called to start a timer to expire in n mSecs. * When the timer expires, the calling task will get the specified event * and the timer will be reloaded with the timeout value. * * @param uint8 taskID - task id to set timer for * @param uint16 event_id - event to be notified with * @param UNINT16 timeout_value - in milliseconds. * * @return SUCCESS, or NO_TIMER_AVAIL. */ uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint16 timeout_value );
osal_start_reload_timer()函数相对于osal_start_timerEx()函数,就是多了一句
/* 装载时间重新装载值 */ newTimer->reloadTimeout = timeout_value;
コメント: