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