Также см. наш предыдущий пост Минимальный пример очереди задач FreeRTOS, в котором также есть примеры отправки и получения через очередь. Пост, который вы сейчас читаете, посвящён только xQueueCreateStatic()
freertos_xqueue_static_example.cpp
enum class MQTTTaskType : uint8_t {
SendStatus = 0,
SendInfo
};
// This struct will be inserted into the queue
struct MQTTTask {
MQTTTaskType task; // The type of work that is requested from the received
// TODO add your custom fields here if requred
};
constexpr size_t MQTT_TASK_QUEUE_LENGTH = 6;
static QueueHandle_t mqttTaskQueue;
static StaticQueue_t mqttTaskQueueStatic;
static uint8_t mqttTaskQueueStorageArea[ MQTT_TASK_QUEUE_LENGTH * sizeof(MQTTTask) ];
void setup() {
// Create task queue
mqttTaskQueue = xQueueCreateStatic( MQTT_TASK_QUEUE_LENGTH,
sizeof(MQTTTask),
mqttTaskQueueStorageArea,
&mqttTaskQueueStatic );
}freertos_xqueue_static_example.cpp
enum class MQTTTaskType : uint8_t {
SendStatus = 0,
SendInfo
};
// This struct will be inserted into the queue
struct MQTTTask {
MQTTTaskType task; // The type of work that is requested from the received
// TODO add your custom fields here if requred
};
constexpr size_t MQTT_TASK_QUEUE_LENGTH = 6;
static QueueHandle_t mqttTaskQueue;
static StaticQueue_t mqttTaskQueueStatic;
static uint8_t mqttTaskQueueStorageArea[ MQTT_TASK_QUEUE_LENGTH * sizeof(MQTTTask) ];
void setup() {
// Create task queue
mqttTaskQueue = xQueueCreateStatic( MQTT_TASK_QUEUE_LENGTH,
sizeof(MQTTTask),
mqttTaskQueueStorageArea,
&mqttTaskQueueStatic );
}
Check out similar posts by category:
C/C++ Встраиваемые системы FreeRTOS PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow