Add return codes to the CDC Host Class driver String/Byte transmission functions.
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 31 Aug 2009 13:58:03 +0000 (13:58 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 31 Aug 2009 13:58:03 +0000 (13:58 +0000)
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/Drivers/USB/Class/Host/HIDParser.c
LUFA/Drivers/USB/Class/Host/HIDParser.h
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/FutureChanges.txt

index e75bee2..cb70808 100644 (file)
@@ -256,21 +256,27 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa
        return USB_Host_SendControlRequest(NULL);\r
 }\r
 \r
-void CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)\r
+uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length)\r
 {\r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
          return;\r
 \r
+       uint8_t ErrorCode;\r
+\r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
-       Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK); \r
+       ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);\r
        Pipe_Freeze();\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
-void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)\r
+uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)\r
 {\r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.Active))\r
          return;\r
+         \r
+       uint8_t ErrorCode = PIPE_READYWAIT_NoError;\r
 \r
        Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
@@ -278,11 +284,13 @@ void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data)
        if (!(Pipe_IsReadWriteAllowed()))\r
        {\r
                Pipe_ClearOUT();\r
-               Pipe_WaitUntilReady();\r
+               ErrorCode = Pipe_WaitUntilReady();\r
        }\r
 \r
        Pipe_Write_Byte(Data);  \r
        Pipe_Freeze();\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
 uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo)\r
index f7dc088..99fbdbb 100644 (file)
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *  \param[in] Data  Pointer to the string to send to the device\r
                         *  \param[in] Length  Size in bytes of the string to send to the device\r
+                        *\r
+                        *  \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum\r
                         */\r
-                       void CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2);\r
+                       uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2);\r
                        \r
                        /** Sends a given byte to the attached USB device, 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 host configuration and state\r
                         *  \param[in] Data  Byte of data to send to the device\r
+                        *\r
+                        *  \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum\r
                         */\r
-                       void CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+                       uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                        /** Determines the number of bytes received by the CDC interface from the device, waiting to be read.\r
                         *\r
index fdce8e5..3fbad65 100644 (file)
@@ -51,9 +51,10 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
 \r
        while (ReportSize)\r
        {\r
-               uint8_t  HIDReportItem  = *(ReportData++);\r
+               uint8_t  HIDReportItem  = *ReportData;\r
                uint32_t ReportItemData = 0;\r
                \r
+               ReportData++;\r
                ReportSize--;\r
                \r
                switch (HIDReportItem & DATA_SIZE_MASK)\r
index 942fe11..ec7ff53 100644 (file)
                #if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__)\r
                        /** Constant indicating the maximum stack depth of the state table. A larger state table\r
                         *  allows for more PUSH/POP report items to be nested, but consumes more memory. By default\r
-                        *  this is set to 3 levels (allowing for two PUSHes to be nested) but this can be overridden by\r
+                        *  this is set to 2 levels (allowing non-nested PUSH items) but this can be overridden by\r
                         *  defining HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the\r
                         *  define to the compiler using the -D compiler switch.\r
                         */\r
-                       #define HID_STATETABLE_STACK_DEPTH    3\r
+                       #define HID_STATETABLE_STACK_DEPTH    2\r
                #endif\r
                \r
                #if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)\r
                                HID_PARSE_HIDStackOverflow            = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */ \r
                                HID_PARSE_HIDStackUnderflow           = 2, /**< A POP was found when the state table stack was empty. */\r
                                HID_PARSE_InsufficientReportItems     = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */\r
-                               HID_PARSE_UnexpectedEndCollection     = 4, /**< END COLLECTION found without matching COLLECTION item. */\r
+                               HID_PARSE_UnexpectedEndCollection     = 4, /**< An END COLLECTION item found without matching COLLECTION item. */\r
                                HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */\r
                                HID_PARSE_UsageStackOverflow          = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */\r
                        };\r
index 37cf850..14dab76 100644 (file)
   *  - Added new Endpoint_SetEndpointDirection() macro for bi-directional endpoints\r
   *  - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer\r
   *  - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use\r
+  *  - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data\r
+  *  - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set\r
   *  \r
   *  <b>Changed:</b>\r
   *  - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested\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
-  *  - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set\r
   *  - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size\r
   *  - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability\r
   *  - Added new "Common" section to the class drivers, to hold all mode-independant definitions for clarity\r
index 5ba3f9c..9facda2 100644 (file)
@@ -12,7 +12,7 @@
   *  or post your suggestion as an enhancement request to the project bug tracker.\r
   *\r
   *  <b>Targeted for This Release:</b>\r
-  *  - Finish HID and Still Image Host Mode Class Drivers, add demo summaries, add return codes to all relevant functions\r
+  *  - Finish HID and Still Image Host Mode Class Drivers, add demo summaries\r
   *  - Add overviews of each of the officially supported boards to the manual\r
   *  - Re-add in flip, flip-ee, dfu and dfu-ee targets to project makefiles\r
   *  - Add in new invalid event hook check targets to project makefiles\r