Fix a few problems with the lib linking with debug on.

This commit is contained in:
Andrew J. Kroll 2013-03-30 11:55:01 -04:00
parent 5ec8889fa3
commit a3dc91cc43
7 changed files with 26 additions and 31 deletions

6
Usb.h
View file

@ -18,10 +18,8 @@ e-mail : support@circuitsathome.com
#ifndef _usb_h_ #ifndef _usb_h_
#define _usb_h_ #define _usb_h_
//#define BOARD_BLACK_WIDDOW //#define BOARD_BLACK_WIDDOW
#define USB_METHODS_INLINE #define USB_METHODS_INLINE
#include <inttypes.h> #include <inttypes.h>
@ -39,12 +37,8 @@ e-mail : support@circuitsathome.com
#else #else
#include <WProgram.h> #include <WProgram.h>
#endif #endif
#include "printhex.h"
#include "hexdump.h"
#include "message.h" #include "message.h"
extern int UsbDEBUGlvl;
/* shield pins. First parameter - SS pin, second parameter - INT pin */ /* shield pins. First parameter - SS pin, second parameter - INT pin */
#ifdef BOARD_BLACK_WIDDOW #ifdef BOARD_BLACK_WIDDOW

View file

@ -20,8 +20,6 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "printhex.h"
#include "hexdump.h"
#include "message.h" #include "message.h"
#include "parsetools.h" #include "parsetools.h"

View file

@ -19,7 +19,6 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "printhex.h"
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
class HexDumper : public BASE_CLASS { class HexDumper : public BASE_CLASS {
@ -41,19 +40,23 @@ public:
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
#ifdef DEBUG
if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
if(!byteCount) { if(!byteCount) {
SerialPrintHex<OFFSET_TYPE > (byteTotal); PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
Serial.print(": "); Notify(PSTR(": "), 0x80);
} }
SerialPrintHex<uint8_t > (pbuf[j]); PrintHex<uint8_t > (pbuf[j], 0x80);
Serial.print(" "); Notify(PSTR(" "), 0x80);
if(byteCount == 15) { if(byteCount == 15) {
Serial.println(""); Notify(PSTR("\r\n"), 0x80);
byteCount = 0xFF; byteCount = 0xFF;
} }
} }
}
#endif
} }
#endif // __HEXDUMP_H__ #endif // __HEXDUMP_H__

View file

@ -1,5 +1,5 @@
#include "message.h"
#include "masstorage.h" #include "masstorage.h"
const uint8_t BulkOnly::epDataInIndex = 1; const uint8_t BulkOnly::epDataInIndex = 1;
const uint8_t BulkOnly::epDataOutIndex = 2; const uint8_t BulkOnly::epDataOutIndex = 2;
const uint8_t BulkOnly::epInterruptInIndex = 3; const uint8_t BulkOnly::epInterruptInIndex = 3;

View file

@ -1,6 +1,8 @@
#if !defined(__MASSTORAGE_H__) #if !defined(__MASSTORAGE_H__)
#define __MASSTORAGE_H__ #define __MASSTORAGE_H__
#define DEBUG
#include <inttypes.h> #include <inttypes.h>
#include "avrpins.h" #include "avrpins.h"
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
@ -15,10 +17,6 @@
#include <WProgram.h> #include <WProgram.h>
#endif #endif
#include "printhex.h"
#include "hexdump.h"
#include "message.h"
#include <confdescparser.h> #include <confdescparser.h>
#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) #define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))

View file

@ -14,6 +14,8 @@ Circuits At Home, LTD
Web : http://www.circuitsathome.com Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com e-mail : support@circuitsathome.com
*/ */
#define DEBUG
#include "message.h" #include "message.h"
// 0x80 is the default (i.e. trace) to turn off set this global to something lower. // 0x80 is the default (i.e. trace) to turn off set this global to something lower.
// this allows for 126 other debugging levels. // this allows for 126 other debugging levels.
@ -46,7 +48,6 @@ void NotifyStr(char const * msg, int lvl) {
while (c = *msg++) Notifyc(c, lvl); while (c = *msg++) Notifyc(c, lvl);
} }
#ifdef DEBUG
void NotifyFailGetDevDescr(void) { void NotifyFailGetDevDescr(void) {
Notify(PSTR("\r\ngetDevDescr"), 0x80); Notify(PSTR("\r\ngetDevDescr"), 0x80);
} }
@ -58,7 +59,7 @@ void NotifyFailGetConfDescr(void) {
Notify(PSTR("\r\ngetConf"), 0x80); Notify(PSTR("\r\ngetConf"), 0x80);
} }
void NotifyFailSetConf(void) { void NotifyFailSetConfDescr(void) {
Notify(PSTR("\r\nsetConf"), 0x80); Notify(PSTR("\r\nsetConf"), 0x80);
} }
@ -73,4 +74,3 @@ void NotifyFail(uint8_t rcode) {
PrintHex<uint8_t > (rcode, 0x80); PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }
#endif

View file

@ -20,6 +20,10 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
extern int UsbDEBUGlvl;
#include "printhex.h"
void Notify(char const * msg, int lvl); void Notify(char const * msg, int lvl);
void NotifyStr(char const * msg, int lvl); void NotifyStr(char const * msg, int lvl);
#ifdef DEBUG #ifdef DEBUG
@ -37,9 +41,6 @@ void NotifyFail(uint8_t rcode);
#define NotifyFailUnknownDevice(VID, PID) #define NotifyFailUnknownDevice(VID, PID)
#define NotifyFail(rcode) #define NotifyFail(rcode)
#endif #endif
extern int UsbDEBUGlvl;
#include "printhex.h"
template <class ERROR_TYPE> template <class ERROR_TYPE>
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
@ -49,5 +50,6 @@ void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }
#include "hexdump.h"
#endif // __MESSAGE_H__ #endif // __MESSAGE_H__