Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 6 May 2010 11:56:34 +0000 (11:56 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 6 May 2010 11:56:34 +0000 (11:56 +0000)
LUFA/Drivers/USB/Class/Common/CDC.h
LUFA/Drivers/USB/Class/Device/CDC.c
LUFA/Drivers/USB/Class/Device/CDC.h
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/ManPages/ChangeLog.txt

index cef7a4c..9fb1202 100644 (file)
 \r
                /** CDC Class specific request to set the current virtual serial port handshake line states. */\r
                #define REQ_SetControlLineState          0x22\r
 \r
                /** CDC Class specific request to set the current virtual serial port handshake line states. */\r
                #define REQ_SetControlLineState          0x22\r
+\r
+               /** CDC Class specific request to send a break to the receiver via the carrier channel. */\r
+               #define REQ_SendBreak                    0x23\r
+\r
+               /** CDC Class specific request to send an encapsulated command to the device. */\r
+               #define REQ_SendEncapsulatedCommand      0x00\r
+\r
+               /** CDC Class specific request to retrieve an encapsulated command response from the device. */\r
+               #define REQ_GetEncapsulatedResponse      0x01\r
                \r
                /** Notification type constant for a change in the virtual serial port handshake line states, for\r
                 *  use with a USB_Notification_Header_t notification structure when sent to the host via the CDC \r
                \r
                /** Notification type constant for a change in the virtual serial port handshake line states, for\r
                 *  use with a USB_Notification_Header_t notification structure when sent to the host via the CDC \r
index ade2a1b..e1cb554 100644 (file)
@@ -84,6 +84,17 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* CDCInterfaceIn
                        }\r
        \r
                        break;\r
                        }\r
        \r
                        break;\r
+               case REQ_SendBreak:\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       {                               \r
+                               Endpoint_ClearSETUP();\r
+                               \r
+                               EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue);\r
+\r
+                               Endpoint_ClearStatusStage();\r
+                       }\r
+\r
+                       break;\r
        }\r
 }\r
 \r
        }\r
 }\r
 \r
index 2c5c30a..0b2c4c0 100644 (file)
                         */\r
                        void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
                         */\r
                        void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
 \r
+                       /** CDC class driver event for a send break request sent to the device from the host. This is generally used to seperate\r
+                        *  data or to indicate a special condition to the receiving device.\r
+                        *\r
+                        *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
+                        *  \param[in]     Duration          Duration of the break that has been sent by the host, in milliseconds\r
+                        */\r
+                       void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
                        /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the\r
                         *  string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the\r
                         *  \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be \r
                        /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the\r
                         *  string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the\r
                         *  \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be \r
                                                                                                                  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
                                void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
                                                                                                                         ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
                                                                                                                  ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
                                void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
                                                                                                                         ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
+                               void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, uint8_t Duration)\r
+                                                               ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
                        #endif\r
 \r
        #endif\r
                        #endif\r
 \r
        #endif\r
index bc8e089..8a00616 100644 (file)
@@ -261,6 +261,22 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCI
        return USB_Host_SendControlRequest(NULL);\r
 }\r
 \r
        return USB_Host_SendControlRequest(NULL);\r
 }\r
 \r
+uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, const uint8_t Duration)\r
+{\r
+       USB_ControlRequest = (USB_Request_Header_t)\r
+       {\r
+               .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+               .bRequest      = REQ_SendBreak,\r
+               .wValue        = Duration,\r
+               .wIndex        = CDCInterfaceInfo->State.ControlInterfaceNumber,\r
+               .wLength       = 0,\r
+       };\r
+\r
+       Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+       \r
+       return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
 uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, char* Data, const uint16_t Length)\r
 {\r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
 uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, char* Data, const uint16_t Length)\r
 {\r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
@@ -303,8 +319,6 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, cons
 \r
 uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
 {\r
 \r
 uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
 {\r
-       uint16_t BytesInPipe = 0;\r
-\r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return 0;\r
        \r
        if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
          return 0;\r
        \r
index bb12c08..3ea2d51 100644 (file)
                         */\r
                        uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
                        \r
                         */\r
                        uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
                        \r
+                       /** Sends a Send Break request to the device. This is generally used to seperate data data or to indicate a special condition\r
+                        *  to the receiving device.\r
+                        *\r
+                        *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
+                        *  \param[in]     Duration          Duration of the break, in milliseconds\r
+                        *\r
+                        *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum\r
+                        */\r
+                       uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);\r
+                       \r
                        /** Sends a given string to the attached USB device, if connected. If a device is not connected when the function is called, the\r
                         *  string is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the\r
                         *  \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be \r
                        /** Sends a given string to the attached USB device, if connected. If a device is not connected when the function is called, the\r
                         *  string is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the\r
                         *  \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be \r
index 9e36872..8e68183 100644 (file)
@@ -15,6 +15,7 @@
   *  - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup\r
   *  - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus\r
   *    is suspended before or during a transfer\r
   *  - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup\r
   *  - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus\r
   *    is suspended before or during a transfer\r
+  *  - Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to the Device and Host CDC Class drivers\r
   *\r
   *  <b>Changed:</b>\r
   *  - AVRISP programmer project now has a more robust timeout system\r
   *\r
   *  <b>Changed:</b>\r
   *  - AVRISP programmer project now has a more robust timeout system\r