{
Endpoint_ClearSETUP();
Endpoint_Read_Control_Stream_LE(&CDCInterfaceInfo->State.LineEncoding, sizeof(CDCInterfaceInfo->State.LineEncoding));
- EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo);
Endpoint_ClearIN();
+
+ EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo);
}
break;
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
Endpoint_ClearSETUP();
-
+ Endpoint_ClearStatusStage();
+
CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue;
- EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo);
- Endpoint_ClearStatusStage();
+ EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo);
}
break;
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
Endpoint_ClearSETUP();
-
- EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue);
-
Endpoint_ClearStatusStage();
+
+ EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue);
}
break;
}
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
- char* const Data,
+ const char* const Data,
const uint16_t Length)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
- uint8_t ReceivedByte = -1;
-
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
- return 0;
+ return -1;
+
+ int16_t ReceivedByte = -1;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
- if (!(Endpoint_IsOUTReceived()))
- return -1;
- else if (Endpoint_BytesInEndpoint())
- ReceivedByte = Endpoint_Read_Byte();
+ if (Endpoint_IsOUTReceived())
+ {
+ if (Endpoint_BytesInEndpoint())
+ ReceivedByte = Endpoint_Read_Byte();
- if (!(Endpoint_BytesInEndpoint()))
- Endpoint_ClearOUT();
+ if (!(Endpoint_BytesInEndpoint()))
+ Endpoint_ClearOUT();
+ }
return ReceivedByte;
}