#author("2022-07-09T15:56:50+08:00","default:Admin","Admin")
#author("2022-11-15T13:36:33+08:00","default:Admin","Admin")
[[+TI+CC2530]]

&color(red){※This article is based on ZigBee Stack 2.51.a};

#contents

* 概要 [#aa1d408f]

OSAL为:Operating System Abstraction Layer,即操作系统抽象层,支持多任务运行,它并不是一个传统意义上的操作系统,但是实现了部分类似操作系统的功能。

OSAL概念是由TI公司在ZIGBEE协议栈引入,他的意思是”模拟操作系统”,此OS,并非一个真正的OS,而是模拟OS的一些方法为广大编程者提供一种写MCU程序的方法。当有一个事件发生的时候,OSAL负责将此事件分配给能够处理此事件的任务,然后此任务判断事件的类型,调用相应的事件处理程序进行处理。


#codeprettify{{
Osal主要提供如下功能:任务注册、任务间同步互斥、中断处理、存储器分配和管理、提供定时器功能
}}

* 常用API [#s19b25da]

** osal_start_timerEx() [#p278f854]

开启定时器计时。用来周期性产生某一事件

#codeprettify{{
/*********************************************************************
 * @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 )
}}
** osal_start_reload_timer() [#e6713ff6]

自动加载时间点和超时值。

#codeprettify{{
/*********************************************************************
 * @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()函数,就是多了一句

#codeprettify{{
 /*   装载时间重新装载值     */
 newTimer->reloadTimeout = timeout_value;
}}

** osal_clear_event [#q3e64762]

清除事件。

#codeprettify{{
uint8 osal_clear_event( uint8 task_id, uint16 event_flag );
}}

#hr();
コメント:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS