add progmem compatible debug and info functions
This commit is contained in:
parent
710aa2d53a
commit
bb1367c243
@ -43,7 +43,7 @@
|
|||||||
#define USB_CRC_CHECK 0x01
|
#define USB_CRC_CHECK 0x01
|
||||||
|
|
||||||
#define TRANSFER_BUFFER_SIZE 0x200
|
#define TRANSFER_BUFFER_SIZE 0x200
|
||||||
|
#define FORMAT_BUFFER_LEN 0x0FF
|
||||||
#define HW_VERSION "2.6"
|
#define HW_VERSION "2.6"
|
||||||
#define SW_VERSION "1.0"
|
#define SW_VERSION "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
extern FILE uart_stdout;
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
@ -46,4 +46,23 @@ void debug(int level, char* format, ...) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_INFO
|
||||||
|
uint8_t buffer_debug[FORMAT_BUFFER_LEN];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||||
|
#else
|
||||||
|
void debug_P(int level, PGM_P format, ...) {
|
||||||
|
#ifdef NO_DEBUG
|
||||||
|
|
||||||
|
#else
|
||||||
|
va_list args;
|
||||||
|
if (!(debug_level & level))
|
||||||
|
return;
|
||||||
|
strlcpy_P(buffer_debug,format,FORMAT_BUFFER_LEN);
|
||||||
|
va_start(args, format);
|
||||||
|
vprintf(buffer_debug, args);
|
||||||
|
va_end(args);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#if defined(NO_DEBUG) && defined(__GNUC__)
|
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||||
@ -39,5 +39,17 @@ void debug(int level, char *format, ...);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||||
|
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||||
|
arguments. We use this extension here to preprocess pmesg away. */
|
||||||
|
#define debug_P(level, format, args...) ((void)0)
|
||||||
|
#else
|
||||||
|
void debug_P(int level, PGM_P format, ...);
|
||||||
|
/* print a message, if it is considered significant enough.
|
||||||
|
Adapted from [K&R2], p. 174 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* DEBUG_H */
|
#endif /* DEBUG_H */
|
||||||
|
|
||||||
|
|||||||
@ -20,9 +20,12 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -46,4 +49,26 @@ void info(char* format, ...) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NO_INFO
|
||||||
|
uint8_t buffer_info[FORMAT_BUFFER_LEN];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NO_INFO) && defined(__GNUC__)
|
||||||
|
|
||||||
|
#define info(format, args...) ((void)0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
void info_P(PGM_P format, ...) {
|
||||||
|
#ifdef NO_INFO
|
||||||
|
|
||||||
|
#else
|
||||||
|
strlcpy_P(buffer_info,format,FORMAT_BUFFER_LEN);
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
vprintf(buffer_info, args);
|
||||||
|
va_end(args);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#if defined(NO_INFO) && defined(__GNUC__)
|
#if defined(NO_INFO) && defined(__GNUC__)
|
||||||
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||||
@ -39,4 +39,15 @@ void info(char *format, ...);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(NO_INFO) && defined(__GNUC__)
|
||||||
|
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||||
|
arguments. We use this extension here to preprocess pmesg away. */
|
||||||
|
#define info_P(format, args...) ((void)0)
|
||||||
|
#else
|
||||||
|
void info_P(PGM_P format, ...);
|
||||||
|
/* print a message, if it is considered significant enough.
|
||||||
|
Adapted from [K&R2], p. 174 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user