Embedded Systems Building Blocks, Second Edition

11.06: Buffered Serial I/O Module (COMMBGND )

11.06 Buffered Serial I/O Module ( COMMBGND)

The COMMBGND module allows data received from and sent to a UART to be buffered. Specifically, you would use the COMMBGND module if you write an application destined for a foreground/background environment. The COMMBGND module is designed to work in conjunction with the COMM_PC module described in the previous section. COMMBGND allows you to do full-duplex communication on either serial port (concurrently). The source code for the COMMBGND module is found in the \SOFTWARE\BLOCKS\COMM\SOURCE directory and specifically, in COMMBGND.C (Listing 11.4) and COMMBGND.H (Listing 11.5).

Warning

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

As a convention, all functions and variables related to the COMMBGND module start with Comm while all #define constants start with COMM_.

Each serial port is assigned two ring buffers: one for byte reception and another for byte transmission. Both ring buffers are stored in a structure called COMM_RING_BUF (see COMMBGND.C on page 473). Each ring buffer consists of four elements:

  1. storage for data (an array of INT8Us)

  2. a counter containing the number of bytes in the ring buffer

  3. a pointer where the next byte will be placed in the ring buffer

  4. a pointer where the next byte will be extracted from the ring buffer

Figure 11.20 shows a flow diagram for data reception...

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: Digital Signal Processors (DSP)
Finish!
Privacy Policy

This is embarrasing...

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