spark/core-common-lib — pull request #5 by davids5 (2014-01-31 22:07:23+00:00)
Title: Fixes Compile warnings and Adds Panic and Compile time and runtime controlled Debugging

This adds Debug logging and Panic features.

```cpp
/*
* This module supports runtime and compile time message filtering.
*
* For a message be compiled in the message type has to be >= to then the LOG_LEVEL_AT_COMPILE_TIME
* For a message to be output the message type has to be >= then the LOG_LEVEL_AT_RUN_TIME
* and finally the D_XXXXX bit has to be set in the COMPILE_TIME_LOG_FILTER the sets the run_time_log_fillter.
*
* This module assumes one of two #defines RELEASE_BUILD or DEBUG_BUILD exist
* Then the LOG_LEVEL_AT_COMPILE_TIME and LOG_LEVEL_AT_RUN_TIME are set based on RELEASE or DEBUG
* For a release build
* LOG_LEVEL_AT_COMPILE_TIME = WARN_LEVEL
* LOG_LEVEL_AT_RUN_TIME = WARN_LEVEL
* For a debug build:
* LOG_LEVEL_AT_COMPILE_TIME = LOG_LEVEL
* LOG_LEVEL_AT_RUN_TIME = LOG_LEVEL
* The API
* LOG(fmt,...)
* DEBUG(fmt,...)
* WARN(fmt,...)
* ERROR(fmt,...)
* PANIC(code,fmt,...)
*/
```
Usage:
```cpp
define DEBUG_BUILD=y on make command line and add the following to your Application.cpp

void debug_output_(const char *p)
{
static boolean once = false;
if (!once)
{
once = true;
Serial1.begin(115200);
}

Serial1.print(p);
}
The API looks like

LOG("Want %d more cores",count);
WARN("Running %s on cores only %d more left",,"Low",count);
DEBUG("connection closed %d",retValue);
ERROR("Flash write Failed @0x%0x",badd_address);
PANIC(HardFault,"Hit Hardfault");
```
Panic codes are defined in panic_codes.h

PANIC(code,[text])
```cpp
// Add a panic code def_panic_codes(_class, led, code)
// the panic module will send SOS followed by 900 ms delay
// followed by 300 blinks of the value of code
/// ...---... code ...---...

This is added to the while(1) loop in the code to help identify a Fault or Fault condition
Currently used

def_panic_codes(Faults,RGB_COLOR_RED,HardFault) 1 blink
def_panic_codes(Faults,RGB_COLOR_RED,NMIFault) 2 etc....
def_panic_codes(Faults,RGB_COLOR_RED,MemManage)
def_panic_codes(Faults,RGB_COLOR_RED,BusFault)
def_panic_codes(Faults,RGB_COLOR_RED,UsageFault)

def_panic_codes(Cloud,RGB_COLOR_RED,InvalidLenth)

def_panic_codes(System,RGB_COLOR_RED,Exit)
def_panic_codes(System,RGB_COLOR_RED,OutOfHeap)

```