
AN758
8 Rev. 0.1
5.1.2. CDC_Device_ConfigureEndpoints
USB CDC device endpoint configuration.
Syntax
bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const
CDCInterfaceInfo)
Parameters
CDCInterfaceInfo: Pointer to CDC Class state structure
Return Value
True: if configuration success
False: if configuration failure
Description
This functions set data in/out endpoint as bulk type, and set notification endpoint as interrupt type.
Example
bool ConfigSuccess = true;
ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface);
5.1.3. CDC_Device_SendData
USB CDC sends data to USB IN FIFO.
Syntax
uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInter-faceInfo,
const char* const Buffer,const uint16_t Length)
Parameters
CDCInterfaceInfo: Pointer to CDC Class state structure
Buffer: Pointer to data buffer
Length: Transmit length
Return Value
Error code: definition can be found in EndpointStream.h
ENDPOINT_RWSTREAM_NoError
ENDPOINT_RWSTREAM_EndpointStalled
ENDPOINT_RWSTREAM_DeviceDisconnected
ENDPOINT_RWSTREAM_BusSuspended
ENDPOINT_RWSTREAM_Timeout
ENDPOINT_RWSTREAM_IncompleteTransfer
Description
This function sends data to USB IN FIFO. Transmit data size specified in Length.
Note: Endpoint_ClearIN() must be called to send data to USB host, otherwise, the data will keep in USB device FIFO.
Example
uint32_t recv_count;
recv_count = uart_get_data(in_buff);
if(recv_count)
{
CDC_Device_SendData(&VirtualSerial_CDC_Interface, (char *)in_buff, recv_count);
Endpoint_ClearIN();
}
Comentários a estes Manuais