@@ -190,6 +190,8 @@ int | |||||
main(void) | main(void) | ||||
{ | { | ||||
debug_printf("starting...\n"); | |||||
BoardInitMcu(); | BoardInitMcu(); | ||||
Radio.Init(&revents); | Radio.Init(&revents); | ||||
@@ -200,6 +202,15 @@ main(void) | |||||
#if 1 | #if 1 | ||||
wait_for_vcp(); | wait_for_vcp(); | ||||
/* | |||||
* This is required to use w/ FreeBSD. Not sure why but if this | |||||
* delay isn't here, the code will hang waiting for the output to | |||||
* be sent, and it never does get sent. I believe this is because | |||||
* the packet to enable sending the data hasn't arrived yet, and | |||||
* this code fails to handle that case, and drops the data on the | |||||
* floor. | |||||
*/ | |||||
DelayMs(50); | |||||
usb_printf("starting...\r\n"); | usb_printf("starting...\r\n"); | ||||
#endif | #endif | ||||
@@ -26,13 +26,17 @@ | |||||
#include "misc.h" | #include "misc.h" | ||||
#include <stdarg.h> | |||||
#include <usbd_cdc_if.h> | #include <usbd_cdc_if.h> | ||||
#include <usb_device.h> | #include <usb_device.h> | ||||
static volatile uint32_t holding; | |||||
void | void | ||||
Error_Handler(void) | Error_Handler(void) | ||||
{ | { | ||||
/* XXX - handle error */ | |||||
debug_printf("error_handler\n"); | |||||
for (;;) holding++; | |||||
} | } | ||||
/* | /* | ||||
@@ -48,3 +52,31 @@ wait_for_vcp(void) | |||||
} | } | ||||
} | } | ||||
#if MEM_DEBUG_BUF | |||||
static char debugbuf[1024]; | |||||
static uint32_t debugpos; | |||||
void | |||||
debug_printf(const char *format, ...) | |||||
{ | |||||
char buf[128]; | |||||
char *pos; | |||||
va_list args; | |||||
uint32_t length; | |||||
uint32_t cpy; | |||||
va_start(args, format); | |||||
length = vsnprintf(buf, sizeof buf, format, args); | |||||
va_end(args); | |||||
pos = &buf[0]; | |||||
while (length) { | |||||
cpy = MIN(length, sizeof debugbuf - debugpos); | |||||
memcpy(&debugbuf[debugpos], pos, cpy); | |||||
debugpos += cpy; | |||||
pos += cpy; | |||||
length -= cpy; | |||||
} | |||||
} | |||||
#endif |
@@ -1,2 +1,13 @@ | |||||
void wait_for_vcp(void); | void wait_for_vcp(void); | ||||
void Error_Handler(void); | void Error_Handler(void); | ||||
#define MEM_DEBUG_BUF 0 | |||||
#if MEM_DEBUG_BUF | |||||
void debug_printf(const char *format, ...); | |||||
#else | |||||
static inline void | |||||
debug_printf(const char *format, ...) | |||||
{ | |||||
} | |||||
#endif |