Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Erik Strand
lufa
Commits
09bedd65
Commit
09bedd65
authored
Aug 16, 2009
by
Dean Camera
Browse files
Added return values to the CDC and MIDI class driver transmit functions.
parent
5d4478b3
Changes
6
Show whitespace changes
Inline
Side-by-side
LUFA/Drivers/USB/Class/Device/CDC.c
View file @
09bedd65
...
@@ -121,46 +121,55 @@ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
...
@@ -121,46 +121,55 @@ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
CDC_Device_Flush
(
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
))
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
!
(
CDCInterfaceInfo
->
State
.
LineEncoding
.
BaudRateBPS
))
return
;
return
ENDPOINT_READYWAIT_NoError
;
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataINEndpointNumber
);
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
))
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
!
(
CDCInterfaceInfo
->
State
.
LineEncoding
.
BaudRateBPS
))
return
;
return
ENDPOINT_READYWAIT_NoError
;
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataINEndpointNumber
);
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataINEndpointNumber
);
if
(
!
(
Endpoint_IsReadWriteAllowed
()))
if
(
!
(
Endpoint_IsReadWriteAllowed
()))
{
{
uint8_t
ErrorCode
;
Endpoint_ClearIN
();
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
))
if
((
USB_DeviceState
!=
DEVICE_STATE_Configured
)
||
!
(
CDCInterfaceInfo
->
State
.
LineEncoding
.
BaudRateBPS
))
return
;
return
ENDPOINT_READYWAIT_NoError
;
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataINEndpointNumber
);
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataINEndpointNumber
);
if
(
Endpoint_BytesInEndpoint
())
if
(
Endpoint_BytesInEndpoint
())
{
{
uint8_t
ErrorCode
;
Endpoint_ClearIN
();
Endpoint_ClearIN
();
Endpoint_WaitUntilReady
();
if
((
ErrorCode
=
Endpoint_WaitUntilReady
())
!=
ENDPOINT_READYWAIT_NoError
)
return
ErrorCode
;
}
}
Endpoint_ClearIN
();
Endpoint_ClearIN
();
Endpoint_WaitUntilReady
();
return
Endpoint_WaitUntilReady
();
}
}
uint16_t
CDC_Device_BytesReceived
(
USB_ClassInfo_CDC_Device_t
*
const
CDCInterfaceInfo
)
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
...
@@ -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
)
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
;
return
0
;
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataOUTEndpointNumber
);
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
DataOUTEndpointNumber
);
...
@@ -190,7 +199,7 @@ uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
...
@@ -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
)
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
;
return
;
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
NotificationEndpointNumber
);
Endpoint_SelectEndpoint
(
CDCInterfaceInfo
->
Config
.
NotificationEndpointNumber
);
...
...
LUFA/Drivers/USB/Class/Device/CDC.h
View file @
09bedd65
...
@@ -156,16 +156,20 @@
...
@@ -156,16 +156,20 @@
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \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] Data Pointer to the string to send to the host
* \param[in] Length Size in bytes of 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
/** 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.
* byte is discarded.
*
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \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
* \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.
/** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
*
*
...
@@ -188,8 +192,10 @@
...
@@ -188,8 +192,10 @@
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
/** 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.
* \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
/** 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
* control lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist
...
...
LUFA/Drivers/USB/Class/Device/MIDI.c
View file @
09bedd65
...
@@ -70,18 +70,24 @@ void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
...
@@ -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
)
if
(
USB_DeviceState
!=
DEVICE_STATE_Configured
)
return
;
return
ENDPOINT_RWSTREAM_NoError
;
Endpoint_SelectEndpoint
(
MIDIInterfaceInfo
->
Config
.
DataINEndpointNumber
);
Endpoint_SelectEndpoint
(
MIDIInterfaceInfo
->
Config
.
DataINEndpointNumber
);
if
(
Endpoint_IsReadWriteAllowed
());
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
();
Endpoint_ClearIN
();
}
}
return
ENDPOINT_RWSTREAM_NoError
;
}
}
bool
MIDI_Device_ReceiveEventPacket
(
USB_ClassInfo_MIDI_Device_t
*
const
MIDIInterfaceInfo
,
MIDI_EventPacket_t
*
const
Event
)
bool
MIDI_Device_ReceiveEventPacket
(
USB_ClassInfo_MIDI_Device_t
*
const
MIDIInterfaceInfo
,
MIDI_EventPacket_t
*
const
Event
)
...
...
LUFA/Drivers/USB/Class/Device/MIDI.h
View file @
09bedd65
...
@@ -113,8 +113,10 @@
...
@@ -113,8 +113,10 @@
*
*
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
* \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
* \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.
/** Receives a MIDI event packet from the host.
*
*
...
...
LUFA/ManPages/ChangeLog.txt
View file @
09bedd65
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
* HID interface within the device, not all HID interfaces
* HID interface within the device, not all HID interfaces
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver
* - Added explicit attribute masks to the device mode demos' descriptors
* - 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>
* <b>Fixed:</b>
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
...
...
LUFA/ManPages/FutureChanges.txt
View file @
09bedd65
...
@@ -13,11 +13,6 @@
...
@@ -13,11 +13,6 @@
*
*
* <b>Targeted for This Release:</b>
* <b>Targeted for This Release:</b>
* - Host Mode Class Drivers
* - 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 overviews of each of the officially supported boards to the manual
* - Add hub support to match Atmel's stack
* - Add hub support to match Atmel's stack
*
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment