35#ifndef _FREERTOS_DRIVERS_COMMON_DEVICE_BUFFER_HXX_
36#define _FREERTOS_DRIVERS_COMMON_DEVICE_BUFFER_HXX_
46#ifdef OPENMRN_FEATURE_DEVTAB
55#ifdef OPENMRN_FEATURE_DEVTAB
60 static void block_until_condition(
File *file,
bool read);
67#ifdef OPENMRN_FEATURE_DEVTAB
77#ifdef OPENMRN_FEATURE_DEVTAB
115#ifdef OPENMRN_FEATURE_DEVTAB
130 size_t consumed = items;
152 size_t added = items;
185#ifdef OPENMRN_FEATURE_DEVTAB
233 return device_buffer;
236 typedef T member_type;
258 size_t put(
const T *buf,
size_t items)
260 size_t last_count =
count;
273 return count - last_count;
281 size_t get(T *buf,
size_t items)
283 size_t last_count =
count;
285 while (items && (
count > 0))
296 return last_count -
count;
323 if (
space() < result)
Helper for DeviceBuffer which allows for methods to not be inlined.
uint16_t readIndex
read index
void flush()
flush all the data out of the buffer and reset the buffer.
uint16_t level
level of space required in buffer in order to wakeup, 0 if unused
size_t advance(size_t items)
Add a number of items to the buffer by advancing the writeIndex.
size_t space()
Return the number of items for which space is available.
void signal_condition()
Signal the wakeup condition.
~DeviceBufferBase()
Destructor.
size_t pending()
Return the number of items in the queue.
uint16_t size
size in items of buffer
size_t consume(size_t items)
Remove a number of items from the buffer by advancing the readIndex.
void select_insert()
Add client to list of clients needing woken.
uint16_t writeIndex
write index
void signal_condition_from_isr()
Signal the wakeup condition from an ISR context.
DeviceBufferBase(size_t size, size_t level)
Constructor.
uint16_t count
total number of items in buffer
Implements a smart buffer specifically designed for character device drivers.
size_t get(T *buf, size_t items)
remove a number of items from the buffer.
DeviceBuffer(size_t size, size_t level)
Constructor.
static constexpr unsigned member_size()
size_t data_write_pointer(T **buf)
Get a reference to the current location in the buffer for write.
size_t put(const T *buf, size_t items)
Insert a number of items to the buffer.
size_t data_read_pointer(T **buf)
Get a reference to the current location in the buffer for read.
void destroy()
Destroy an existing DeviceBuffer instance.
~DeviceBuffer()
Destructor.
static DeviceBuffer * create(size_t size, size_t level=0)
Create a DeviceBuffer instance.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Select wakeup information.
static void select_wakeup_from_isr(SelectInfo *info, int *woken)
Wakeup the list of clients needing woken.
static void select_insert(SelectInfo *info)
Add client to list of clients needing woken.
static void select_wakeup(SelectInfo *info)
Wakeup the list of clients needing woken.