/****************************************************************************** * File: MCU_USB.h * Component: MCU_USB * Description: Public interface for the MCU USB-CDC driver. * TX: SendByte, SendBuffer (both fire-and-forget via putchar_raw). * RX: background ring buffer drained lazily from the SDK's * stdio layer. ReadByte / bIsRxDataAvailable read from it. * * Layer: MCU (hardware abstraction) *****************************************************************************/ #ifndef MCU_USB_H #define MCU_USB_H #include "STD_TYPES.h" #define MCU_USB_WAIT_FOR_CONNECTION_DISABLED 0U #define MCU_USB_WAIT_FOR_CONNECTION_ENABLED 1U /* ------------------------------------------------------------------------ */ /* TX PUBLIC API */ /* ------------------------------------------------------------------------ */ STD_tenuResult MCU_USB_enuInit(void); STD_tenuResult MCU_USB_enuSendByte(u8 u8Byte); STD_tenuResult MCU_USB_enuSendBuffer(const u8 *pu8Data, u16 u16Length); /* ------------------------------------------------------------------------ */ /* RX PUBLIC API */ /* ------------------------------------------------------------------------ */ /** * @brief Read one byte from the USB RX ring buffer (non-blocking). * * Internally drains any pending bytes from the SDK's stdio layer into * the ring buffer before checking. Returns immediately. * * @param pu8Byte Pointer to store the received byte. * @return STD_OK byte read, * STD_NULL_POINTER_ERROR if pu8Byte is NULL, * STD_NOK if no data available. */ STD_tenuResult MCU_USB_enuReadByte(u8 *pu8Byte); /** * @brief Read up to u16MaxLength bytes from the USB RX ring buffer. * * @param pu8Data Output buffer. * @param u16MaxLength Maximum bytes to read. * @param pu16Read Actual bytes read. * @return STD_OK at least one byte read, * STD_NULL_POINTER_ERROR if pu8Data or pu16Read is NULL, * STD_NOK if no data available. */ STD_tenuResult MCU_USB_enuReadBuffer(u8 *pu8Data, u16 u16MaxLength, u16 *pu16Read); /** * @brief Check if USB RX data is available. * * Drains pending bytes from the SDK first, then checks the ring buffer. * * @return STD_TRUE if data available, STD_FALSE if empty. */ STD_tBool MCU_USB_bIsRxDataAvailable(void); #endif /* MCU_USB_H */