M4和M7雙核之間消息通信
概述
基本原理
![M4和M7雙核之間消息通信,第2張 M4和M7雙核之間消息通信,圖片,第2張](/img.php?pic=http://image109.360doc.com/DownloadImg/2022/11/1103/255635208_2_20221111031254742.png)
單消息代碼描述
xMessageBufferSend()
{
if( time out!=0)
{
while( there is insufficient space inthebuffer&&
not timed out waiting )
{
Enter the blocked state to wait forspacein the buffer
}
}
if( there is enough space in the buffer )
{
writedata to buffer
sbSEND_COMPLETED()
}
}
xMessageBufferReceive()
{
if( time out!=0)
{
while( there isnodatain the buffer &&
not timed out waiting )
{
Enter the blocked state to wait fordata
}
}
if( there isdatain the buffer )
{
readdata from buffer
sbRECEIVE_COMPLETED()
}
}
![M4和M7雙核之間消息通信,第3張 M4和M7雙核之間消息通信,圖片,第3張](/img.php?pic=http://image109.360doc.com/DownloadImg/2022/11/1103/255635208_3_20221111031254914.png)
多消息代碼描述
如果硬件允許,則每個消息緩沖區可以使用不同的中斷線,從而使中斷服務程序和消息緩沖區之間保持一對一的映射。 中斷服務例程可以簡單地查詢每個消息緩沖區以查看其是否包含數據。 可以通過傳遞元數據(消息是什麽,消息的預期接收者是什麽等等)以及實際數據的單個消息緩沖區來代替多個消息緩沖區。
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreToCoreInterrupt( pxStreamBuffer )
voidvGenerateCoreToCoreInterrupt( MessageBufferHandle_t xUpdatedBuffer )
{
size_tBytesWritten.
if( xUpdatedBuffer != xControlMessageBuffer )
{
BytesWritten = xMessageBufferSend( xControlMessageBuffer,
&xUpdatedBuffer,
sizeof( xUpdatedBuffer ),
0);
configASSERT( BytesWritten == sizeof( xUpdatedBuffer );
GenerateInterrupt();
}
}
voidInterruptServiceRoutine(void)
{
MessageBufferHandle_t xUpdatedMessageBuffer;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
while( xMessageBufferReceiveFromISR( xControlMessageBuffer,
&xUpdatedMessageBuffer,
sizeof( xUpdatedMessageBuffer ),
&xHigherPriorityTaskWoken )
==sizeof( xUpdatedMessageBuffer ) )
{
xMessageBufferSendCompletedFromISR( xUpdatedMessageBuffer,
&xHigherPriorityTaskWoken );
}
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
![M4和M7雙核之間消息通信,第4張 M4和M7雙核之間消息通信,圖片,第4張](/img.php?pic=http://image109.360doc.com/DownloadImg/2022/11/1103/255635208_4_2022111103125555.png)
![M4和M7雙核之間消息通信,第5張 M4和M7雙核之間消息通信,圖片,第5張](/img.php?pic=http://image109.360doc.com/DownloadImg/2022/11/1103/255635208_5_20221111031255195.gif)
0條評論