Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_debug.h File Reference

This file defines a Debug interface. More...

#include "nz_circularBuffer.h"
#include "nz_serDataPorts.h"

Go to the source code of this file.

Data Structures

union  DEBUG_ERROR_FLAGS
 

Macros

#define DEBUG_LEVEL_OFF   0
 
#define DEBUG_LEVEL_CRITICAL   1
 
#define DEBUG_LEVEL_ERROR   2
 
#define DEBUG_LEVEL_WARNING   3
 
#define DEBUG_LEVEL_INFO   4
 
#define DEBUG_LEVEL_FINE   5
 
#define DEBUG_TEMP_BUF_SIZE   128
 
#define DEBUG_TXBUF_SIZE   256
 
#define DEBUG_RXBUF_SIZE   32
 
#define debugInit()
 
#define debugAllInitDone()
 
#define debugService()
 
#define debugPutChar(c)
 
#define debugPutByte(b)
 
#define debugPutWord(w)
 
#define debugPutArray(pArr, size)
 
#define debugPutString(str)
 
#define debugPutHexByte(w)
 
#define debugPutHexWord(w)
 
#define debugPutHexLine(adr, buf, len)
 
#define debugWaitForSpace(required)
 
#define debugWaitTillAllSent()
 
#define debugIsTxBufEmpty()   (1)
 
#define DEBUG_PUT_STR(lvl, str)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutString(str);}}
 
#define DEBUG_PUT_CHAR(lvl, c)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutChar(c);}}
 
#define DEBUG_PUT_BYTE(lvl, c)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutByte(c);}}
 
#define DEBUG_PUT_WORD(lvl, w)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutWord(w);}}
 
#define DEBUG_PUT_HEXBYTE(lvl, b)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutHexByte(b);}}
 
#define DEBUG_PUT_HEXWORD(lvl, w)   {if (MY_DEBUG_LEVEL >= lvl) {debugPutHexWord(w);}}
 

Variables

char debugTempBuf [128]
 
DEBUG_ERROR_FLAGS debugErrorFlags
 

Detailed Description

This file defines a Debug interface.

Author
Modtronix Engineering
Compiler:
MPLAB XC16 Compiler

Description

This file defines a Debug interface. The implementation has to be done in a separate c file by creating instances of these functions. To use debugging in a project, the following must be done:

  • Copy Configuration section below to projdefs.h file.
  • In this "Configuration" section, uncomment disired lines, and change any default values as needed.
  • Add the nz_debug.c default implementation to the MPLAB project, or create a new implementation if the functionality should be changed.
  • The functions defined in this file can now be used in the project.

For additional information, see Debugging

Configuration

The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.

// *********************************************************************
// --------------- Debug Configuration (nz_debug.h) --------------------
// *********************************************************************
#define NZ_USBHID_DEBUG_ENABLE
//#define NZ_USBCDC_DEBUG_ENABLE
//#define NZ_UART1_DEBUG_ENABLE
//Size of Debug TX buffer, MUST BE power of 2 value! Increase size of this buffer if debug information
//is getting lost. This can be the case if the application writes debug information to the debug buffer
//faster than it can be outputted.
#define DEBUG_TXBUF_SIZE ( 256 ) //[-DEFAULT-]
//Size of Debug RX buffer, MUST BE power of 2 value! Ensure it is large enought to hold largest string
//written to debug port. For example, when using the USB port for debugging, text message are sent to
//the debug port from the @ref devtools_nzUsbTerminal.
#define DEBUG_RXBUF_SIZE ( 32 ) //[-DEFAULT-]
//Gives size of debugTempBuf. If commented, or not present, will be set to default of 128 bytes
//#define DEBUG_TEMP_BUF_SIZE ( 128 ) //[-DEFAULT-]
//Uncomment this line to disable all debugging!
//#define DEBUG_LEVEL_ALLOFF
//To enable debug configuration for additional modules, add line to each of the 3 sections below with name of new module. For example in first section, add "#define DEBUG_CONF_NEWMOD 0"
#if defined (DEBUG_LEVEL_ALLOFF)
#define DEBUG_CONF_MAIN ( 0 )
#define DEBUG_CONF_DEFAULT ( 0 )
#else
#if defined (RELEASE_BUILD)
#define DEBUG_CONF_MAIN DEBUG_LEVEL_ERROR
#define DEBUG_CONF_DEFAULT DEBUG_LEVEL_ERROF
#else
#define DEBUG_CONF_MAIN DEBUG_LEVEL_INFO
#define DEBUG_CONF_DEFAULT DEBUG_LEVEL_INFO
#endif
#endif

