Tactility/TactilityC/Source/tt_message_queue.h
Ken Van Hoeylandt 3ea02d912f
Merge develop into main (#167)
- WiFi Connect app is now hidden by default, but accessible at the bottom of the WiFi Manage app when WiFi is turned on.
- WiFi service now turns on WiFi when calling connect() and WiFi is not on.
- Removed `blocking` option for `service::loader::startApp()`. This feature was unused and complex.
- Various apps: Moved private headers into Private/ folder.
- Various apps: created start() function for easy starting.
- Added documentation to all TactilityC APIs
- Refactored various `enum` into `class enum`
- Refactor M5Stack `initBoot()` (but VBus is still 0V for some reason)
2025-01-17 19:37:42 +01:00

63 lines
2.0 KiB
C

#pragma once
#include <freertos/FreeRTOS.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
/** A handle that represents a message queue instance */
typedef void* MessageQueueHandle;
/**
* Allocate a new message queue in memory.
* @param[in] capacity how many messages this queue can contain before it starts blocking input
* @param[in] messageSize the size of a message
*/
MessageQueueHandle tt_message_queue_alloc(uint32_t capacity, uint32_t messageSize);
/** Free up the memory of a queue (dealloc) */
void tt_message_queue_free(MessageQueueHandle handle);
/**
* Put (post) a message in the queue
* @param[in] handle the queue handle
* @param[in] message the message of the correct size - its data will be copied
* @param[timeout] timeout the amount of ticks to wait until the message is queued
* @return true if the item was successfully queued
*/
bool tt_message_queue_put(MessageQueueHandle handle, const void* message, TickType_t timeout);
/**
* Get the oldest message from the queue.
* @param[in] handle the queue handle
* @param[out] message a pointer to a message of the correct size
* @param[in] timeout the amount of ticks to wait until a message was copied
* @return true if a message was successfully copied
*/
bool tt_message_queue_get(MessageQueueHandle handle, void* message, TickType_t timeout);
/** @return the total amount of messages that this queue can hold */
uint32_t tt_message_queue_get_capacity(MessageQueueHandle handle);
/** @return the size of a single message in the queue */
uint32_t tt_message_queue_get_message_size(MessageQueueHandle handle);
/** @return the current amount of items in the queue */
uint32_t tt_message_queue_get_count(MessageQueueHandle handle);
/** @return the remaining capacity in the queue */
uint32_t tt_message_queue_get_space(MessageQueueHandle handle);
/**
* Remove all items from the queue (if any)
* @return true on failure
*/
bool tt_message_queue_reset(MessageQueueHandle handle);
#ifdef __cplusplus
}
#endif