Nut/OS  5.0.5
API Reference
Debug Device

Debug output driver for ATmega On-Chip UART. More...

Collaboration diagram for Debug Device:

Variables

NUTDEVICE devDebug0
 Debug device 0 information structure.
NUTDEVICE devDebug1
 UART 1 Device information structure.

Detailed Description

Debug output driver for ATmega On-Chip UART.

This stream device driver writes data to the internal UART of the ATmega128/103 chip. The output is unbuffered and uses polling. Therefore it can be used for standard I/O output even within interrupt routines.


Variable Documentation

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '0', 0, 0, 0, 0},      
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    DebugInit,                  
    DebugIOCtl,                 



    NULL,

    DebugWrite,
    DebugWrite_P,
    DebugOpen,
    DebugClose,



    NULL

}

Debug device 0 information structure.

Debug device 0 information structure.

Usually, the device structure is the only public symbol that may be referenced by the application code using

 #include <dev/debug.h>

 {
     ...
     NutRegisterDevice(&devDebug0, 0, 0);
     ...
 }

If not referenced, the driver code (and this structure) will not be included in the final binary.

The name of the structure may differ among platforms. Portable applications should avoid it and instead make use of dev/board.h.

 #include <dev/board.h>

 {
     ...
     NutRegisterDevice(&DEV_DEBUG, 0, 0);
     ...
 }

While output is supported by default, input may be not. If input is required, applications may replace DEV_DEBUG by DEV_CONSOLE. In this case the debug driver is selected only, if it has input capability (see NUT_DEV_DEBUG_READ). Otherwise an interrupt driven UART driver will be used.

Note, that this polling driver has certain advantages

  • very low memory usage
  • allows stdio output functions in interrupt context
  • allows stdio output functions in early system stage
  • no internal buffering, output is synchronous
  • atomic output with multiple threads

but also some disadvantages

  • concurrent threads are blocked during output
  • most or all UART settings are hard coded
  • may not work with non-ASCII (binary) data
  • often only output is supported, not input
  • only one instance (open) is allowed

When used with Harvard architectures, additional functions may be offered to access data in program space.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '1', 0, 0, 0, 0},      
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    DebugInit,                  
    DebugIOCtl,                 
    0,
    DebugWrite,
    DebugWrite_P,
    DebugOpen,
    DebugClose,
    0
}

UART 1 Device information structure.

Debug device 1 information structure.