STM32CubeIDE在stm32開發(fā)者起著最基礎(chǔ)的作用,在STM32CubeIDE中配置FreeRTOS中間層時需要選擇interface,其中有三個選項: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)是獨立于供應(yīng)商的硬件抽象層,用于基于Arm Cortex處理器的微控制器,并且CMSIS提供了到處理器和外圍設(shè)備,實時操作系統(tǒng)以及中間件組件的接口,可以說非常實用。
CMSIS軟件接口簡化了軟件重用,減少了開發(fā)周期,而且也不受限操作系統(tǒng)的類型,去耦。
不同之處
RTOS v1使得軟件能夠在不同的實時操作系統(tǒng)下運行(屏蔽不同RTOS提供的API的差別)
而RTOS v2則是拓展了RTOS v1,兼容更多的CPU架構(gòu)和實時操作系統(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,高級功能選擇V2:
我分別選擇CMSIS_V1和CMSIS_V2編譯了兩次進行對比,CMSIS_V2都要大一些。
審核編輯:劉清
-
微控制器
+關(guān)注
關(guān)注
48文章
7651瀏覽量
152124 -
處理器
+關(guān)注
關(guān)注
68文章
19409瀏覽量
231207 -
CMSIS
+關(guān)注
關(guān)注
0文章
40瀏覽量
11943 -
stm32cubemx
+關(guān)注
關(guān)注
5文章
284瀏覽量
15007
發(fā)布評論請先 登錄
相關(guān)推薦
想選一個10或12bit的ADC,有哪些ADC可以選擇呢?SPS該如何計算呢?
MAX44290ANT+T和MAX44290ANT+TG7有什么區(qū)別呢?
域名、IP 地址、網(wǎng)址分別是什么?有什么區(qū)別呢?
![域名、IP 地址、網(wǎng)址分別是什么?<b class='flag-5'>有</b><b class='flag-5'>什么區(qū)別</b><b class='flag-5'>呢</b>?](https://file1.elecfans.com/web2/M00/06/B9/wKgZombqQ9OAav1FAAElWjHcO-A799.png)
XTR300,XTR305和XTR300有什么區(qū)別呢?
移植CMSIS-NN v6.0.0版本到VisionBoard
![移植<b class='flag-5'>CMSIS</b>-NN <b class='flag-5'>v</b>6.0.0版本到VisionBoard](https://file1.elecfans.com/web2/M00/C4/8A/wKgZomX0EhWACv8DAAAUet8ikhs451.png)
請問ESP32支持Jlink v9或CMSIS DAP調(diào)試嗎?
PDR_ON復(fù)位和NRST引腳復(fù)位,對STM32F407IG的影響有什么區(qū)別呢?
請問CMSIS-RTOS怎么調(diào)試?
MSC_Application只要在任務(wù)中調(diào)用就會報錯,怎么處理?
CMSIS-RTOS V1與V2的區(qū)別是什么?
CMSIS的DSP數(shù)字信號處理函數(shù)庫應(yīng)用
![<b class='flag-5'>CMSIS</b>的DSP數(shù)字信號處理函數(shù)庫應(yīng)用](https://file1.elecfans.com/web2/M00/C6/89/wKgaomYA57SAWp1AAABXjOBcrGk842.png)
英偉達AI服務(wù)器NVLink版與PCIe版有何區(qū)別?又如何選擇呢?
![英偉達AI服務(wù)器NVLink版與PCIe版<b class='flag-5'>有</b>何<b class='flag-5'>區(qū)別</b>?又如何<b class='flag-5'>選擇</b><b class='flag-5'>呢</b>?](https://file1.elecfans.com/web2/M00/C4/F1/wKgZomX5BQCAAGCPAAaUZ9psNS4086.jpg)
評論