OSAL全称为Operating System Abstration Layer,翻译为"操作系统抽象层",支持多任务的执行,但它并不是一个传统意义上的操作系统,但是实现了部分类似操作系统的功能。
在TI的mmwave_sdk中的OSAL抽象出下面几个层:
1. CycleprofilerP OSAL Porting Layer
2. DebugP OSAL porting Layer
3. HwiP OSAL Porting Layer
4. MemoryP OSAL Porting Layer
5. SemaphoreP OSAL Porting Layer
文章目录
CycleprofilerP OSAL
这个模块用于测量CPU周期的周期分析器模块
API函数介绍
CycleprofilerP_init 函数
函数原型:
void CycleprofilerP_init (void)
函数功能:
用于初始化周期分析器
CycleprofilerP_getTimeStamp 函数
函数原型:
uint32_t CycleprofilerP_getTimeStamp (void)
函数功能:
得到CPU周期计数时间戳
DebugP OSAL
这个模块用于调试使用
宏定义介绍
DebugP_ASSERT_ENABLED
#define DebugP_ASSERT_ENABLED 0
功能描述:
定义用于控制是否启用断言的功能
DebugP_LOG_ENABLED
#define DebugP_LOG_ENABLED 0
功能描述:
定义用于将日志API插入操作系统提供的日志机制中,应用程序开发人员可以根据其要求移植后端日志API
外部宏定义介绍
DebugP_assert
#define DebugP_assert(expression)
功能描述:
异常检测功能,如果表达式的计算结果为true,则API不执行任何操作。如果计算结果为false,则底层的RTOS端口实现将通过其基础处理异常
DebugP_log0
#define DebugP_log0(format)
功能描述:
0个参数的调试功能,"printf"格式字符串
DebugP_log1
#define DebugP_log1(format, p1)
功能描述:
1个参数的调试功能,"printf"格式字符串
DebugP_log2
#define DebugP_log2(format, p1, p2)
功能描述:
2个参数的调试功能,"printf"格式字符串
DebugP_log3
#define DebugP_log3(format, p1, p2, p3)
功能描述:
3个参数的调试功能,"printf"格式字符串
DebugP_log4
#define DebugP_log4(format, p1, p2, p3, p4)
功能描述:
4个参数的调试功能,"printf"格式字符串
HwiP OSAL
这个模块是硬件中断模块
API函数介绍
HwiP_clearInterrupt函数
函数原型:
void HwiP_clearInterrupt (int32_t interruptNum)
函数功能:
该函数用来清除一个中断
HwiP_create函数
函数原型:
HwiP_Handle HwiP_create (int32_t interruptNum, HwiP_Fxn hwiFxn, HwiP_Params *params)
函数功能:
该函数用来创建一个中断
HwiP_delete函数
函数原型:
HwiP_Status HwiP_delete (HwiP_Handle handle)
函数功能:
该函数用来删除一个中断
HwiP_disable函数
函数原型:
uintptr_t HwiP_disable (void)
函数功能:
该函数用于禁用中断以进入关键区域
HwiP_disableInterrupt函数
函数原型:
void HwiP_disableInterrupt (int32_t interruptNum)
函数功能:
该函数用于关闭一个中断
HwiP_enableInterrupt函数
函数原型:
void HwiP_enableInterrupt (int32_t interruptNum)
函数功能:
该函数用于开启一个中断
HwiP_Params_init 函数
函数原型:
void HwiP_Params_init (HwiP_Params *params)
函数功能:
将params结构初始化为默认值
HwiP_restore函数
函数原型:
void HwiP_restore (uintptr_t key)
函数功能:
该函数用于恢复中断以退出关键区域
MemoryP OSAL
这个模块是内存管理模块,内存管理模块允许应用程序执行内存分配和清除。这个模块提供各自的API为:Data Buffer、Control Buffer
API函数介绍
MemoryP_ctrlAlloc
函数原型:
void * MemoryP_ctrlAlloc (uint32_t size, uint8_t alignment)
函数功能:
该函数用于为控制操作分配空间
MemoryP_ctrlFree
函数原型:
void MemoryP_ctrlFree (void *ptr, uint32_t size)
函数功能:
该函数用于为控制操作释放空间
MemoryP_dataAlloc
函数原型:
void * MemoryP_dataAlloc (uint32_t size, uint8_t alignment)
函数功能:
该函数用于为数据操作分配空间
MemoryP_dataFree
函数原型:
void MemoryP_dataFree (void *ptr, uint32_t size)
函数功能:
该函数用于为数据操作释放空间
MemoryP_getStats
函数原型:
void MemoryP_getStats (MemoryP_Stats *stats)
函数功能:
该函数用于获取数据内存统计的信息
SemaphoreP OSAL
这个模块是信号量模块
API函数介绍
SemaphoreP_create
函数原型:
SemaphoreP_Handle SemaphoreP_create (uint32_t count, SemaphoreP_Params *params)
函数功能:
该函数用于创建一个信号量
SemaphoreP_delete
函数原型:
SemaphoreP_Status SemaphoreP_delete (SemaphoreP_Handle handle)
函数功能:
该函数用于删除一个信号量
SemaphoreP_Params_init
函数原型:
void SemaphoreP_Params_init (SemaphoreP_Params *params)
函数功能:
初始化参数结构体为默认值
SemaphoreP_pend
函数原型:
SemaphoreP_Status SemaphoreP_pend (SemaphoreP_Handle handle, uint32_t timeout)
函数功能:
该函数用于挂起一个信号量
SemaphoreP_post
函数原型:
SemaphoreP_Status SemaphoreP_post (SemaphoreP_Handle handle)
函数功能:
该函数用于释放一个信号量
SemaphoreP_postFromClock
函数原型:
SemaphoreP_Status SemaphoreP_postFromClock (SemaphoreP_Handle handle)
函数功能:
该函数用于释放来自ClockP的信号量
SemaphoreP_postFromISR
函数原型:
SemaphoreP_Status SemaphoreP_postFromISR (SemaphoreP_Handle handle)
函数功能:
该函数用于释放来自ISR的信号量
参考文献:
- 《mmWave SDK Module Documentation》