This cc.h requires you to declare a global Mutex called "SD1mtx", which you can do in your main file. It also assumes you are using SD1 for the debug console, which is easy enough to tailor to your needs.
cc.h (just the meat):
Code: Select all
#include <ch.h>
#include <inttypes.h>
#include <chprintf.h>
#include <hal.h>
... snip...
extern Mutex SD1mtx;
/* Define (sn)printf formatters for these lwIP types */
#define U16_F PRIu16
#define S16_F PRIu16
#define X16_F PRIx16
#define U32_F PRIu32
#define S32_F PRId32
#define X32_F PRIx32
#define PRINTFREPLACEMENT(...) chprintf((BaseSequentialStream*) &SD1, __VA_ARGS__)
#define LWIP_PLATFORM_DIAG(x) do { while(!chMtxTryLock(&SD1mtx)) {}; \
PRINTFREPLACEMENT x; chMtxUnlock(); } while (0)
#define LWIP_PLATFORM_ASSERT(x) do { chprintf((BaseSequentialStream*) &SD1, \
"Assertion \"%s\" failed at line %d in %s\n", \
x, __LINE__, __FILE__); chSysHalt(); } while(0)