avrftdi: move logging defines to avrftdi_private.h

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@1156 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Hannes Weisbach 2013-05-02 11:07:37 +00:00
parent 068c6ca9cc
commit 1885f8ba84
3 changed files with 17 additions and 14 deletions

View File

@ -3,6 +3,8 @@
* avrftdi_private.h: Add libusb-1.0 include to fix include order in windows. * avrftdi_private.h: Add libusb-1.0 include to fix include order in windows.
* NEWS: Add notice avrftdi supporting TPI * NEWS: Add notice avrftdi supporting TPI
* avr.c: Fix avr_tpi_poll_nvmbsy() - poll read data instead of return code * avr.c: Fix avr_tpi_poll_nvmbsy() - poll read data instead of return code
* avrftdi_private.h, avrftdi.c: move logging #defines to from avrftdi.c to
avrftdi_private.h, so that they are available for avrftdi_tpi, too.
2013-04-30 Hannes Weisbach <hannes_weisbach@gmx.net> 2013-04-30 Hannes Weisbach <hannes_weisbach@gmx.net>

View File

@ -48,19 +48,6 @@
#include <libftdi1/ftdi.h> #include <libftdi1/ftdi.h>
enum { FTDI_SCK = 1, FTDI_MOSI, FTDI_MISO, FTDI_RESET }; enum { FTDI_SCK = 1, FTDI_MOSI, FTDI_MISO, FTDI_RESET };
enum { ERR, WARN, INFO, DEBUG, TRACE };
#define __log(lvl, fmt, ...) \
do { \
avrftdi_log(lvl, __func__, __LINE__, fmt, ##__VA_ARGS__); \
} while(0)
#define log_err(fmt, ...) __log(ERR, fmt, ##__VA_ARGS__)
#define log_warn(fmt, ...) __log(WARN, fmt, ##__VA_ARGS__)
#define log_info(fmt, ...) __log(INFO, fmt, ##__VA_ARGS__)
#define log_debug(fmt, ...) __log(DEBUG, fmt, ##__VA_ARGS__)
#define log_trace(fmt, ...) __log(TRACE, fmt, ##__VA_ARGS__)
#define FTDI_DEFAULT_MASK ( (1 << (FTDI_SCK - 1)) | (1 << (FTDI_MOSI - 1)) ) #define FTDI_DEFAULT_MASK ( (1 << (FTDI_SCK - 1)) | (1 << (FTDI_MOSI - 1)) )
@ -114,7 +101,7 @@ ftdi_pin_name(avrftdi_t* pdata, int pin)
* This function is the backend of the log_*-macros, but it can be used * This function is the backend of the log_*-macros, but it can be used
* directly. * directly.
*/ */
static void avrftdi_log(int level, const char * func, int line, void avrftdi_log(int level, const char * func, int line,
const char * fmt, ...) { const char * fmt, ...) {
static int skip_prefix = 0; static int skip_prefix = 0;
const char *p = fmt; const char *p = fmt;

View File

@ -11,6 +11,20 @@
#include "pgm.h" #include "pgm.h"
enum { ERR, WARN, INFO, DEBUG, TRACE };
#define __log(lvl, fmt, ...) \
do { \
avrftdi_log(lvl, __func__, __LINE__, fmt, ##__VA_ARGS__); \
} while(0)
#define log_err(fmt, ...) __log(ERR, fmt, ##__VA_ARGS__)
#define log_warn(fmt, ...) __log(WARN, fmt, ##__VA_ARGS__)
#define log_info(fmt, ...) __log(INFO, fmt, ##__VA_ARGS__)
#define log_debug(fmt, ...) __log(DEBUG, fmt, ##__VA_ARGS__)
#define log_trace(fmt, ...) __log(TRACE, fmt, ##__VA_ARGS__)
#define E(x, ftdi) \ #define E(x, ftdi) \
do { \ do { \
if ((x)) \ if ((x)) \