Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
template_project_debug/main.c

===== Description =====

This is a blank project that can be used as a template for starting new projects. All it does is blink the System LED every second.

Additionally this demo also implements debugging via the USB port and the Netcruzer USB Terminal App. During the program various debug messages are written, which will be displayed on the "Netcruzer USB Terminal" (running on a PC connected to the target board's USB port). This demo also monitors the USB port for Debug messages send to us.
If "hi" is received, it replies with "Hello"
Use the "Netcruzer USB Terminal" App to send and receive USB Debug messages. It can be downloaded here: https://netcruzer.com/usbterminal/

===== Required Hardware =====

The project requires a SBC66 Netcruzer board with an USB Port (not USB Host).

===== Building Project =====

This project is located in the "src/demos/template/template_project_debug" folder of the Netcruzer Download. To compile for Netcruzer Board, open this project in MPLAB X, and select the "Project Configuration" for desired board. For example "SBC66ZL_R1" for the SBC66ZL Revision 1 board. For details click here

===== Programming Board =====

After compiling (build), the board can be programmed via the USB Bootloader or a PIC Programmer. USB Programming is simplified when using the SBC board together with a Prototype Board.

===== File History =====

2014-01-08, David H. (DH):

#define THIS_IS_MAIN_FILE //Uniquely identifies this as the file with the main application entry function main()
// Includes /////////////////////////////////////
#include "HardwareProfile.h" //Required for all Netcruzer projects
//Add debugging. DEBUG_CONF_MAIN macro sets debugging to desired level (defined in projdefs.h)
#if !defined(DEBUG_CONF_MAIN)
#define DEBUG_CONF_MAIN DEBUG_CONF_DEFAULT //Default Debug Level, disabled if DEBUG_LEVEL_ALLOFF defined, else DEBUG_LEVEL_ERROR
#endif
#define MY_DEBUG_LEVEL DEBUG_CONF_MAIN
#include "nz_debug.h"
// Variables ////////////////////////////////////
static WORD tmrFlashLed = 0; //Timer for flashing system LED
int main(void) {
//Default initialization. All ports inputs. All analog features disabled. Tick 1ms
DEBUG_PUT_STR(DEBUG_LEVEL_INFO, "\nThis is a test debug message from template_project_debug demo");
DIR_SYSLED = OUTPUT_PIN; //Set System LED port as outputs
//Main loop
while(1)
{
nzSysTaskDefault(); //Main netcruzer task, call in main loop.
//Flash system LED every 500ms
if (tick16TestTmr(tmrFlashLed)) {
tick16UpdateTmrMS(tmrFlashLed, 100); //Update timer to expire in 10ms again
LAT_SYSLED = !LAT_SYSLED; //Toggle System LED
}
}//end while
}
#if defined(HAS_NZ_DEBUGGING)
void debugService(void) {
//Check if a debug message was received
if (cbufHasWholePacket(CIRBUF_RX_DEBUG)) {
//'hi' - Reply with "Hello" on a new line
if (cbufPacketStrcmp(CIRBUF_RX_DEBUG, "hi") == 0) {
debugPutString("\nHello");
}
//Add custom debug message processing
else if (cbufPacketStrcmp(CIRBUF_RX_DEBUG, "...") == 0) {
//..... Do something
}
//Remove received packet. If it was not processed above, it is lost!
cbufRemovePacket(CIRBUF_RX_DEBUG);
}
}
#endif