/* flaneth - flash and ethernet - dartboard mod
* version 0.1 date 2008-11-09
* Copyright (C) 2007-2008 Stefan Schuermans <stefan@schuermans.info>
* Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
* a BlinkenArea project - http://www.blinkenarea.org/
*/
#ifndef INC_debug
#define INC_debug
#include <stdio.h>
#include <avr/pgmspace.h>
// debug configuration (what to debug)
#define DEBUG_INIT 0
#define DEBUG_EEPROM 0
#define DEBUG_CF 0
#define DEBUG_DART 1
#define DEBUG_RTL8019 0
#define DEBUG_ETHER 0
#define DEBUG_ARP 0
#define DEBUG_IP 0
#define DEBUG_ICMP 0
#define DEBUG_UDP 0
#define DEBUG_DHCP 0
#define DEBUG_TCP 0
#define DEBUG_HTTP 1
// debug version of printf
#ifdef DEBUG
#define debug_printf( fmt, arg... ) \
{ \
static const PROGMEM char fmt_pgm[] = fmt"\r\n"; \
char fmt_buf[sizeof( fmt_pgm )]; \
for( int i = 0; i < sizeof( fmt_pgm ); i++ ) \
fmt_buf[i] = (char)pgm_read_byte_near( (uint16_t)fmt_pgm + i ); \
printf( fmt_buf, ##arg ); \
}
#else
#define debug_printf( fmt, arg... ) { }
#endif
// specialized debug versions of printf
#define debug_specialized_printf( enabled, fmt, arg... ) { if( enabled ) debug_printf( fmt, ##arg ); }
#define debug_init_printf( fmt, arg... ) debug_specialized_printf( DEBUG_INIT, "init: "fmt, ##arg )
#define debug_eeprom_printf( fmt, arg... ) debug_specialized_printf( DEBUG_EEPROM, "eeprom: "fmt, ##arg )
#define debug_cf_printf( fmt, arg... ) debug_specialized_printf( DEBUG_CF, "cf: "fmt, ##arg )
#define debug_dart_printf( fmt, arg... ) debug_specialized_printf( DEBUG_DART, "dart: "fmt, ##arg )
#define debug_rtl8019_printf( fmt, arg... ) debug_specialized_printf( DEBUG_RTL8019, "rtl8019: "fmt, ##arg )
#define debug_ether_printf( fmt, arg... ) debug_specialized_printf( DEBUG_ETHER, "ether: "fmt, ##arg )
#define debug_arp_printf( fmt, arg... ) debug_specialized_printf( DEBUG_ARP, "arp: "fmt, ##arg )