![]() |
ChibiOS/RT Architecture - Reference Manual - Guides |
|
This module defines an abstract interface for I/O channels by extending the BaseSequentialStream interface. Note that no code is present, I/O channels are just abstract interface like structures, you should look at the systems as to a set of abstract C++ classes (even if written in C). Specific device drivers can use/extend the interface and implement them.
This system has the advantage to make the access to channels independent from the implementation logic.
Data Structures | |
| struct | BaseChannelVMT |
BaseChannel virtual methods table. More... | |
| struct | BaseChannel |
| Base channel class. More... | |
| struct | BaseAsynchronousChannelVMT |
BaseAsynchronousChannel virtual methods table. More... | |
| struct | BaseAsynchronousChannel |
| Base asynchronous channel class. More... | |
Defines | |
| #define | _base_channel_methods |
BaseChannel specific methods. | |
| #define | _base_channel_data _base_sequential_stream_data |
BaseChannel specific data. | |
| #define | chIOPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip)) |
| Channel output check. | |
| #define | chIOGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip)) |
| Channel input check. | |
| #define | chIOPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE)) |
| Channel blocking byte write. | |
| #define | chIOPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time)) |
| Channel blocking byte write with timeout. | |
| #define | chIOGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE)) |
| Channel blocking byte read. | |
| #define | chIOGetTimeout(ip, time) ((ip)->vmt->get(ip, time)) |
| Channel blocking byte read with timeout. | |
| #define | chIOWriteTimeout(ip, bp, n, time) ((ip)->vmt->writet(ip, bp, n, time)) |
| Channel blocking write with timeout. | |
| #define | chIOReadTimeout(ip, bp, n, time) ((ip)->vmt->readt(ip, bp, n, time)) |
| Channel blocking read with timeout. | |
| #define | _base_asynchronous_channel_methods _base_channel_methods |
BaseAsynchronousChannel specific methods. | |
| #define | _base_asynchronous_channel_data |
BaseAsynchronousChannel specific data. | |
| #define | chIOGetWriteEventSource(ip) (&((ip)->vmt->oevent)) |
| Returns the write event source. | |
| #define | chIOGetReadEventSource(ip) (&((ip)->vmt->ievent)) |
| Returns the read event source. | |
| #define _base_channel_methods |
_base_sequential_stream_methods \ /* Channel output check.*/ \ bool_t (*putwouldblock)(void *instance); \ /* Channel input check.*/ \ bool_t (*getwouldblock)(void *instance); \ /* Channel put method with timeout specification.*/ \ msg_t (*put)(void *instance, uint8_t b, systime_t time); \ /* Channel get method with timeout specification.*/ \ msg_t (*get)(void *instance, systime_t time); \ /* Channel write method with timeout specification.*/ \ size_t (*writet)(void *instance, const uint8_t *bp, \ size_t n, systime_t time); \ /* Channel read method with timeout specification.*/ \ size_t (*readt)(void *instance, uint8_t *bp, size_t n, systime_t time);
BaseChannel specific methods.
| #define _base_channel_data _base_sequential_stream_data |
BaseChannel specific data.
BaseChannel is only an interface without implementation. | #define chIOPutWouldBlock | ( | ip | ) | ((ip)->vmt->putwouldblock(ip)) |
Channel output check.
This function verifies if a subsequent put/write operation would block.
| [in] | ip | pointer to a BaseChannel or derived class |
| FALSE | if the output queue has space and would not block a write operation. | |
| TRUE | if the output queue is full and would block a write operation. |
| #define chIOGetWouldBlock | ( | ip | ) | ((ip)->vmt->getwouldblock(ip)) |
Channel input check.
This function verifies if a subsequent get/read operation would block.
| [in] | ip | pointer to a BaseChannel or derived class |
| FALSE | if the input queue contains data and would not block a read operation. | |
| TRUE | if the input queue is empty and would block a read operation. |
| #define chIOPut | ( | ip, | ||
| b | ||||
| ) | ((ip)->vmt->put(ip, b, TIME_INFINITE)) |
Channel blocking byte write.
This function writes a byte value to a channel. If the channel is not ready to accept data then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| [in] | b | the byte value to be written to the channel |
| Q_OK | if the operation succeeded. | |
| Q_RESET | if the channel associated queue (if any) was reset. |
| #define chIOPutTimeout | ( | ip, | ||
| b, | ||||
| time | ||||
| ) | ((ip)->vmt->put(ip, b, time)) |
Channel blocking byte write with timeout.
This function writes a byte value to a channel. If the channel is not ready to accept data then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| [in] | b | the byte value to be written to the channel |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| Q_OK | if the operation succeeded. | |
| Q_TIMEOUT | if the specified time expired. | |
| Q_RESET | if the channel associated queue (if any) was reset. |
| #define chIOGet | ( | ip | ) | ((ip)->vmt->get(ip, TIME_INFINITE)) |
Channel blocking byte read.
This function reads a byte value from a channel. If the data is not available then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| Q_RESET | if the channel associated queue (if any) was reset. |
| #define chIOGetTimeout | ( | ip, | ||
| time | ||||
| ) | ((ip)->vmt->get(ip, time)) |
Channel blocking byte read with timeout.
This function reads a byte value from a channel. If the data is not available then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| Q_TIMEOUT | if the specified time expired. | |
| Q_RESET | if the channel associated queue (if any) was reset. |
| #define chIOWriteTimeout | ( | ip, | ||
| bp, | ||||
| n, | ||||
| time | ||||
| ) | ((ip)->vmt->writet(ip, bp, n, time)) |
Channel blocking write with timeout.
The function writes data from a buffer to a channel. If the channel is not ready to accept data then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| [out] | bp | pointer to the data buffer |
| [in] | n | the maximum amount of data to be transferred |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| #define chIOReadTimeout | ( | ip, | ||
| bp, | ||||
| n, | ||||
| time | ||||
| ) | ((ip)->vmt->readt(ip, bp, n, time)) |
Channel blocking read with timeout.
The function reads data from a channel into a buffer. If the data is not available then the calling thread is suspended.
| [in] | ip | pointer to a BaseChannel or derived class |
| [in] | bp | pointer to the data buffer |
| [in] | n | the maximum amount of data to be transferred |
| [in] | time | the number of ticks before the operation timeouts, the following special values are allowed:
|
| #define _base_asynchronous_channel_methods _base_channel_methods |
BaseAsynchronousChannel specific methods.
| #define _base_asynchronous_channel_data |
_base_channel_data \ /* Data Available EventSource.*/ \ EventSource ievent; \ /* Data Transmitted EventSource.*/ \ EventSource oevent;
BaseAsynchronousChannel specific data.
| #define chIOGetWriteEventSource | ( | ip | ) | (&((ip)->vmt->oevent)) |
Returns the write event source.
The write event source is broadcasted when the channel is ready for write operations. This usually happens when the internal output queue becomes empty.
| [in] | ip | pointer to a BaseAsynchronousChannel or derived class |
EventSource object. | #define chIOGetReadEventSource | ( | ip | ) | (&((ip)->vmt->ievent)) |
Returns the read event source.
The read event source is broadcasted when the channel is ready for read operations. This usually happens when the internal input queue becomes non-empty.
| [in] | ip | pointer to a BaseAsynchronousChannel or derived class |
EventSource object.
1.7.1