X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=debug.c;h=ba8d3f16f6e45e39a2c6954b13c22fcfbafc61b6;hb=421e7d6da138dc122cf33791f3631156f73cccd7;hp=8dab8c707951cd1d777d3557f64c1947759ed3ba;hpb=c430e296be053c17d4d5f40c53378d401ab07a17;p=sigrok-firmware-fx2lafw.git diff --git a/debug.c b/debug.c index 8dab8c70..ba8d3f16 100644 --- a/debug.c +++ b/debug.c @@ -22,33 +22,40 @@ #include #include - #include #include #include - #include "debug.h" #define MESSAGE_LENGTH_MAX 64 -void debugf(const char *format, ...) { +void debugf(const char *format, ...) +{ va_list arg; int count; - // Format the string - va_start (arg, format); + /* Format the string. */ + va_start(arg, format); count = vsprintf(EP6FIFOBUF, format, arg); - va_end (arg); + va_end(arg); - // Zero out the rest of the buffer - while(count < MESSAGE_LENGTH_MAX) + /* Zero out the rest of the buffer. */ + while (count < MESSAGE_LENGTH_MAX) EP6FIFOBUF[count++] = '\0'; - // Send the buffer + /* Send the buffer. */ count = 32; EP6BCH = MSB(count); SYNCDELAY4; EP6BCL = LSB(count); + SYNCDELAY4; +} + +void _assert(char *expr, const char *filename, unsigned int linenumber) +{ + debugf("Assert(%s) failed at line %u in file %s.\n", + expr, linenumber, filename); + while (1); } #endif