#include "log.h" #include #include #include #include #if LOG_USB_ENABLE void log_init(bool wait) { usb_interface_t const *intf[] = { &usb_ff_bulk, NULL }; usb_open(intf, GINT_CALL_NULL); while(wait && !usb_is_open()) sleep(); } bool log_write(char const *str) { if(!usb_is_open()) return false; usb_fxlink_text(str, 0); return true; } bool log_printf(char const *fmt, ...) { if(!usb_is_open()) return false; va_list args; va_start(args, fmt); bool b = log_vprintf(fmt, args); va_end(args); return b; } bool log_vprintf(char const *fmt, va_list args) { if(!usb_is_open()) return false; static char str[256]; vsnprintf(str, sizeof str, fmt, args); log_write(str); return true; } #else void log_init(bool) { } bool log_write(char const *) { return false; } bool log_printf(char const *, ...) { return false; } bool log_vprintf(char const *, va_list) { return false; } #endif /* LOG_USB_ENABLE */