又想了想,觉得有些头绪了。
之前问题纠结到了,使用CMSIS_OS API创建消息队列,消息队列单元的大小仅仅是4字节。而直接使用FreeRTOS的API创建消息队列,可以将消息队列的单元大小设置成任意,也就是说,消息队列中可以直接传递一些复杂些的结构体、数组什么的。本以为CMSIS_OS会限制FreeRTOS消息队列传递复杂的数据结构。现在想想,并不用担心这样的问题。
CMSIS-RTOS的说明文档中这样描述:
Message Queue Management functions allow to control, send, receive, or wait for messages. A message can be an integer or pointer value that is send to a thread or interrupt service routine.
Returnsmessage queue ID for reference by other functions or NULL in case of error.NoteMUST REMAIN UNCHANGED: osMessageCreate shall be consistent in every CMSIS-RTOS.
osThreadId tid_thread1; // ID for thread 1 osThreadId tid_thread2; // for thread 2
typedef struct { // Message object structure
float voltage; // AD result of measured voltage
float current; // AD result of measured current
int counter; // A counter value
} T_MEAS;