欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

FreeRTOS軟件定時(shí)器apollo中斷狀態(tài)判斷

 更新時(shí)間:2022年04月07日 16:35:25   作者:jiang_2018  
這篇文章主要為大家介紹了FreeRTOS軟件定時(shí)器apollo中斷狀態(tài)的判斷,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步早日升職加薪

問題場(chǎng)景

開發(fā)中發(fā)現(xiàn)FreeRTOS軟件定時(shí)器不走了,具體表現(xiàn)在軟件定時(shí)器中斷進(jìn)不去。

分析問題

觀察發(fā)現(xiàn)只有在某個(gè)任務(wù)執(zhí)行期間,F(xiàn)reeRTOS的軟件定時(shí)器才會(huì)不走,其他任務(wù)執(zhí)行時(shí)正常,排查后是此任務(wù)的優(yōu)先級(jí)比定時(shí)器任務(wù)高,且占用時(shí)間比較長(zhǎng),導(dǎo)致任務(wù)切不出去。

解決問題

在FreeRTOSConfig.h中修改定時(shí)器任務(wù)優(yōu)先級(jí)為最高解決問題

apollo中斷狀態(tài)判斷

在看apollo3 代碼時(shí)發(fā)現(xiàn)下面這個(gè)函數(shù)

void WsfSetOsSpecificEvent(void)
{
  if(xRadioTaskEventObject != NULL) 
  {
      BaseType_t xHigherPriorityTaskWoken, xResult;
      if(xPortIsInsideInterrupt() == pdTRUE) {
          // Send an event to the main radio task
          xHigherPriorityTaskWoken = pdFALSE;
          xResult = xEventGroupSetBitsFromISR(xRadioTaskEventObject, 1,
                                              &xHigherPriorityTaskWoken);
          // If the radio task is higher-priority than the context we're currently
          // running from, we should yield now and run the radio task.
          //
          if ( xResult != pdFAIL )
          {
              portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
          }    
      }
      else {
          xResult = xEventGroupSetBits(xRadioTaskEventObject, 1);
          //
          // If the radio task is higher priority than the context we're currently
          // running from, we should yield now and run the radio task.
          //
          if ( xResult != pdFAIL )
          {
              portYIELD();
          }
      }

  }    
}

這是FreeRTOS發(fā)送一個(gè)事件標(biāo)志組,xPortIsInsideInterrupt這個(gè)函數(shù)判斷是否在中斷中,進(jìn)而調(diào)用判斷是否調(diào)用FromISR結(jié)尾的api,下面看下原理

static portFORCE_INLINE BaseType_t xPortIsInsideInterrupt( void )
{
uint32_t ulCurrentInterrupt;
BaseType_t xReturn;
	/* Obtain the number of the currently executing interrupt. */
	__asm
	{
		mrs ulCurrentInterrupt, ipsr
	}
	if( ulCurrentInterrupt == 0 )
	{
		xReturn = pdFALSE;
	}
	else
	{
		xReturn = pdTRUE;
	}
	return xReturn;
}

讀IPSR寄存器,0表示當(dāng)前沒有中斷在運(yùn)行,非0表示正在運(yùn)行的中斷號(hào),即處于中斷中,所以要用FromISR結(jié)尾的api

以上就是FreeRTOS軟件定時(shí)器apollo中斷狀態(tài)判斷的詳細(xì)內(nèi)容,更多關(guān)于FreeRTOS定時(shí)器apollo中斷判斷的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論