Serial Port
Public Types | Public Member Functions
SerialRingBuffer Class Reference

Ring buffer for RX and TX data. More...

#include <SerialPort.h>

List of all members.

Public Types

typedef uint16_t buf_size_t

Public Member Functions

int available ()
bool empty ()
void flush ()
bool get (uint8_t *b)
buf_size_t get (uint8_t *b, buf_size_t n)
void init (uint8_t *b, buf_size_t s)
int peek ()
bool put (uint8_t b)
buf_size_t put (const uint8_t *b, buf_size_t n)
buf_size_t put_P (PGM_P b, buf_size_t n)

Detailed Description

Ring buffer for RX and TX data.

Definition at line 246 of file SerialPort.h.


Member Typedef Documentation

typedef uint16_t SerialRingBuffer::buf_size_t

Define type for buffer indices

Definition at line 250 of file SerialPort.h.


Member Function Documentation

int SerialRingBuffer::available ( )
Returns:
The number of bytes in the ring buffer.
Note:
This function must not be called with interrupts disabled.

Definition at line 30 of file SerialPort.cpp.

bool SerialRingBuffer::empty ( ) [inline]
Returns:
true if the ring buffer is empty else false.

Definition at line 256 of file SerialPort.h.

void SerialRingBuffer::flush ( )

Discard all data in the ring buffer.

Note:
This function must not be called with interrupts disabled.

Definition at line 42 of file SerialPort.cpp.

bool SerialRingBuffer::get ( uint8_t *  b)

Get the next byte from the ring buffer.

Parameters:
[in]blocation for the returned byte
Returns:
true if a byte was returned or false if the ring buffer is empty

Definition at line 54 of file SerialPort.cpp.

SerialRingBuffer::buf_size_t SerialRingBuffer::get ( uint8_t *  b,
buf_size_t  n 
)

Get the maximum number of contiguous bytes from the ring buffer with one call to memcpy.

Note:
This function must not be called with interrupts disabled.
Parameters:
[in]bPointer to the data.
[in]nNumber of bytes to transfer from the ring buffer.
Returns:
Number of bytes transferred.

Definition at line 72 of file SerialPort.cpp.

void SerialRingBuffer::init ( uint8_t *  b,
buf_size_t  s 
)

Initialize the ring buffer.

Parameters:
[in]bBuffer for the data.
[in]sSize of the buffer.

Definition at line 96 of file SerialPort.cpp.

int SerialRingBuffer::peek ( )

Peek at the next byte in the ring buffer.

Returns:
The next byte that would be read or -1 if the ring buffer is empty.

Definition at line 105 of file SerialPort.cpp.

bool SerialRingBuffer::put ( uint8_t  b)

Put a byte into the ring buffer.

Parameters:
[in]bthe byte
Returns:
true if byte was transferred or false if the ring buffer is full.

Definition at line 115 of file SerialPort.cpp.

SerialRingBuffer::buf_size_t SerialRingBuffer::put ( const uint8_t *  b,
buf_size_t  n 
)

Put the maximum number of contiguous bytes into the ring buffer. with one call to memcpy.

Note:
This function must not be called with interrupts disabled.
Parameters:
[in]bpointer to data.
[in]nnumber of bytes to transfer to the ring buffer.
Returns:
number of bytes transferred.

Definition at line 136 of file SerialPort.cpp.

SerialRingBuffer::buf_size_t SerialRingBuffer::put_P ( PGM_P  b,
buf_size_t  n 
)

Put the maximum number of contiguous bytes into the ring buffer. with one call to memcpy.

Note:
This function must not be called with interrupts disabled.
Parameters:
[in]bpointer to data.
[in]nnumber of bytes to transfer to the ring buffer.
Returns:
number of bytes transferred.

Definition at line 165 of file SerialPort.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Defines