FreeRTOS Task-Queue mit statischem Speicher (xQueueCreateStatic) minimales Beispiel
English
Deutsch
Siehe auch unseren vorherigen Post FreeRTOS Task-Queue minimales Beispiel, der auch Beispiele zum Senden & Empfangen mit einer Queue enthält. Der Post, den Sie gerade ansehen, handelt nur von 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++, Embedded, 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