ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
freertos_queue.hpp
Go to the documentation of this file.
1
5#ifndef ELEC_C7222_UTILS_FREERTOS_QUEUE_HPP
6#define ELEC_C7222_UTILS_FREERTOS_QUEUE_HPP
7
8#include <cstddef>
9#include <cstdint>
10
11#include "non_copyable.hpp"
12
13namespace c7222 {
14
37 public:
39 FreeRtosQueue() = default;
45 FreeRtosQueue(std::size_t length, std::size_t item_size);
52 bool Initialize(std::size_t length, std::size_t item_size);
55
62 bool Send(const void* item, std::uint32_t ticks_to_wait = 0);
64 bool SendFromISR(const void* item);
71 bool Receive(void* out_item, std::uint32_t ticks_to_wait = 0);
73 bool ReceiveFromISR(void* out_item);
79 bool Overwrite(const void* item);
81 bool Reset();
83 std::size_t MessagesWaiting() const;
85 std::size_t SpacesAvailable() const;
87 bool IsValid() const;
88
89 private:
90 void* handle_{nullptr};
91 std::size_t length_{0};
92 std::size_t item_size_{0};
93};
94
95} // namespace c7222
96
97#endif // ELEC_C7222_UTILS_FREERTOS_QUEUE_HPP
Ownership-based wrapper for a fixed-size item queue.
Definition freertos_queue.hpp:36
bool ReceiveFromISR(void *out_item)
Dequeue one item from ISR context.
std::size_t SpacesAvailable() const
FreeRtosQueue(std::size_t length, std::size_t item_size)
Construct and initialize a queue.
~FreeRtosQueue()
Destroy queue resources if initialized.
bool IsValid() const
bool Reset()
Reset the queue contents.
std::size_t MessagesWaiting() const
bool Receive(void *out_item, std::uint32_t ticks_to_wait=0)
Dequeue one item from task context.
bool Overwrite(const void *item)
Overwrite queue storage with a new item.
bool Initialize(std::size_t length, std::size_t item_size)
Initialize (or re-initialize) the queue.
FreeRtosQueue()=default
Construct an uninitialized queue wrapper.
bool SendFromISR(const void *item)
Enqueue one item from ISR context.
bool Send(const void *item, std::uint32_t ticks_to_wait=0)
Enqueue one item from task context.
Disable both copy and move operations.
Definition non_copyable.hpp:75
C7222 course abstractions namespace.
Definition ble.hpp:20
Base classes to control copy/move semantics.