CubeMX FreeRTOS(cmsis os)函数API一览 (附可以在中断中调用的API)

CubeMX生成FreeRTOS工程以后,因为兼容多个RTOS的缘故,对很多函数的API做了封装,刚开始接触,不是很清楚这些API的资料在哪找,在此列出。

实际使用时,对照下面的官方的API介绍,会发现这个CMSIS RTOS的API太少了,很多FreeRTOS原来的功能,例如:获取任务栈空间剩余量,复位消息队列等等API都没有相应的说明。

因为资料少,刚开始摸索很不解,逐渐使用发现,FreeRTOS本来的API是可以直接使用的,实际开发中我也是混着用,因为CubeMX封装以后的做了一些小处理,例如一些API的中断保护版本都被CMSIS OS整合到一起了,使用时不必再区分是否在中断里,还是很方便的。

一些下面说明文档中没有的API就使用FreeRTOS本身的了。

以下所有资料来源于cmsis rtos官方说明文档,在keil5本地就有:
CMSIS os说明文档
Function Overview
函数一览:

Kernel Information and Control
    osKernelInitialize : Initialize the RTOS kernel.
    osKernelStart : Start the RTOS kernel.
    osKernelRunning : Query if the RTOS kernel is running.
    osKernelSysTick : Get RTOS kernel system timer counter.
    osKernelSysTickFrequency : RTOS kernel system timer frequency in Hz.
    osKernelSysTickMicroSec : Convert microseconds value to RTOS kernel system timer value.
Thread Management
    osThreadCreate : Start execution of a thread function.
    osThreadTerminate : Stop execution of a thread function.
    osThreadYield : Pass execution to next ready thread function.
    osThreadGetId : Get the thread identifier to reference this thread.
    osThreadSetPriority : Change the execution priority of a thread function.
    osThreadGetPriority : Obtain the current execution priority of a thread function.
Generic Wait Functions
    osDelay : Wait for a specified time.
    osWait : Wait for any event of the type Signal, Message, or Mail.(*)
Timer Management
    osTimerCreate : Define attributes of the timer callback function.
    osTimerStart : Start or restart the timer with a time value.
    osTimerStop : Stop the timer.
    osTimerDelete : Delete a timer.
Signal Events
    osSignalSet : Set signal flags of a thread.
    osSignalClear : Reset signal flags of a thread.
    osSignalWait : Suspend execution until specific signal flags are set.
Mutexes
    osMutexCreate : Define and initialize a mutex.
    osMutexWait : Obtain a mutex or Wait until it becomes available.
    osMutexRelease : Release a mutex.
    osMutexDelete : Delete a mutex.
Semaphores
    osSemaphoreCreate : Define and initialize a semaphore.
    osSemaphoreWait : Obtain a semaphore token or Wait until it becomes available.
    osSemaphoreRelease : Release a semaphore token.
    osSemaphoreDelete : Delete a semaphore.
Memory Pool
    osPoolCreate : Define and initialize a fix-size memory pool.
    osPoolAlloc : Allocate a memory block.
    osPoolCAlloc : Allocate a memory block and zero-set this block.
    osPoolFree : Return a memory block to the memory pool.
Message Queue
    osMessageCreate : Define and initialize a message queue.
    osMessagePut : Put a message into a message queue.
    osMessageGet : Get a message or suspend thread execution until message arrives.
Mail Queue
    osMailCreate : Define and initialize a mail queue with fix-size memory blocks.
    osMailAlloc : Allocate a memory block.
    osMailCAlloc : Allocate a memory block and zero-set this block.
    osMailPut : Put a memory block into a mail queue.
    osMailGet : Get a mail or suspend thread execution until mail arrives.
    osMailFree : Return a memory block to the mail queue.
RTX Specific Functions
    os_idle_demon : System thread running when no other thread is ready to run.
    os_suspend : Suspend the RTX task scheduler.
    os_resume : Resume the RTX task scheduler.
    os_tick_init : Initialize an alternative hardware timer as RTX kernel timer.
    os_tick_val : Get alternative hardware timer's current value.
    os_tick_ovf : Get alternative hardware timer's overflow flag.
    os_tick_irqack : Acknowledge alternative hardware timer interrupt.
    os_error : Called when a runtime error is detected.

The following CMSIS-RTOS functions can be called from threads and Interrupt Service Routines (ISR):
下面的函数支持在中断中调用:

osKernelRunning 查询内核是否正在运行
osSignalSet 创建信号量
osSemaphoreRelease 释放信号量令牌
osPoolAlloc, osPoolCAlloc, osPoolFree 分配一个内存池 分配且清零一个内存池 释放内存池
osMessagePut, osMessageGet 将消息放入消息队列  获取消息队列
osMailAlloc, osMailCAlloc, osMailGet, osMailPut, osMailFree 分配内存块 分配一个内存块并对这个块清零  获取邮件或挂起线程执行,直到邮件到达 将内存块放入邮件队列  将内存块返回到邮件队列
  • 3
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值