Overview of ECROS Stream I/O

ECROS provides stream input / output services to hardware devices that can be usefully viewed as sources and sinks of byte or character streams.  For example, a UART can clearly be viewed in this way so ECROS supports stream I/O to and from UARTs.  A display device, such as an LCD, can also be viewed as a place to send characters or control bytes.  Displays based on popular controllers such as the Hitachi H44780U are supported by ECROS.  When functionality of the device cannot be easily supported by "in-band" control, that is by data sent in the stream, an "out-of-band" control path is provided.  An example of out-of-band control is setting the cursor and insertion position on a display.

UART Streams

ECROS supports two input/output serial streams for UARTs that are integral to the MCU.  The stream identifiers are OS_UART0 and OS_UART1.  Both input and output are buffered and the size of buffers can be selected during configuration before ECROS is compiled.  Stream services operate on the buffers and always complete essentially without delay.  Characters are moved between the buffers and the UARTs using interrupts.

Input from the buffers can be polled.  That is, the application can periodically call ECROS API functions to read from the stream and process input as it arrives.  In this situation, the advantage of buffering is that the polling rate only needs to be chosen to avoid the buffer filling, not to catch every character.  Input can also be event-driven.  In this case, the application calls an ECROS API function to instruct the stream to send an event to a task when input arrives.

The Display Stream

ECROS supports a single output-only display stream on the assumption that a single display device is attached to the target system.  The stream identifier is OS_DISPLAY.  The selection of the display device type must be made during configuration before ECROS is compiled.  For example, a device using the Hitachi H44780U can be selected and the connection of the controller data bus and control signals to the MCU specified.  When ECROS is compiled and linked into an application, characters directed to the display device will appear on the display.

The display stream is fully buffered.  That is, memory is set aside to store a complete display screen image and it is to this image that characters are first written.  The actual display is updated from the image during idle time when application tasks are not calling on the CPU.  Applications need not be concerned with the time taken by the display controller to complete an operation.  For example, the H44780U controller takes approximately 40 µs to complete a character write.  To fill two lines of a 20 character display would normally take 1.6 ms, most of which is spent waiting for the controller's busy flag to go inactive.  With ECROS, writing to the display stream takes place essentially without delay and the system spends no appreciable time waiting on the busy flag.  If the busy flag is set when ECROS tries to update the display, other work is scheduled and the display update is retried later.  As a result, the display of information does not interfere with time-critical tasks and overall CPU availability is increased.

Stream Operations

 


Last edited March 10, 2004.  All material Copyright © 2004 Graham Davies.