Embedded Systems Building Blocks, Second Edition

11.07: Buffered Serial I/O Module (COMMRTOS )

11.07 Buffered Serial I/O Module ( COMMRTOS)

The COMMRTOS module works just like the COMMBGND module except that the COMMRTOS module uses semaphores to indicate when bytes are inserted into the buffer. Semaphores allow your task-level code to process incoming and outgoing data as quickly as possible. Furthermore, your application code no longer needs to poll the receive buffer to see if bytes are available. Similarly, your application code also will be suspended if the transmit buffer is full. This also prevents your code from having to check that the transmit buffer is not full when you are sending data on a serial port.

The source code for the COMMRTOS module is found in the \SOFTWARE\BLOCKS\COMM\SOURCE directory and, specifically, in COMMRTOS.C (Listing 11.6) and COMMRTOS.H (Listing 11.7). As a convention, all functions and variables related to the COMMRTOS module start with Comm while all #define constants start with COMM_.

Warning

In the previous edition of this book, COMMBGND was called COMMBUF2. The file COMMBUF2.C is now COMMRTOS.C and, COMMBUF2.H is now COMMRTOS.H.

Along with the two ring buffers, each serial port now has two semaphores: one to signal that a byte was received and the other to signal that a byte was sent. The COMM_RING_BUF structure (see COMMRTOS.C on page ) is identical to the COMMBGND structure except for the addition of the semaphores.


Figure 11.22: Buffered serial I/O,...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: M-Modules
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.