一项任务中的传输接收

transmission reception in one task freertos

我正在开发一个 freeRTOS 项目和 SAM4S Xplained Pro。

在一个名为 every x ms 的任务中,我想:

我在想是否有办法不仅定期唤醒此任务,而且在检测到帧结束时唤醒此任务?而当这个任务被这个事件唤醒时,只会进行数据的提取,不会进行数据传输。

最好的方法是创建两个任务吗?一个用于发射,另一个用于接收。 我还没有编写任何代码,我正在寻找一些关于如何处理 FreeRTOS 和通信问题的建议,因为我是它的初学者...

您可以在流缓冲区或消息缓冲区上设置任务块(https://www.freertos.org/RTOS-stream-message-buffers.html) and have the interrupt send data to the buffer to unblock the task. Set the read timeout to the period at which you want to transmit, that way the task will unblock when either it is time to transmit again or when data has arrived. You can use https://www.freertos.org/xTaskCheckForTimeOut.html 以调整超时以考虑已经处于阻塞状态的任何时间(即,如果任务最初阻塞 100 毫秒,但数据在40ms后到达导致任务解阻塞,然后将下一个块时间调整为60ms,然后再次阻塞以弥补整个100ms)。