|
ChibiOS/HAL 9.0.0
|
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.

Default control operation codes. | |
| #define | CHN_CTL_INVALID 0 |
| Invalid operation code. | |
| #define | CHN_CTL_NOP 1 |
| Does nothing. | |
| #define | CHN_CTL_TX_WAIT 2 |
| Wait for TX completion. | |
Macro Functions (BaseChannel) | |
| #define | chnPutTimeout(ip, b, time) |
| Channel blocking byte write with timeout. | |
| #define | chnGetTimeout(ip, time) |
| Channel blocking byte read with timeout. | |
| #define | chnWrite(ip, bp, n) |
| Channel blocking write. | |
| #define | chnWriteTimeout(ip, bp, n, time) |
| Channel blocking write with timeout. | |
| #define | chnRead(ip, bp, n) |
| Channel blocking read. | |
| #define | chnReadTimeout(ip, bp, n, time) |
| Channel blocking read with timeout. | |
| #define | chnControl(ip, operation, arg) |
| Control operation on a channel. | |
I/O status flags added to the event listener | |
| #define | CHN_NO_ERROR (eventflags_t)0 |
| No pending conditions. | |
| #define | CHN_CONNECTED (eventflags_t)1 |
| Connection happened. | |
| #define | CHN_DISCONNECTED (eventflags_t)2 |
| Disconnection happened. | |
| #define | CHN_INPUT_AVAILABLE (eventflags_t)4 |
| Data available in the input queue. | |
| #define | CHN_OUTPUT_EMPTY (eventflags_t)8 |
| Output queue empty. | |
| #define | CHN_TRANSMISSION_END (eventflags_t)16 |
| Transmission end. | |
| #define | CHN_PARITY_ERROR (eventflags_t)32 |
| Parity error. | |
| #define | CHN_FRAMING_ERROR (eventflags_t)64 |
| Framing error. | |
| #define | CHN_NOISE_ERROR (eventflags_t)128 |
| Line noise error. | |
| #define | CHN_OVERRUN_ERROR (eventflags_t)256 |
| Overflow error. | |
| #define | CHN_IDLE_DETECTED (eventflags_t)512 |
| RX line idle. | |
| #define | CHN_BREAK_DETECTED (eventflags_t)1024 |
| LIN Break. | |
| #define | CHN_BUFFER_FULL_ERROR (eventflags_t)2048 |
Macro Functions (BaseAsynchronousChannel) | |
| #define | chnGetEventSource(ip) |
| Returns the I/O condition event source. | |
| #define | chnAddFlagsI(ip, flags) |
| Adds status flags to the listeners's flags mask. | |
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... | |
Macros | |
| #define | _base_channel_methods |
BaseChannel specific methods. | |
| #define | _base_channel_data _base_sequential_stream_data |
BaseChannel specific data. | |
| #define | _base_asynchronous_channel_methods _base_channel_methods \ |
BaseAsynchronousChannel specific methods. | |
| #define | _base_asynchronous_channel_data |
BaseAsynchronousChannel specific data. | |
| #define CHN_CTL_INVALID 0 |
Invalid operation code.
Definition at line 43 of file hal_channels.h.
Referenced by __buffered_serial_ctl_impl(), __ctl(), _ctl(), and _ctl().
| #define CHN_CTL_NOP 1 |
Does nothing.
Definition at line 44 of file hal_channels.h.
Referenced by __buffered_serial_ctl_impl(), __ctl(), _ctl(), and _ctl().
| #define CHN_CTL_TX_WAIT 2 |
Wait for TX completion.
Definition at line 45 of file hal_channels.h.
| #define _base_channel_methods |
BaseChannel specific methods.
Definition at line 51 of file hal_channels.h.
| #define _base_channel_data _base_sequential_stream_data |
BaseChannel specific data.
BaseChannel is only an interface without implementation. Definition at line 71 of file hal_channels.h.
| #define chnPutTimeout | ( | 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:
|
| STM_OK | if the operation succeeded. |
| STM_TIMEOUT | if the specified time expired. |
| STM_RESET | if the channel associated queue (if any) was reset. |
Definition at line 118 of file hal_channels.h.
| #define chnGetTimeout | ( | 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:
|
| STM_TIMEOUT | if the specified time expired. |
| STM_RESET | if the channel associated queue (if any) has been reset. |
Definition at line 137 of file hal_channels.h.
| #define chnWrite | ( | ip, | |
| bp, | |||
| n ) |
Channel blocking write.
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 |
Definition at line 152 of file hal_channels.h.
| #define chnWriteTimeout | ( | 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:
|
Definition at line 170 of file hal_channels.h.
| #define chnRead | ( | ip, | |
| bp, | |||
| n ) |
Channel blocking read.
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 |
Definition at line 185 of file hal_channels.h.
| #define chnReadTimeout | ( | 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:
|
Definition at line 203 of file hal_channels.h.
| #define chnControl | ( | ip, | |
| operation, | |||
| arg ) |
Control operation on a channel.
| [in] | ip | pointer to a BaseChannel or derived class |
| [in] | operation | control operation code |
| [in,out] | arg | operation argument |
| MSG_OK | in case of success. |
| MSG_TIMEOUT | in case of operation timeout. |
| MSG_RESET | in case of operation reset. |
Definition at line 219 of file hal_channels.h.
| #define CHN_NO_ERROR (eventflags_t)0 |
No pending conditions.
Definition at line 227 of file hal_channels.h.
| #define CHN_CONNECTED (eventflags_t)1 |
Connection happened.
Definition at line 229 of file hal_channels.h.
Referenced by sduConfigureHookI(), and sduWakeupHookI().
| #define CHN_DISCONNECTED (eventflags_t)2 |
Disconnection happened.
Definition at line 231 of file hal_channels.h.
Referenced by sduStop(), and sduSuspendHookI().
| #define CHN_INPUT_AVAILABLE (eventflags_t)4 |
Data available in the input queue.
Definition at line 233 of file hal_channels.h.
Referenced by bsIncomingDataI(), sdIncomingDataI(), and sduDataReceived().
| #define CHN_OUTPUT_EMPTY (eventflags_t)8 |
Output queue empty.
Definition at line 235 of file hal_channels.h.
Referenced by __bsio_push_data(), bsRequestDataI(), sdRequestDataI(), and sduDataTransmitted().
| #define CHN_TRANSMISSION_END (eventflags_t)16 |
Transmission end.
Definition at line 237 of file hal_channels.h.
| #define CHN_PARITY_ERROR (eventflags_t)32 |
Parity error.
Definition at line 239 of file hal_channels.h.
| #define CHN_FRAMING_ERROR (eventflags_t)64 |
Framing error.
Definition at line 241 of file hal_channels.h.
| #define CHN_NOISE_ERROR (eventflags_t)128 |
Line noise error.
Definition at line 243 of file hal_channels.h.
| #define CHN_OVERRUN_ERROR (eventflags_t)256 |
Overflow error.
Definition at line 245 of file hal_channels.h.
| #define CHN_IDLE_DETECTED (eventflags_t)512 |
RX line idle.
Definition at line 247 of file hal_channels.h.
| #define CHN_BREAK_DETECTED (eventflags_t)1024 |
| #define CHN_BUFFER_FULL_ERROR (eventflags_t)2048 |
Definition at line 251 of file hal_channels.h.
Referenced by bsIncomingDataI().
| #define _base_asynchronous_channel_methods _base_channel_methods \ |
BaseAsynchronousChannel specific methods.
Definition at line 257 of file hal_channels.h.
| #define _base_asynchronous_channel_data |
BaseAsynchronousChannel specific data.
Definition at line 263 of file hal_channels.h.
| #define chnGetEventSource | ( | ip | ) |
Returns the I/O condition event source.
The event source is broadcasted when an I/O condition happens.
| [in] | ip | pointer to a BaseAsynchronousChannel or derived class |
EventSource object.Definition at line 304 of file hal_channels.h.
| #define chnAddFlagsI | ( | ip, | |
| flags ) |
Adds status flags to the listeners's flags mask.
This function is usually called from the I/O ISRs in order to notify I/O conditions such as data events, errors, signal changes etc.
| [in] | ip | pointer to a BaseAsynchronousChannel or derived class |
| [in] | flags | condition flags to be added to the listener flags mask |
Definition at line 318 of file hal_channels.h.
Referenced by __bsio_default_cb(), __bsio_push_data(), bsIncomingDataI(), bsRequestDataI(), sdIncomingDataI(), sdRequestDataI(), sduConfigureHookI(), sduDataReceived(), sduDataTransmitted(), sduStop(), sduSuspendHookI(), and sduWakeupHookI().