git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@803 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-02-28 08:44:42 +00:00
parent e9274448e9
commit c6a781e7ae
1 changed files with 0 additions and 85 deletions

View File

@ -1,85 +0,0 @@
I/O Channels
- Channels are specific for I/O operations, however, a channel can hide a
complex IPC operation.
- Channels are N-sized not necessarily byte-sized.
- Channels support timeout.
- The IOChannel structure hides a virtualized implementation using a VMT.
- The APIs are macros that hide the VMT.
- Channels must support events, at least 3 events are predefined:
0 - Incoming data event.
1 - Output queue empty.
2 - I/O Status Change (at least one status flag was pended).
X - More events can be defined and are channel specific.
- Read/write functions are non blocking and can transfer no data if the
buffers are empty/full.
- Zero sized read and writes simply returns zero, nothing is queued.
/**
* @brief Returns the channel data unit size.
* @details The channel data unit size is characteristic of the channel and
* cannot be modified.
* @param[in] iop pointer to an IOChannel structure
* @return The channel data unit size in bytes.
*/
size_t chIOGetWidth(const IOChannel *iop);
/**
* @brief Returns the event sources associated to the channel.
* @details A channel can have associated event sources. The event sources are
* identified by a numerical identifier, the following identifiers
* are predefined:
* - CH_IO_EVT_INPUT signaled when some data is queued in the input buffer.
* - CH_IO_EVT_OUTPUT signaled when the output buffer is emptied.
* - CH_IO_EVT_STATUS signaled when a channel related condition happens.
*
* @param[in] iop pointer to an IOChannel structure
* @param[in] n the numerical identifier.
* @return A pointer to the @p EventSource structure associated to the numerical
* identifier.
* @retval NULL there is no event source associated to the specified
* identifier.
*/
EventSource *chIOGetEventSource(const IOChannel *iop, ioevtsrc_t n);
/**
* @brief Returns the channel status flags.
* @details The channel status flags are returned and cleared.
*
* @param[in] iop pointer to an IOChannel structure
* @return The status flags.
* @retval 0 no flags pending.
*/
iosts_t chIOGetAndClearStatus(IOChannel *iop);
/**
* @brief Asynchronous read.
* @details This function reads up to @p n data units into the specified
* buffer without blocking. If there is no data into the input queue
* then the function returns immediatly.
*
* @param[in] iop pointer to an IOChannel structure
* @param[out] buf the buffer where to copy the input data
* @param[in] n the maximum number of data units to transfer
* @return The actual data units number read.
* @retval 0 the input queue is empty, no data transfer was performed.
*/
size_t chIORead(IOChannel *iop, void *buf, size_t n);
/**
* @brief Asynchronous write.
* @details This function writes up to @p n data units from the specified
* buffer without blocking. If there is no space into the output queue
* then the function returns immediatly.
*
* @param[in] iop pointer to an IOChannel structure
* @param[out] buf the buffer with the data to be written
* @param[in] n the maximum number of data units to transfer
* @return The actual data units number written.
* @retval 0 the output queue is full, no data transfer was performed.
*/
size_t chIOWrite(IOChannel *iop, const void *buf, size_t n);
bool_t chIOWaitInput(IOChannel *iop, systime_t timeout);
bool_t chIOWaitOutput(IOChannel *iop, systime_t timeout);