bolar_2 backup

This commit is contained in:
2026-11-27 16:38:11 +08:00
commit e96d6d19df
305 changed files with 43350 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
#pragma once
#include "core/app_event.h"
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include <cstddef>
#include <cstdint>
namespace borla {
class AppEventQueue {
public:
static constexpr size_t kCapacity = 32;
AppEventQueue()
{
queue_ = xQueueCreateStatic(
kCapacity,
sizeof(AppEvent),
storage_,
&queue_storage_);
}
bool Publish(const AppEvent& event, TickType_t wait_ticks = 0)
{
return xQueueSend(queue_, &event, wait_ticks) == pdTRUE;
}
bool PublishFromIsr(const AppEvent& event, BaseType_t* higher_priority_woken)
{
return xQueueSendFromISR(queue_, &event, higher_priority_woken) == pdTRUE;
}
bool Receive(AppEvent* event, TickType_t wait_ticks = portMAX_DELAY)
{
return xQueueReceive(queue_, event, wait_ticks) == pdTRUE;
}
size_t Pending() const
{
return static_cast<size_t>(uxQueueMessagesWaiting(queue_));
}
private:
StaticQueue_t queue_storage_{};
alignas(AppEvent) uint8_t storage_[kCapacity * sizeof(AppEvent)]{};
QueueHandle_t queue_ = nullptr;
};
} // namespace borla