66 auto u16ToRead = uint16_t{};
72 auto u16Allocated = uint16_t{};
73 auto u16PreWrap = uint16_t{};
74 auto* pu8Src = (uint8_t*){};
75 auto* pu8Dst = (uint8_t*){};
81 if (u16Allocated > u16Len_) {
84 u16ToRead = u16Allocated;
95 if (u16Allocated != 0u) {
96 if (u16PreWrap >= u16ToRead) {
97 for (
auto i = uint16_t{0}; i < u16ToRead; i++) { *pu8Dst++ = *pu8Src++; }
99 for (
auto i = uint16_t{0}; i < u16PreWrap; i++) { *pu8Dst++ = *pu8Src++; }
101 for (
auto i = u16PreWrap; i < u16ToRead; i++) { *pu8Dst++ = *pu8Src++; }
108 if (u16PreWrap >= u16ToRead) {
146 auto u16ToWrite = uint16_t{};
156 auto u16PreWrap = uint16_t{};
157 auto* pu8Src = (
const uint8_t*){};
158 auto* pu8Dst = (uint8_t*){};
163 u16ToWrite = u16Len_;
175 if (u16PreWrap >= u16ToWrite) {
176 m_u16Head += u16ToWrite;
185 if (u16ToWrite != 0u) {
186 if (u16PreWrap >= u16ToWrite) {
187 for (
auto i = uint16_t{0}; i < u16ToWrite; i++) { *pu8Dst++ = *pu8Src++; }
189 for (
auto i = uint16_t{0}; i < u16PreWrap; i++) { *pu8Dst++ = *pu8Src++; }
191 for (
auto i = u16PreWrap; i < u16ToWrite; i++) { *pu8Dst++ = *pu8Src++; }
Basic data type primatives used throughout the OS.
void Init(uint8_t *pau8Buffer_, uint16_t u16Size_)
Init. Initialize the Streamer object prior to its use, providing a blob of memory for the object to m...
uint8_t * m_pau8Buffer
Pointer to the buffer managed in this object.
void Unlock(void)
Unlock. Reset the lock pointer in the object, allowing a consumer to read any previously unavailable ...
bool Write(uint8_t u8Data_)
Write. Write a byte of data into the stream.
uint16_t m_u16Size
Size of the stream's circular buffer (in bytes)
uint16_t m_u16Avail
Number of bytes free in the stream.
bool Claim(uint8_t **pu8Addr_)
Claim. Claim a byte of data for writing, without actually writing into it. When the writer is ready t...
uint16_t m_u16Tail
Current tail index (read from) of the stream.
Single include file given to users of the Mark3 Kernel API.
bool Read(uint8_t *pu8Data_)
Read. Read a byte of data from the stream, if available.
uint16_t m_u16Head
Current head index (write to) of the stream.
uint8_t * m_pu8LockAddr
Address of the lock point in the stream.
The CriticalGuard class. This class provides an implemention of RAII for critical sections...
bool IsEmpty(void)
IsEmpty.
void Lock(uint8_t *pu8LockAddr_)
Lock. When the lock is set, a client can neither read from, or write to the buffer at the index speci...
Thread/Interrupt-safe byte-based data streaming.
bool CanRead(void)
CanRead.
bool CanWrite(void)
CanWrite.