Software License Agreement

Software License Agreement

The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.

THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

File History

2010-11-16, David H. (DH):

  • Initial version

Macro Definition Documentation

#define DEBUG_PUT_BYTE (   lvl,
 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutByte(c);}}

Write BYTE in decimal format to debug output. For example, following will write "100" to debug output:
BYTE bVal = 100; DEBUG_PUT_BYTE(DEBUG_LEVEL_ERROR, bVal);

Parameters
lvlLevel above which this debug message is written to the debug port.
cByte to write to the debug port
#define DEBUG_PUT_CHAR (   lvl,
 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutChar(c);}}

Write a single character. For example:
DEBUG_PUT_CHAR(DEBUG_LEVEL_ERROR, 'm');

Parameters
lvlLevel above which this debug message is written to the debug port.
cNull terminated string to write to debug port
Examples:
ow_ds2482_async_debug/main.c.
#define DEBUG_PUT_HEXBYTE (   lvl,
 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutHexByte(b);}}

Write the given BYTE as a 2-character "ASCII Hexidecimal" formatted string to the debug output. For example, following will write "A2" to the debug output:
BYTE bVal = 0xa2; DEBUG_PUT_HEXBYTE(DEBUG_LEVEL_ERROR, bVal);

Parameters
lvlLevel above which this debug message is written to the debug port.
bByte to write to the debug port
Examples:
ow_ds2482_async_debug/main.c.
#define DEBUG_PUT_HEXWORD (   lvl,
 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutHexWord(w);}}

Write the given WORD as a 4-character "ASCII Hexidecimal" formatted string to the debug output. For example, following will write "01A2" to the debug output:
WORD wVal = 0x1a2; DEBUG_PUT_HEXWORD(DEBUG_LEVEL_ERROR, wVal);

Parameters
lvlLevel above which this debug message is written to the debug port.
wWord to write to the debug port
#define DEBUG_PUT_STR (   lvl,
  str 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutString(str);}}

Write string to debug output. For example:
DEBUG_PUT_STR(DEBUG_LEVEL_ERROR, "\nThis is a debug string");

Parameters
lvlLevel above which this debug message is written to the debug port.
strNull terminated string to write to debug port
Examples:
db66dev1_debug_demo/main.c, device_HID_debug_demo/main.c, i2c_debug_demo/main.c, ow_ds2482_async_debug/main.c, ow_ds2482_demo1_debug/main.c, pt66din6_debug_demo/main.c, rtc_debug_demo/main.c, template_project_debug/main.c, uart_debug_demo1/main.c, and uart_xc16_demo1/main.c.
#define DEBUG_PUT_WORD (   lvl,
 
)    {if (MY_DEBUG_LEVEL >= lvl) {debugPutWord(w);}}

Write WORD in decimal format to debug output. For example, following will write "100" to debug output:
WORD wVal = 100; DEBUG_PUT_WORD(DEBUG_LEVEL_ERROR, wVal);

Parameters
lvlLevel above which this debug message is written to the debug port.
wWord to write to the debug port
#define DEBUG_RXBUF_SIZE   32

Size of Debug RX buffer. Depending on circular buffer used for implementation, might HAVE TO BE a power of 2 value (if nz_circularBufferPwr2.c is used)! Ensure it is large enought to hold largest string written to debug port. For example, when using the USB port for debugging, text message are sent to the debug port from the Netcruzer USB Terminal.

#define DEBUG_TXBUF_SIZE   256

Size of Debug TX buffer. Depending on circular buffer used for implementation, might HAVE TO BE a power of 2 value (if nz_circularBufferPwr2.c is used)! Increase size of this buffer if debug information is getting lost. This can be the case if the application writes debug information to the debug buffer faster than it can send.

Variable Documentation

DEBUG_ERROR_FLAGS debugErrorFlags

Initialization Error Flags. Are flags for errors that occur during initialization before any debug message can be printed. After initialization, and debug system has been initialized, an attempt will be made to write an error message out onto the debug port.