forked from mfulz_github/qmk_firmware
Added return values to the CDC and MIDI class driver transmit functions.
This commit is contained in:
parent
5d4478b3b4
commit
09bedd6555
|
@ -121,46 +121,55 @@ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
|
|||
CDC_Device_Flush(CDCInterfaceInfo);
|
||||
}
|
||||
|
||||
void CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length)
|
||||
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length)
|
||||
{
|
||||
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
|
||||
return;
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
|
||||
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
|
||||
Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
|
||||
return Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
|
||||
}
|
||||
|
||||
void CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data)
|
||||
uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data)
|
||||
{
|
||||
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
|
||||
return;
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
|
||||
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
|
||||
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
uint8_t ErrorCode;
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
Endpoint_Write_Byte(Data);
|
||||
Endpoint_Write_Byte(Data);
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
}
|
||||
|
||||
void CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
|
||||
uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
|
||||
{
|
||||
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
|
||||
return;
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
|
||||
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
|
||||
|
||||
if (Endpoint_BytesInEndpoint())
|
||||
{
|
||||
uint8_t ErrorCode;
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
return Endpoint_WaitUntilReady();
|
||||
}
|
||||
|
||||
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
|
||||
|
@ -175,7 +184,7 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
|
|||
|
||||
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
|
||||
{
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
|
||||
return 0;
|
||||
|
||||
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
|
||||
|
@ -190,7 +199,7 @@ uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
|
|||
|
||||
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
|
||||
{
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
|
||||
return;
|
||||
|
||||
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber);
|
||||
|
|
|
@ -156,16 +156,20 @@
|
|||
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
|
||||
* \param[in] Data Pointer to the string to send to the host
|
||||
* \param[in] Length Size in bytes of the string to send to the host
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum
|
||||
*/
|
||||
void CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length);
|
||||
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length);
|
||||
|
||||
/** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the
|
||||
* byte is discarded.
|
||||
*
|
||||
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
|
||||
* \param[in] Data Byte of data to send to the host
|
||||
*
|
||||
* \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
|
||||
*/
|
||||
void CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data);
|
||||
uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data);
|
||||
|
||||
/** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
|
||||
*
|
||||
|
@ -188,8 +192,10 @@
|
|||
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
|
||||
*
|
||||
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
|
||||
*/
|
||||
void CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
|
||||
uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
|
||||
|
||||
/** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial
|
||||
* control lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist
|
||||
|
|
|
@ -70,18 +70,24 @@ void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
|
|||
|
||||
}
|
||||
|
||||
void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
|
||||
uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
|
||||
{
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
return ENDPOINT_RWSTREAM_NoError;
|
||||
|
||||
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber);
|
||||
|
||||
if (Endpoint_IsReadWriteAllowed());
|
||||
{
|
||||
Endpoint_Write_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK);
|
||||
uint8_t ErrorCode;
|
||||
|
||||
if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK)) != ENDPOINT_RWSTREAM_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
return ENDPOINT_RWSTREAM_NoError;
|
||||
}
|
||||
|
||||
bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
|
||||
|
|
|
@ -113,8 +113,10 @@
|
|||
*
|
||||
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
|
||||
* \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum
|
||||
*/
|
||||
void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event);
|
||||
uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event);
|
||||
|
||||
/** Receives a MIDI event packet from the host.
|
||||
*
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* HID interface within the device, not all HID interfaces
|
||||
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver
|
||||
* - Added explicit attribute masks to the device mode demos' descriptors
|
||||
* - Added return values to the CDC and MIDI class driver transmit functions
|
||||
*
|
||||
* <b>Fixed:</b>
|
||||
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
|
||||
|
|
|
@ -13,11 +13,6 @@
|
|||
*
|
||||
* <b>Targeted for This Release:</b>
|
||||
* - Host Mode Class Drivers
|
||||
* -# Make new host class drivers
|
||||
* -# Document new host class drivers
|
||||
* -# Convert Host mode demos to class drivers
|
||||
* -# Re-enable Host mode Class driver builds after completion
|
||||
* -# Update Host mode Class Driver demo .txt files
|
||||
* - Add overviews of each of the officially supported boards to the manual
|
||||
* - Add hub support to match Atmel's stack
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue