This module provides a lightweight printf function that can be enabled or disabled via configuration macros. Code can be declared to be within a “debug unit” (usually a module) and prints can be enabled/disabled per debug unit.
To use this module, include module_logging in the application’sUSED_MODULES list and include the debug_print.h header file.
void debug_printf(char fmt, ...)
A limited functionality version of printf that is low memory.
This function works like C-standard printf except that it only accepts d, x, s, u and c format specifiers with no conversions. The function uses the functions from print.h to do the underlying printing.
Unlike printf this function has no return value.
Whether the function does any output can be controlled via defines such as DEBUG_PRINT_ENABLE or DEBUG_PRINT_ENABLE_[debug unit name] in the application’s debug_conf.h
A source file can be added to a debug unit by defining the DEBUG_UNIT macro before inclusion of debug_print.h. For example:
#define DEBUG_UNIT ETHERNET_MODULE #include "debug_print.h"
To include all source files in a module in a particular debug unit, it is convenient to do it in the module_build_info file of the module e.g.:
MODULE_XCC_FLAGS = $(XCC_FLAGS) -DDEBUG_UNIT=ETHERNET_MODULE
If no DEBUG_UNIT is defined then the default debug unit is APPLICATION.
By default, debug printing is turned off. To enable printing you need to include a file called debug_conf.h in your application. Within this file you can set the following defines:
Setting this define to 1 or 0 will control whether debug prints are output.
- DEBUG_PRINT_ENABLE_[debug unit]
Enabling this define will cause printing to be enabled for a specific debug unit. If set to 1, this will override the default set byDEBUG_PRINT_ENABLE.
- DEBUG_PRINT_DISABLE_[debug unit]
Enabling this define will cause printing to be disabled for a specific debug unit. If set to 1, this will override the default set byDEBUG_PRINT_ENABLE.