stm32cubeide在stm32开发者起着最基础的作用,在stm32cubeide中配置freertos中间层时需要选择interface,其中有三个选项:disable、cmsis_v1和cmsis_v2
cmsis定义了通用工具接口,并提供一致的设备支持,那么cmsis_v1和cmsis_v2有什么区别呢,该怎选择呢?
微控制器软件接口标准cmsis
cmsis arm官方定义如下:
cortex微控制器软件接口标准(cmsis)是独立于供应商的硬件抽象层,用于基于arm cortex处理器的微控制器,并且cmsis提供了到处理器和外围设备,实时操作系统以及中间件组件的接口,可以说非常实用。
cmsis软件接口简化了软件重用,减少了开发周期,而且也不受限操作系统的类型,去耦。
不同之处
rtos v1使得软件能够在不同的实时操作系统下运行(屏蔽不同rtos提供的api的差别)
而rtos v2则是拓展了rtos v1,兼容更多的cpu架构和实时操作系统。
rtos v1创建任务函数如下:
/*********************** thread management *****************************//*** @brief create a thread and add it to active threads and set it to state ready.* @param thread_def thread definition referenced with ef osthread.* @param argument pointer that is passed to the thread function as start argument.* @retval thread id for reference by other functions or null in case of error.* @note must remain unchanged: osthreadcreate shall be consistent in every cmsis-rtos.*/osthreadid osthreadcreate (const osthreaddef_t *thread_def, void *argument){ taskhandle_t handle; #if( configsupport_static_allocation == 1 ) && ( configsupport_dynamic_allocation == 1 ) if((thread_def->buffer != null) && (thread_def->controlblock != null)) { handle = xtaskcreatestatic((taskfunction_t)thread_def->pthread,(const portchar *)thread_def->name, thread_def->stacksize, argument, makefreertospriority(thread_def->tpriority), thread_def->buffer, thread_def->controlblock); } else { if (xtaskcreate((taskfunction_t)thread_def->pthread,(const portchar *)thread_def->name, thread_def->stacksize, argument, makefreertospriority(thread_def->tpriority), &handle) != pdpass) { return null; } }#elif( configsupport_static_allocation == 1 ) handle = xtaskcreatestatic((taskfunction_t)thread_def->pthread,(const portchar *)thread_def->name, thread_def->stacksize, argument, makefreertospriority(thread_def->tpriority), thread_def->buffer, thread_def->controlblock);#else if (xtaskcreate((taskfunction_t)thread_def->pthread,(const portchar *)thread_def->name, thread_def->stacksize, argument, makefreertospriority(thread_def->tpriority), &handle) != pdpass) { return null; } #endif return handle;}
rtos v2创建任务函数如下:
osthreadid_t osthreadnew (osthreadfunc_t func, void *argument, const osthreadattr_t *attr) { const char *name; uint32_t stack; taskhandle_t htask; ubasetype_t prio; int32_t mem; htask = null; if (!is_irq() && (func != null)) { stack = configminimal_stack_size; prio = (ubasetype_t)osprioritynormal; name = null; mem = -1; if (attr != null) { if (attr->name != null) { name = attr->name; } if (attr->priority != osprioritynone) { prio = (ubasetype_t)attr->priority; } if ((prio ospriorityisr) || ((attr->attr_bits & osthreadjoinable) == osthreadjoinable)) { return (null); } if (attr->stack_size > 0u) { /* in freertos stack is not in bytes, but in sizeof(stacktype_t) which is 4 on arm ports. */ /* stack size should be therefore 4 byte aligned in order to avoid division caused side effects */ stack = attr->stack_size / sizeof(stacktype_t); } if ((attr->cb_mem != null) && (attr->cb_size >= sizeof(statictask_t)) && (attr->stack_mem != null) && (attr->stack_size > 0u)) { mem = 1; } else { if ((attr->cb_mem == null) && (attr->cb_size == 0u) && (attr->stack_mem == null)) { mem = 0; } } } else { mem = 0; } if (mem == 1) { #if (configsupport_static_allocation == 1) htask = xtaskcreatestatic ((taskfunction_t)func, name, stack, argument, prio, (stacktype_t *)attr->stack_mem, (statictask_t *)attr->cb_mem); #endif } else { if (mem == 0) { #if (configsupport_dynamic_allocation == 1) if (xtaskcreate ((taskfunction_t)func, name, (uint16_t)stack, argument, prio, &htask) != pdpass) { htask = null; } #endif } } } return ((osthreadid_t)htask);}
正常v1够用了,普通功能选v1,高级功能选择v2:
我分别选择cmsis_v1和cmsis_v2编译了两次进行对比,cmsis_v2都要大一些。
面对激烈的市场竞争,欣迪盟及时调整了企业的发展策略
iPhone7 Plus如何进行拆机
基于FPGA的模数转换器的设计
一文看懂交流发电机的工作原理
Microchip推出GridTime™ 3000 GNSS时间服务器
CMSIS_V1和CMSIS_V2有什么区别呢?该怎么选择呢?
关于镀铜表面粗糙问题原因分析
硅谷半导体业,恢复往日的繁荣
至简设计法:运算符(3)
3nm/5nm Intel CPU有望近期量产
智能手机系统:OPhone = Android+公式解析
【新品推介】AIM为EADIN数据总线通信提供解决方案
推动无人机智能教育,全方面培养学生的AI素养
系统射频接口ADS仿真电路原理图及参数设定详细讲解
深交所制定并发布了工业机器人、集成电路等4个行业信息披露指引
人脸识别访客系统应用场景有哪些
基于MP2672评估板的锂电池升压充电器方案
视频监控系统的工作原理及应用
D类功放喇叭功率测量以及功率调节
AIM Systems无损无接触式涂层测量设备的工作原理