4#ifndef TETL_FREERTOS_STREAM_BUFFER_HPP
5#define TETL_FREERTOS_STREAM_BUFFER_HPP
7#include <etl/version.hpp>
9#include <etl/cstddef.hpp>
10#include <etl/cstdint.hpp>
11#include <etl/span.hpp>
12#include <etl/utility.hpp>
14#if defined(TETL_FREERTOS_USE_STUBS)
15 #include <etl/experimental/freertos/stubs.hpp>
32 using size_type =
etl::size_t;
37 stream_buffer(size_type size, size_type triggerLevel)
noexcept;
54 auto write(
etl::span<
etl::
byte const> data, TickType_t ticks) -> size_type;
65 auto read(
etl::span<
etl::
byte> data, TickType_t ticks) -> size_type;
105 auto reset()
noexcept ->
void;
130 StreamBufferHandle_t _handle;
Definition adjacent_find.hpp:9
enum TETL_MAY_ALIAS byte
etl::byte is a distinct type that implements the concept of byte as specified in the C++ language def...
Definition byte.hpp:22
Stream buffers are an RTOS task to RTOS task, and interrupt to task communication primitives.
Definition stream_buffer.hpp:31
auto empty() const noexcept -> bool
Queries a stream buffer to see if it is empty. A stream buffer is empty if it does not contain any da...
Definition stream_buffer.hpp:163
auto space_available() const noexcept -> size_type
Queries a stream buffer to see how much free space it contains, which is equal to the amount of data ...
Definition stream_buffer.hpp:178
auto native_handle() const noexcept -> StreamBufferHandle_t
Returns the native FreeRTOS handle to the stream_buffer.
Definition stream_buffer.hpp:193
stream_buffer(stream_buffer &&other)=delete
auto trigger_level(size_type triggerLevel) noexcept -> void
A stream buffer's trigger level is the number of bytes that must be in the stream buffer before a tas...
Definition stream_buffer.hpp:188
auto bytes_available() const noexcept -> size_type
Queries a stream buffer to see how much data it contains, which is equal to the number of bytes that ...
Definition stream_buffer.hpp:173
~stream_buffer() noexcept
Deletes a stream buffer, then the allocated memory is freed.
Definition stream_buffer.hpp:138
auto write(etl::span< etl::byte const > data, TickType_t ticks) -> size_type
Sends bytes to a stream buffer. The bytes are copied into the stream buffer.
Definition stream_buffer.hpp:143
auto read_from_isr(etl::span< etl::byte > data, BaseType_t *prio) -> size_type
Receives bytes from a stream buffer.
Definition stream_buffer.hpp:158
auto operator=(stream_buffer const &other) -> stream_buffer &=delete
auto write_from_isr(etl::span< etl::byte const > data, BaseType_t *prio) -> size_type
Interrupt safe version of the API function that sends a stream of bytes to the stream buffer.
Definition stream_buffer.hpp:148
stream_buffer(size_type size, size_type triggerLevel) noexcept
Creates a new stream buffer using dynamically allocated memory.
Definition stream_buffer.hpp:133
auto reset() noexcept -> void
Resets a stream buffer to its initial, empty, state. Any data that was in the stream buffer is discar...
Definition stream_buffer.hpp:183
stream_buffer(stream_buffer const &other)=delete
auto full() const noexcept -> bool
Queries a stream buffer to see if it is full. A stream buffer is full if it does not have any free sp...
Definition stream_buffer.hpp:168
auto read(etl::span< etl::byte > data, TickType_t ticks) -> size_type
Receives bytes from a stream buffer.
Definition stream_buffer.hpp:153
auto operator=(stream_buffer &&other) -> stream_buffer &=delete
constexpr auto data() const noexcept -> pointer
Returns a pointer to the beginning of the sequence.
Definition span.hpp:225
constexpr auto size() const noexcept -> size_type
Returns the number of elements in the span.
Definition span.hpp:231
auto xStreamBufferSend(StreamBufferHandle_t handle, void const *data, etl::size_t size, TickType_t ticksToWait) -> etl::size_t
Definition stubs.hpp:119
auto xStreamBufferReceive(StreamBufferHandle_t handle, void *data, etl::size_t size, TickType_t ticks) -> etl::size_t
Definition stubs.hpp:135
auto xStreamBufferSpacesAvailable(StreamBufferHandle_t handle) -> etl::size_t
Definition stubs.hpp:159
auto xStreamBufferIsEmpty(StreamBufferHandle_t handle) -> BaseType_t
Definition stubs.hpp:177
auto xStreamBufferReset(StreamBufferHandle_t handle) -> BaseType_t
Definition stubs.hpp:171
auto xStreamBufferIsFull(StreamBufferHandle_t handle) -> BaseType_t
Definition stubs.hpp:183
auto xStreamBufferCreate(etl::size_t bufferSizeBytes, etl::size_t triggerLevelBytes) -> StreamBufferHandle_t
Definition stubs.hpp:111
auto xStreamBufferBytesAvailable(StreamBufferHandle_t handle) -> etl::size_t
Definition stubs.hpp:153
auto xStreamBufferReceiveFromISR(StreamBufferHandle_t handle, void *data, etl::size_t size, BaseType_t *prio) -> etl::size_t
Definition stubs.hpp:142
auto vStreamBufferDelete(StreamBufferHandle_t handle) -> void
Definition stubs.hpp:148
auto xStreamBufferSendFromISR(StreamBufferHandle_t handle, void const *data, etl::size_t size, BaseType_t *prio) -> etl::size_t
Definition stubs.hpp:127
auto xStreamBufferSetTriggerLevel(StreamBufferHandle_t handle, etl::size_t triggerLevel) -> BaseType_t
Definition stubs.hpp:165