STM32CubeIDE在stm32開(kāi)發(fā)者起著最基礎(chǔ)的作用,在STM32CubeIDE中配置FreeRTOS中間層時(shí)需要選擇interface,其中有三個(gè)選項(xiàng):Disable、CMSIS_V1和CMSIS_V2
CMSIS定義了通用工具接口,并提供一致的設(shè)備支持,那么CMSIS_V1和CMSIS_V2有什么區(qū)別呢,該怎選擇呢?

微控制器軟件接口標(biāo)準(zhǔn)CMSIS
CMSIS ARM官方定義如下:

Cortex微控制器軟件接口標(biāo)準(zhǔn)(CMSIS)是獨(dú)立于供應(yīng)商的硬件抽象層,用于基于Arm Cortex處理器的微控制器,并且CMSIS提供了到處理器和外圍設(shè)備,實(shí)時(shí)操作系統(tǒng)以及中間件組件的接口,可以說(shuō)非常實(shí)用。
CMSIS軟件接口簡(jiǎn)化了軟件重用,減少了開(kāi)發(fā)周期,而且也不受限操作系統(tǒng)的類(lèi)型,去耦。
不同之處
-
RTOS v1使得軟件能夠在不同的實(shí)時(shí)操作系統(tǒng)下運(yùn)行(屏蔽不同RTOS提供的API的差別)
-
而RTOS v2則是拓展了RTOS v1,兼容更多的CPU架構(gòu)和實(shí)時(shí)操作系統(tǒng)。
RTOS v1創(chuàng)建任務(wù)函數(shù)如下:
/***********************ThreadManagement*****************************/
/**
*@briefCreateathreadandaddittoActiveThreadsandsetittostateREADY.
*@paramthread_defthreaddefinitionreferencedwith
efosThread.
*@paramargumentpointerthatispassedtothethreadfunctionasstartargument.
*@retvalthreadIDforreferencebyotherfunctionsorNULLincaseoferror.
*@noteMUSTREMAINUNCHANGED:osThreadCreateshallbeconsistentineveryCMSIS-RTOS.
*/
osThreadIdosThreadCreate(constosThreadDef_t*thread_def,void*argument)
{
TaskHandle_thandle;
#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,(constportCHAR*)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,(constportCHAR*)thread_def->name,
thread_def->stacksize,argument,makeFreeRtosPriority(thread_def->tpriority),
&handle)!=pdPASS){
returnNULL;
}
}
#elif(configSUPPORT_STATIC_ALLOCATION==1)
handle=xTaskCreateStatic((TaskFunction_t)thread_def->pthread,(constportCHAR*)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,(constportCHAR*)thread_def->name,
thread_def->stacksize,argument,makeFreeRtosPriority(thread_def->tpriority),
&handle)!=pdPASS){
returnNULL;
}
#endif
returnhandle;
}
RTOS v2創(chuàng)建任務(wù)函數(shù)如下:
osThreadId_tosThreadNew(osThreadFunc_tfunc,void*argument,constosThreadAttr_t*attr){
constchar*name;
uint32_tstack;
TaskHandle_thTask;
UBaseType_tprio;
int32_tmem;
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((prioosPriorityISR)||((attr->attr_bits&osThreadJoinable)==osThreadJoinable)){
return(NULL);
}
if(attr->stack_size>0U){
/*InFreeRTOSstackisnotinbytes,butinsizeof(StackType_t)whichis4onARMports.*/
/*Stacksizeshouldbetherefore4bytealignedinordertoavoiddivisioncausedsideeffects*/
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,高級(jí)功能選擇V2:
我分別選擇CMSIS_V1和CMSIS_V2編譯了兩次進(jìn)行對(duì)比,CMSIS_V2都要大一些。
審核編輯 :李倩
-
微控制器
+關(guān)注
關(guān)注
48文章
7680瀏覽量
152335 -
cpu
+關(guān)注
關(guān)注
68文章
10929瀏覽量
213448 -
CMSIS
+關(guān)注
關(guān)注
0文章
40瀏覽量
11974
原文標(biāo)題:stm32CubeIDE中CMSIS_V1和CMSIS_V2選項(xiàng)的區(qū)別
文章出處:【微信號(hào):技術(shù)讓夢(mèng)想更偉大,微信公眾號(hào):技術(shù)讓夢(mèng)想更偉大】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
AIGC和AI有什么區(qū)別
MAX44290ANT+T和MAX44290ANT+TG7有什么區(qū)別呢?
域名、IP 地址、網(wǎng)址分別是什么?有什么區(qū)別呢?

XTR300,XTR305和XTR300有什么區(qū)別呢?
移植CMSIS-NN v6.0.0版本到VisionBoard

請(qǐng)問(wèn)ESP32支持Jlink v9或CMSIS DAP調(diào)試嗎?
PDR_ON復(fù)位和NRST引腳復(fù)位,對(duì)STM32F407IG的影響有什么區(qū)別呢?
請(qǐng)問(wèn)CMSIS-RTOS怎么調(diào)試?
MSC_Application只要在任務(wù)中調(diào)用就會(huì)報(bào)錯(cuò),怎么處理?
CMSIS-RTOS V1與V2的區(qū)別是什么?
CMSIS的DSP數(shù)字信號(hào)處理函數(shù)庫(kù)應(yīng)用

英偉達(dá)AI服務(wù)器NVLink版與PCIe版有何區(qū)別?又如何選擇呢?

評(píng)論