Com_usb_cdc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef __COM_USB_CDC_H
  2. #define __COM_USB_CDC_H
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #define COM_USB_TX_BUFFER_SIZE 2048
  6. #define COM_USB_RX_BUFFER_SIZE 512
  7. #define COM_USB_SEND_TASK_PRIORITY 3
  8. #define COM_USB_SEND_TASK_STACK 512
  9. /* 首次挂载宽限(ms):设备 CONFIGURED 后等待终端重连再发首包,
  10. 避免第一包掉进主机重枚举窗口被丢弃;酌情调大(如 1000) */
  11. #define COM_USB_BOOT_HOLDOFF_MS 500
  12. /* 日志行缓冲(字节): 须覆盖最长单行(SNAP行约123B); 超长截断 */
  13. #define COM_LOG_LINE_BUF_SIZE 192
  14. /* 打印总开关: 0=关闭全部打印(含遥测dump/故障打印, 关闭后零开销),1=开启 */
  15. #define COM_LOG_ENABLE 1
  16. /* 遥测开关: 0=关闭周期遥测dump(SNAP/BMC/CT/PTC/FAN/ACK),1=开启; 仅 COM_LOG_ENABLE=1 时有效 */
  17. #define COM_TELEMETRY_ENABLE 1
  18. /* 调试日志宏: 开->Com_log_printf(行原子), 关->空语句(零开销) */
  19. #if COM_LOG_ENABLE
  20. #define LOG_PRINTF(...) Com_log_printf(__VA_ARGS__)
  21. #else
  22. #define LOG_PRINTF(...) do { } while (0)
  23. #endif
  24. /* 遥测dump宏: 总开关与遥测开关同时为1才打印 */
  25. #if (COM_LOG_ENABLE && COM_TELEMETRY_ENABLE)
  26. #define TELEMETRY_PRINTF(...) Com_log_printf(__VA_ARGS__)
  27. #else
  28. #define TELEMETRY_PRINTF(...) do { } while (0)
  29. #endif
  30. int Com_log_printf(const char *fmt, ...);
  31. void Com_usb_cdc_init(void);
  32. void Com_usb_cdc_rx_handler(uint8_t *buf, uint32_t len);
  33. uint32_t Com_usb_cdc_read(uint8_t *buf, uint32_t len);
  34. uint32_t Com_usb_cdc_bytes_available(void);
  35. #endif /* __COM_USB_CDC_H */