OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qbsbuffers.h
1
8#ifndef QBSBUFFERS_H
9 #define QBSBUFFERS_H
10
11 #include "qtypes.h"
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #ifndef Q_BYTE_SIZED_BUFFERS
18 #define Q_BYTE_SIZED_BUFFERS ( 1 )
19 #endif
20
30 typedef struct _qBSBuffer_s { // skipcq: CXX-E2000
32 struct _qBSBuffer_Private_s { // skipcq: CXX-E2000
33 volatile qUINT8_t *buffer; /*< Points to the beginning of the buffer storage area. */
34 volatile qIndex_t head; /*< Used to hold the index of the head. */
35 volatile qIndex_t tail; /*< Used to hold the index of the tail. */
36 size_t length; /*< The length of the buffer(a valid power of two). */
37 }
38 qPrivate;
40 }
42
48 size_t qBSBuffer_Count( const qBSBuffer_t * const b );
49
57
65
73
82 qUINT8_t *dst );
83
92 void *dst,
93 const size_t n );
94
102 const qUINT8_t bData );
103
112 volatile qUINT8_t *pBuffer,
113 const size_t length );
114
117 #ifdef __cplusplus
118 }
119 #endif
120
121#endif
qBool_t qBSBuffer_Setup(qBSBuffer_t *const b, volatile qUINT8_t *pBuffer, const size_t length)
Initialize the Byte-sized buffer.
qBool_t qBSBuffer_Read(qBSBuffer_t *const b, void *dst, const size_t n)
Gets n data from the Byte-sized buffer and removes them.
qBool_t qBSBuffer_Put(qBSBuffer_t *const b, const qUINT8_t bData)
Adds an element of data to the Byte-sized buffer.
qBool_t qBSBuffer_Empty(const qBSBuffer_t *const b)
Query the empty status of the Byte-sized buffer.
size_t qBSBuffer_Count(const qBSBuffer_t *const b)
Query the number of elements in the Byte-sized buffer.
qUINT8_t qBSBuffer_Peek(const qBSBuffer_t *const b)
Looks for one byte from the head of the Byte-sized buffer without removing it.
qBool_t qBSBuffer_Get(qBSBuffer_t *const b, qUINT8_t *dst)
Gets one data-byte from the front of the Byte-sized buffer, and removes it.
qBool_t qBSBuffer_IsFull(const qBSBuffer_t *const b)
Query the full status of the Byte-sized buffer.
qUINT8_t qBool_t
A type to instantiate an OS boolean variable.
Definition qtypes.h:139
uint8_t qUINT8_t
Unsigned integer type with width of exactly 8 bits respectively.
Definition qtypes.h:44
size_t qIndex_t
A type to instantiate an OS index variable. Can store the maximum size of a theoretically possible ob...
Definition qtypes.h:146
A BSBuffer(Byte-sized buffer) object.
Definition qbsbuffers.h:30