CMSIS Example - osMessageQ osMessagePut osMessageGet

时间:2023-03-08 17:13:18
 #include "cmsis_os.h"

 void Thread0( void * arg);
void Thread1( void * arg); osThreadDef( Thread0, Thread0, osPriorityNormal, );
osThreadDef( Thread1, Thread1, osPriorityAboveNormal, ); osMessageQDef(_thread0_MsgQ, );
osMessageQId thread0_MsgQ; osMessageQDef(_thread1_MsgQ, );
osMessageQId thread1_MsgQ; void Thread0( void * arg)
{
osEvent event;
while()
{
event = osMessageGet(thread0_MsgQ, osWaitForever );
if ( event.status == osOK)
osMessagePut( thread1_MsgQ, event.value.v+, osWaitForever ); osDelay( );
}
} void Thread1( void * arg)
{
osEvent event;
osMessagePut( thread0_MsgQ, , ); while()
{
event = osMessageGet(thread1_MsgQ, osWaitForever );
if ( event.status == osOK)
osMessagePut( thread0_MsgQ, event.value.v+, osWaitForever ); osDelay( );
}
} int main( void )
{
osKernelInitialize(); thread0_MsgQ = osMessageCreate( osMessageQ(_thread0_MsgQ), );
thread1_MsgQ = osMessageCreate( osMessageQ(_thread1_MsgQ), ); osThreadCreate( osThread(Thread0), (void *) );
osThreadCreate( osThread(Thread1), (void *) ); osKernelStart(); return ;
}