ChibiOS/RT
6.0.3
|
Macros | |
#define | _PIPE_DATA(name, buffer, size) |
Data part of a static pipe initializer. More... | |
#define | PIPE_DECL(name, buffer, size) pipe_t name = _PIPE_DATA(name, buffer, size) |
Static pipe initializer. More... | |
Data Structures | |
struct | pipe_t |
Structure representing a pipe object. More... | |
Functions | |
static size_t | pipe_write (pipe_t *pp, const uint8_t *bp, size_t n) |
Non-blocking pipe write. More... | |
static size_t | pipe_read (pipe_t *pp, uint8_t *bp, size_t n) |
Non-blocking pipe read. More... | |
void | chPipeObjectInit (pipe_t *pp, uint8_t *buf, size_t n) |
Initializes a mailbox_t object. More... | |
void | chPipeReset (pipe_t *pp) |
Resets a pipe_t object. More... | |
size_t | chPipeWriteTimeout (pipe_t *pp, const uint8_t *bp, size_t n, sysinterval_t timeout) |
Pipe write with timeout. More... | |
size_t | chPipeReadTimeout (pipe_t *pp, uint8_t *bp, size_t n, sysinterval_t timeout) |
Pipe read with timeout. More... | |
static size_t | chPipeGetSize (const pipe_t *pp) |
Returns the pipe buffer size as number of bytes. More... | |
static size_t | chPipeGetUsedCount (const pipe_t *pp) |
Returns the number of used byte slots into a pipe. More... | |
static size_t | chPipeGetFreeCount (const pipe_t *pp) |
Returns the number of free byte slots into a pipe. More... | |
static void | chPipeResume (pipe_t *pp) |
Terminates the reset state. More... | |
#define _PIPE_DATA | ( | name, | |
buffer, | |||
size | |||
) |
Data part of a static pipe initializer.
This macro should be used when statically initializing a pipe that is part of a bigger structure.
[in] | name | the name of the pipe variable |
[in] | buffer | pointer to the pipe buffer array of uint8_t |
[in] | size | number of uint8_t elements in the buffer array |
#define PIPE_DECL | ( | name, | |
buffer, | |||
size | |||
) | pipe_t name = _PIPE_DATA(name, buffer, size) |
Static pipe initializer.
Statically initialized pipes require no explicit initialization using chPipeObjectInit()
.
[in] | name | the name of the pipe variable |
[in] | buffer | pointer to the pipe buffer array of uint8_t |
[in] | size | number of uint8_t elements in the buffer array |
|
static |
Non-blocking pipe write.
The function writes data from a buffer to a pipe. The operation completes when the specified amount of data has been transferred or when the pipe buffer has been filled.
[in] | pp | the pointer to an initialized pipe_t object |
[in] | bp | pointer to the data buffer |
[in] | n | the maximum amount of data to be transferred, the value 0 is reserved |
Definition at line 105 of file chpipes.c.
References pipe_t::buffer, chPipeGetFreeCount(), pipe_t::cnt, pipe_t::top, and pipe_t::wrptr.
Referenced by chPipeWriteTimeout().
|
static |
Non-blocking pipe read.
The function reads data from a pipe into a buffer. The operation completes when the specified amount of data has been transferred or when the pipe buffer has been emptied.
[in] | pp | the pointer to an initialized pipe_t object |
[out] | bp | pointer to the data buffer |
[in] | n | the maximum amount of data to be transferred, the value 0 is reserved |
Definition at line 156 of file chpipes.c.
References pipe_t::buffer, chPipeGetUsedCount(), pipe_t::cnt, pipe_t::rdptr, and pipe_t::top.
Referenced by chPipeReadTimeout().
void chPipeObjectInit | ( | pipe_t * | pp, |
uint8_t * | buf, | ||
size_t | n | ||
) |
Initializes a mailbox_t
object.
[out] | pp | the pointer to the pipe_t structure to be initialized |
[in] | buf | pointer to the pipe buffer as an array of uint8_t |
[in] | n | number of elements in the buffer array |
Definition at line 207 of file chpipes.c.
References pipe_t::buffer, chDbgCheck, pipe_t::cnt, pipe_t::rdptr, pipe_t::reset, pipe_t::rtr, pipe_t::top, pipe_t::wrptr, and pipe_t::wtr.
Referenced by chFactoryCreatePipe().
void chPipeReset | ( | pipe_t * | pp | ) |
Resets a pipe_t
object.
All the waiting threads are resumed with status MSG_RESET
and the queued data is lost.
MSG_RESET
until the mailbox is enabled again using chPipeResumeX()
.[in] | pp | the pointer to an initialized pipe_t object |
Definition at line 236 of file chpipes.c.
References pipe_t::buffer, chDbgCheck, chSchRescheduleS(), chSysLock(), chSysUnlock(), chThdResumeI(), pipe_t::cnt, MSG_RESET, pipe_t::rdptr, pipe_t::reset, pipe_t::rtr, pipe_t::wrptr, and pipe_t::wtr.
size_t chPipeWriteTimeout | ( | pipe_t * | pp, |
const uint8_t * | bp, | ||
size_t | n, | ||
sysinterval_t | timeout | ||
) |
Pipe write with timeout.
The function writes data from a buffer to a pipe. The operation completes when the specified amount of data has been transferred or after the specified timeout or if the pipe has been reset.
[in] | pp | the pointer to an initialized pipe_t object |
[in] | bp | pointer to the data buffer |
[in] | n | the number of bytes to be written, the value 0 is reserved |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
n
means that a timeout occurred or the pipe went in reset state.Definition at line 278 of file chpipes.c.
References chDbgCheck, chSysLock(), chSysUnlock(), chThdResume(), chThdSuspendTimeoutS(), MSG_OK, pipe_write(), pipe_t::reset, pipe_t::rtr, and pipe_t::wtr.
size_t chPipeReadTimeout | ( | pipe_t * | pp, |
uint8_t * | bp, | ||
size_t | n, | ||
sysinterval_t | timeout | ||
) |
Pipe read with timeout.
The function reads data from a pipe into a buffer. The operation completes when the specified amount of data has been transferred or after the specified timeout or if the pipe has been reset.
[in] | pp | the pointer to an initialized pipe_t object |
[out] | bp | pointer to the data buffer |
[in] | n | the number of bytes to be read, the value 0 is reserved |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
n
means that a timeout occurred or the pipe went in reset state.Definition at line 343 of file chpipes.c.
References chDbgCheck, chSysLock(), chSysUnlock(), chThdResume(), chThdSuspendTimeoutS(), MSG_OK, pipe_read(), pipe_t::reset, pipe_t::rtr, and pipe_t::wtr.
|
inlinestatic |
Returns the pipe buffer size as number of bytes.
[in] | pp | the pointer to an initialized pipe_t object |
Definition at line 158 of file chpipes.h.
References pipe_t::buffer, and pipe_t::top.
Referenced by chPipeGetFreeCount().
|
inlinestatic |
Returns the number of used byte slots into a pipe.
[in] | pp | the pointer to an initialized pipe_t object |
Definition at line 174 of file chpipes.h.
References pipe_t::cnt.
Referenced by chPipeGetFreeCount(), and pipe_read().
|
inlinestatic |
Returns the number of free byte slots into a pipe.
[in] | pp | the pointer to an initialized pipe_t object |
Definition at line 187 of file chpipes.h.
References chPipeGetSize(), and chPipeGetUsedCount().
Referenced by pipe_write().
|
inlinestatic |
Terminates the reset state.
[in] | pp | the pointer to an initialized pipe_t object |
Definition at line 199 of file chpipes.h.
References pipe_t::reset.