Add comments to the currently completed portions of the incomplete Test and Measureme...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 26 Jul 2010 05:02:55 +0000 (05:02 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 26 Jul 2010 05:02:55 +0000 (05:02 +0000)
Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c

index 184e2e2..d529302 100644 (file)
@@ -100,16 +100,25 @@ void SetupHardware(void)
        USB_Init();\r
 }\r
 \r
+/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and\r
+ *  starts the library USB task to begin the enumeration and USB management process.\r
+ */\r
 void EVENT_USB_Device_Connect(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
 }\r
 \r
+/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via\r
+ *  the status LEDs and stops the USB management and CDC management tasks.\r
+ */\r
 void EVENT_USB_Device_Disconnect(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 }\r
 \r
+/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration\r
+ *  of the USB device after enumeration - the device endpoints are configured and the CDC management task started.\r
+ */\r
 void EVENT_USB_Device_ConfigurationChanged(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
@@ -130,10 +139,15 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        }\r
 }\r
 \r
+/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific\r
+ *  control requests that are not handled internally by the USB library (including the CDC control commands,\r
+ *  which are all issued via the control endpoint), so that they can be handled appropriately for the application.\r
+ */\r
 void EVENT_USB_Device_UnhandledControlRequest(void)\r
 {\r
        uint8_t TMCRequestStatus = TMC_REQUEST_STATUS_SUCCESS;\r
 \r
+       /* Process TMC specific control requests */\r
        switch (USB_ControlRequest.bRequest)\r
        {\r
                case Req_InitiateAbortBulkOut:\r
@@ -141,6 +155,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that no split transaction is already in progress and the data OUT transfer tag is valid */\r
                                if (RequestInProgess != 0)\r
                                {\r
                                        TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;\r
@@ -171,6 +186,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that an ABORT BULK OUT transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateAbortBulkOut)\r
                                  TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;                          \r
                                else if (IsTMCBulkOUTReset)\r
@@ -193,6 +209,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that no split transaction is already in progress and the data IN transfer tag is valid */\r
                                if (RequestInProgess != 0)\r
                                {\r
                                        TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;                                \r
@@ -224,6 +241,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that an ABORT BULK IN transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateAbortBulkIn)\r
                                  TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;\r
                                else if (IsTMCBulkINReset)\r
@@ -246,6 +264,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that no split transaction is already in progress */\r
                                if (RequestInProgess != 0)\r
                                {\r
                                        Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS);                              \r
@@ -273,6 +292,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
+                               /* Check that a CLEAR transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateClear)\r
                                  TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;                          \r
                                else if (IsTMCBulkINReset || IsTMCBulkOUTReset)\r
@@ -305,7 +325,8 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        break;\r
        }\r
 }\r
-       \r
+\r
+/** Function to manage TMC data transmission and reception to and from the host. */\r
 void TMC_Task(void)\r
 {\r
        /* Device must be connected and configured for the task to run */\r