Add return codes to the CDC Host Class driver String/Byte transmission functions.

pull/1469/head
Dean Camera 15 years ago
parent cf2776531c
commit dac7b046fd

@ -256,33 +256,41 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa
return USB_Host_SendControlRequest(NULL);
}
void CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)
uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return;
uint8_t ErrorCode;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
Pipe_Freeze();
return ErrorCode;
}
void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))
return;
uint8_t ErrorCode = PIPE_READYWAIT_NoError;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_ClearOUT();
Pipe_WaitUntilReady();
ErrorCode = Pipe_WaitUntilReady();
}
Pipe_Write_Byte(Data);
Pipe_Freeze();
return ErrorCode;
}
uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)

@ -163,16 +163,20 @@
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state
* \param[in] Data Pointer to the string to send to the device
* \param[in] Length Size in bytes of the string to send to the device
*
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum
*/
void CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2);
uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2);
/** Sends a given byte to the attached USB device, 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 host configuration and state
* \param[in] Data Byte of data to send to the device
*
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum
*/
void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
/** Determines the number of bytes received by the CDC interface from the device, waiting to be read.
*

@ -51,9 +51,10 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
while (ReportSize)
{
uint8_t HIDReportItem = *(ReportData++);
uint8_t HIDReportItem = *ReportData;
uint32_t ReportItemData = 0;
ReportData++;
ReportSize--;
switch (HIDReportItem & DATA_SIZE_MASK)

@ -79,11 +79,11 @@
#if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__)
/** Constant indicating the maximum stack depth of the state table. A larger state table
* allows for more PUSH/POP report items to be nested, but consumes more memory. By default
* this is set to 3 levels (allowing for two PUSHes to be nested) but this can be overridden by
* this is set to 2 levels (allowing non-nested PUSH items) but this can be overridden by
* defining HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the
* define to the compiler using the -D compiler switch.
*/
#define HID_STATETABLE_STACK_DEPTH 3
#define HID_STATETABLE_STACK_DEPTH 2
#endif
#if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)
@ -134,7 +134,7 @@
HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */
HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */
HID_PARSE_InsufficientReportItems = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */
HID_PARSE_UnexpectedEndCollection = 4, /**< END COLLECTION found without matching COLLECTION item. */
HID_PARSE_UnexpectedEndCollection = 4, /**< An END COLLECTION item found without matching COLLECTION item. */
HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */
HID_PARSE_UsageStackOverflow = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */
};

@ -16,14 +16,14 @@
* - Added new Endpoint_SetEndpointDirection() macro for bi-directional endpoints
* - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer
* - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use
* - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data
* - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set
*
* <b>Changed:</b>
* - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested
* 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
* - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set
* - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size
* - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability
* - Added new "Common" section to the class drivers, to hold all mode-independant definitions for clarity

@ -12,7 +12,7 @@
* or post your suggestion as an enhancement request to the project bug tracker.
*
* <b>Targeted for This Release:</b>
* - Finish HID and Still Image Host Mode Class Drivers, add demo summaries, add return codes to all relevant functions
* - Finish HID and Still Image Host Mode Class Drivers, add demo summaries
* - Add overviews of each of the officially supported boards to the manual
* - Re-add in flip, flip-ee, dfu and dfu-ee targets to project makefiles
* - Add in new invalid event hook check targets to project makefiles

Loading…
Cancel
Save