diff options
| author | sakumisu <[email protected]> | 2025-04-29 18:01:35 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-04-29 18:01:35 +0800 |
| commit | 644ac2b37f13218042e6c4040de3537d3db2e05c (patch) | |
| tree | 166cc58ecd867cc1f7bd1e88dcf206475fb15b78 | |
| parent | d3de69ae389d3825e435a3692752affc5226efdf (diff) | |
update(common/usb_log): update USB_ASSERT
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | common/usb_log.h | 29 |
1 files changed, 23 insertions, 6 deletions
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) |
