diff --git a/common/usb_log.h b/common/usb_log.h index 94eedfb6..ca03af5b 100644 --- a/common/usb_log.h +++ b/common/usb_log.h @@ -75,12 +75,29 @@ #define USB_LOG_RAW(...) CONFIG_USB_PRINTF(__VA_ARGS__) -void usb_assert(const char *filename, int linenum); -#define USB_ASSERT(f) \ - do { \ - if (!(f)) \ - usb_assert(__FILE__, __LINE__); \ - } while (0) +#ifndef CONFIG_USB_ASSERT_DISABLE +#define USB_ASSERT(f) \ + do { \ + if (!(f)) { \ + USB_LOG_ERR("ASSERT FAIL [%s] @ %s:%d\r\n", #f, __FILE__, __LINE__); \ + while (1) { \ + } \ + } \ + } while (false) + +#define USB_ASSERT_MSG(f, fmt, ...) \ + do { \ + if (!(f)) { \ + USB_LOG_ERR("ASSERT FAIL [%s] @ %s:%d\r\n", #f, __FILE__, __LINE__); \ + USB_LOG_ERR(fmt "\r\n", ##__VA_ARGS__); \ + while (1) { \ + } \ + } \ + } while (false) +#else +#define USB_ASSERT(f) {} +#define USB_ASSERT_MSG(f, fmt, ...) {} +#endif #define ___is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') static inline void usb_hexdump(const void *ptr, uint32_t buflen)