Loading...
Searching...
No Matches
buffer_stream.h File Reference

This file implements the concept of a buffer stream. More...

#include <furi.h>

Go to the source code of this file.

Typedefs

typedef struct Buffer Buffer
 
typedef struct BufferStream BufferStream
 

Functions

uint8_t * buffer_get_data (Buffer *buffer)
 Get buffer data pointer.
 
size_t buffer_get_size (Buffer *buffer)
 Get buffer size.
 
void buffer_reset (Buffer *buffer)
 Reset buffer and send to free buffer pool.
 
BufferStreambuffer_stream_alloc (size_t buffer_size, size_t buffers_count)
 Allocate a new BufferStream instance.
 
void buffer_stream_free (BufferStream *buffer_stream)
 Free a BufferStream instance.
 
bool buffer_stream_send_from_isr (BufferStream *buffer_stream, const uint8_t *data, size_t size)
 Write data to buffer stream, from ISR context Data will be written to the buffer until the buffer is full, and only then will the buffer be sent.
 
Bufferbuffer_stream_receive (BufferStream *buffer_stream, uint32_t timeout)
 Receive buffer from stream.
 
size_t buffer_stream_get_overrun_count (BufferStream *buffer_stream)
 Get stream overrun count.
 
void buffer_stream_reset (BufferStream *buffer_stream)
 Reset stream and buffer pool.
 

Detailed Description

This file implements the concept of a buffer stream.

Data is written to the buffer until the buffer is full. Then the buffer pointer is written to the stream, and the new write buffer is taken from the buffer pool. After the buffer has been read by the receiving thread, it is sent to the free buffer pool.

This will speed up sending large chunks of data between threads, compared to using a stream directly.

Function Documentation

◆ buffer_get_data()

uint8_t * buffer_get_data ( Buffer * buffer)

Get buffer data pointer.

Parameters
buffer
Returns
uint8_t*

◆ buffer_get_size()

size_t buffer_get_size ( Buffer * buffer)

Get buffer size.

Parameters
buffer
Returns
size_t

◆ buffer_reset()

void buffer_reset ( Buffer * buffer)

Reset buffer and send to free buffer pool.

Parameters
buffer

◆ buffer_stream_alloc()

BufferStream * buffer_stream_alloc ( size_t buffer_size,
size_t buffers_count )

Allocate a new BufferStream instance.

Parameters
buffer_size
buffers_count
Returns
BufferStream*

◆ buffer_stream_free()

void buffer_stream_free ( BufferStream * buffer_stream)

Free a BufferStream instance.

Parameters
buffer_stream

◆ buffer_stream_get_overrun_count()

size_t buffer_stream_get_overrun_count ( BufferStream * buffer_stream)

Get stream overrun count.

Parameters
buffer_stream
Returns
size_t

◆ buffer_stream_receive()

Buffer * buffer_stream_receive ( BufferStream * buffer_stream,
uint32_t timeout )

Receive buffer from stream.

Parameters
buffer_stream
timeout
Returns
Buffer*

◆ buffer_stream_reset()

void buffer_stream_reset ( BufferStream * buffer_stream)

Reset stream and buffer pool.

Parameters
buffer_stream

◆ buffer_stream_send_from_isr()

bool buffer_stream_send_from_isr ( BufferStream * buffer_stream,
const uint8_t * data,
size_t size )

Write data to buffer stream, from ISR context Data will be written to the buffer until the buffer is full, and only then will the buffer be sent.

Parameters
buffer_stream
data
size
Returns
bool