projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5d4478b
)
Added return values to the CDC and MIDI class driver transmit functions.
author
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 16 Aug 2009 14:30:46 +0000
(14:30 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 16 Aug 2009 14:30:46 +0000
(14:30 +0000)
LUFA/Drivers/USB/Class/Device/CDC.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Class/Device/CDC.h
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Class/Device/MIDI.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Class/Device/MIDI.h
patch
|
blob
|
blame
|
history
LUFA/ManPages/ChangeLog.txt
patch
|
blob
|
blame
|
history
LUFA/ManPages/FutureChanges.txt
patch
|
blob
|
blame
|
history
diff --git
a/LUFA/Drivers/USB/Class/Device/CDC.c
b/LUFA/Drivers/USB/Class/Device/CDC.c
index
cbb9a85
..
003a6b3
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/
LUFA/Drivers/USB/Class/Device/CDC.c
@@
-121,46
+121,55
@@
void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
CDC_Device_Flush(CDCInterfaceInfo);
\r
}
\r
\r
CDC_Device_Flush(CDCInterfaceInfo);
\r
}
\r
\r
-
void
CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length)
\r
+
uint8_t
CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length)
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
- return;
\r
+ return
ENDPOINT_READYWAIT_NoError
;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
- Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
\r
+
return
Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
\r
}
\r
\r
}
\r
\r
-
void
CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data)
\r
+
uint8_t
CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data)
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
- return;
\r
+ return
ENDPOINT_READYWAIT_NoError
;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (!(Endpoint_IsReadWriteAllowed()))
\r
{
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (!(Endpoint_IsReadWriteAllowed()))
\r
{
\r
+ uint8_t ErrorCode;
\r
+
\r
Endpoint_ClearIN();
\r
Endpoint_ClearIN();
\r
- Endpoint_WaitUntilReady();
\r
+
\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
\r
+ return ErrorCode;
\r
}
\r
\r
}
\r
\r
- Endpoint_Write_Byte(Data);
\r
+ Endpoint_Write_Byte(Data);
\r
+ return ENDPOINT_READYWAIT_NoError;
\r
}
\r
\r
}
\r
\r
-
void
CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
+
uint8_t
CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
{
\r
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
\r
- return;
\r
+ return
ENDPOINT_READYWAIT_NoError
;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (Endpoint_BytesInEndpoint())
\r
{
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (Endpoint_BytesInEndpoint())
\r
{
\r
+ uint8_t ErrorCode;
\r
+
\r
Endpoint_ClearIN();
\r
Endpoint_ClearIN();
\r
- Endpoint_WaitUntilReady();
\r
+
\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
\r
+ return ErrorCode;
\r
}
\r
\r
Endpoint_ClearIN();
\r
}
\r
\r
Endpoint_ClearIN();
\r
- Endpoint_WaitUntilReady();
\r
+ return Endpoint_WaitUntilReady();
\r
}
\r
\r
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
}
\r
\r
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
@@
-175,7
+184,7
@@
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
\r
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
\r
{
\r
\r
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
\r
{
\r
- if (
USB_DeviceState != DEVICE_STATE_Configured
)
\r
+ if (
(USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)
)
\r
return 0;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
\r
return 0;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
\r
@@
-190,7
+199,7
@@
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
\r
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
{
\r
\r
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
\r
{
\r
- if (
USB_DeviceState != DEVICE_STATE_Configured
)
\r
+ if (
(USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)
)
\r
return;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber);
\r
return;
\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber);
\r
diff --git
a/LUFA/Drivers/USB/Class/Device/CDC.h
b/LUFA/Drivers/USB/Class/Device/CDC.h
index
a58bea2
..
99f8eb2
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Device/CDC.h
+++ b/
LUFA/Drivers/USB/Class/Device/CDC.h
@@
-156,16
+156,20
@@
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
* \param[in] Data Pointer to the string to send to the host
\r
* \param[in] Length Size in bytes of the string to send to the host
\r
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
* \param[in] Data Pointer to the string to send to the host
\r
* \param[in] Length Size in bytes of the string to send to the host
\r
+ *
\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum
\r
*/
\r
*/
\r
-
void
CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length);
\r
+
uint8_t
CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length);
\r
\r
/** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the
\r
* byte is discarded.
\r
*
\r
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
* \param[in] Data Byte of data to send to the host
\r
\r
/** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the
\r
* byte is discarded.
\r
*
\r
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
* \param[in] Data Byte of data to send to the host
\r
+ *
\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
\r
*/
\r
*/
\r
-
void
CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data);
\r
+
uint8_t
CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, const uint8_t Data);
\r
\r
/** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
\r
*
\r
\r
/** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
\r
*
\r
@@
-188,8
+192,10
@@
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
\r
*
\r
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
\r
*
\r
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
\r
+ *
\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
\r
*/
\r
*/
\r
-
void
CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
\r
+
uint8_t
CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
\r
\r
/** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial
\r
* control lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist
\r
\r
/** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial
\r
* control lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist
\r
diff --git
a/LUFA/Drivers/USB/Class/Device/MIDI.c
b/LUFA/Drivers/USB/Class/Device/MIDI.c
index
76583b1
..
79d9e74
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Device/MIDI.c
+++ b/
LUFA/Drivers/USB/Class/Device/MIDI.c
@@
-70,18
+70,24
@@
void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
\r
}
\r
\r
\r
}
\r
\r
-
void
MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
\r
+
uint8_t
MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
\r
{
\r
if (USB_DeviceState != DEVICE_STATE_Configured)
\r
{
\r
if (USB_DeviceState != DEVICE_STATE_Configured)
\r
- return;
\r
+ return
ENDPOINT_RWSTREAM_NoError
;
\r
\r
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (Endpoint_IsReadWriteAllowed());
\r
{
\r
\r
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber);
\r
\r
if (Endpoint_IsReadWriteAllowed());
\r
{
\r
- Endpoint_Write_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK);
\r
+ uint8_t ErrorCode;
\r
+
\r
+ if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK)) != ENDPOINT_RWSTREAM_NoError)
\r
+ return ErrorCode;
\r
+
\r
Endpoint_ClearIN();
\r
}
\r
Endpoint_ClearIN();
\r
}
\r
+
\r
+ return ENDPOINT_RWSTREAM_NoError;
\r
}
\r
\r
bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
\r
}
\r
\r
bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
\r
diff --git
a/LUFA/Drivers/USB/Class/Device/MIDI.h
b/LUFA/Drivers/USB/Class/Device/MIDI.h
index
c7e46ba
..
ce6778f
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Device/MIDI.h
+++ b/
LUFA/Drivers/USB/Class/Device/MIDI.h
@@
-113,8
+113,10
@@
*
\r
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
\r
* \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send
\r
*
\r
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
\r
* \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send
\r
+ *
\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum
\r
*/
\r
*/
\r
-
void
MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event);
\r
+
uint8_t
MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event);
\r
\r
/** Receives a MIDI event packet from the host.
\r
*
\r
\r
/** Receives a MIDI event packet from the host.
\r
*
\r
diff --git
a/LUFA/ManPages/ChangeLog.txt
b/LUFA/ManPages/ChangeLog.txt
index
11c21f0
..
8952337
100644
(file)
--- a/
LUFA/ManPages/ChangeLog.txt
+++ b/
LUFA/ManPages/ChangeLog.txt
@@
-19,6
+19,7
@@
* HID interface within the device, not all HID interfaces
\r
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver
\r
* - Added explicit attribute masks to the device mode demos' descriptors
\r
* HID interface within the device, not all HID interfaces
\r
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver
\r
* - Added explicit attribute masks to the device mode demos' descriptors
\r
+ * - Added return values to the CDC and MIDI class driver transmit functions
\r
*
\r
* <b>Fixed:</b>
\r
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
\r
*
\r
* <b>Fixed:</b>
\r
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
\r
diff --git
a/LUFA/ManPages/FutureChanges.txt
b/LUFA/ManPages/FutureChanges.txt
index
319e95d
..
daabcea
100644
(file)
--- a/
LUFA/ManPages/FutureChanges.txt
+++ b/
LUFA/ManPages/FutureChanges.txt
@@
-13,11
+13,6
@@
*
\r
* <b>Targeted for This Release:</b>
\r
* - Host Mode Class Drivers
\r
*
\r
* <b>Targeted for This Release:</b>
\r
* - Host Mode Class Drivers
\r
- * -# Make new host class drivers
\r
- * -# Document new host class drivers
\r
- * -# Convert Host mode demos to class drivers
\r
- * -# Re-enable Host mode Class driver builds after completion
\r
- * -# Update Host mode Class Driver demo .txt files
\r
* - Add overviews of each of the officially supported boards to the manual
\r
* - Add hub support to match Atmel's stack
\r
*
\r
* - Add overviews of each of the officially supported boards to the manual
\r
* - Add hub support to match Atmel's stack
\r
*
\r