Rename reserved members of all structs so that they are uniformly named across all...
[pub/USBasp.git] / Demos / Device / Incomplete / TestAndMeasurement / TestAndMeasurement.c
index d529302..e002542 100644 (file)
@@ -36,7 +36,7 @@
  */\r
 TMC_Capabilities_t Capabilities =\r
        {\r
  */\r
 TMC_Capabilities_t Capabilities =\r
        {\r
-               .Status     = TMC_REQUEST_STATUS_SUCCESS,\r
+               .Status     = TMC_STATUS_SUCCESS,\r
                .TMCVersion = VERSION_BCD(1.00),\r
                \r
                .Interface  =\r
                .TMCVersion = VERSION_BCD(1.00),\r
                \r
                .Interface  =\r
@@ -53,19 +53,16 @@ TMC_Capabilities_t Capabilities =
        };\r
 \r
 /** Current TMC control request that is being processed */\r
        };\r
 \r
 /** Current TMC control request that is being processed */\r
-uint8_t RequestInProgess = 0;\r
+uint8_t RequestInProgess   = 0;\r
 \r
 /** Stream callback abort flag for bulk IN data */\r
 \r
 /** Stream callback abort flag for bulk IN data */\r
-bool IsTMCBulkINReset    = false;\r
+bool IsTMCBulkINReset      = false;\r
 \r
 /** Stream callback abort flag for bulk OUT data */\r
 \r
 /** Stream callback abort flag for bulk OUT data */\r
-bool IsTMCBulkOUTReset   = false;\r
+bool IsTMCBulkOUTReset     = false;\r
 \r
 \r
-/** Last used tag value for bulk IN transfers */\r
-uint8_t NextTransferINTag  = 0;\r
-\r
-/** Last used tag value for bulk IN transfers */\r
-uint8_t NextTransferOUTTag  = 0;\r
+/** Last used tag value for data transfers */\r
+uint8_t CurrentTransferTag = 0;\r
 \r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
 \r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
@@ -145,7 +142,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
  */\r
 void EVENT_USB_Device_UnhandledControlRequest(void)\r
 {\r
  */\r
 void EVENT_USB_Device_UnhandledControlRequest(void)\r
 {\r
-       uint8_t TMCRequestStatus = TMC_REQUEST_STATUS_SUCCESS;\r
+       uint8_t TMCRequestStatus = TMC_STATUS_SUCCESS;\r
 \r
        /* Process TMC specific control requests */\r
        switch (USB_ControlRequest.bRequest)\r
 \r
        /* Process TMC specific control requests */\r
        switch (USB_ControlRequest.bRequest)\r
@@ -155,14 +152,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
-                               /* Check that no split transaction is already in progress and the data OUT transfer tag is valid */\r
+                               /* Check that no split transaction is already in progress and the data transfer tag is valid */\r
                                if (RequestInProgess != 0)\r
                                {\r
                                if (RequestInProgess != 0)\r
                                {\r
-                                       TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;\r
+                                       TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;\r
                                }\r
                                }\r
-                               else if (USB_ControlRequest.wValue != NextTransferOUTTag)\r
+                               else if (USB_ControlRequest.wValue != CurrentTransferTag)\r
                                {\r
                                {\r
-                                       TMCRequestStatus = TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS;\r
+                                       TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS;\r
                                }\r
                                else\r
                                {\r
                                }\r
                                else\r
                                {\r
@@ -188,9 +185,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                \r
                                /* Check that an ABORT BULK OUT transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateAbortBulkOut)\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
+                                 TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;                          \r
                                else if (IsTMCBulkOUTReset)\r
                                else if (IsTMCBulkOUTReset)\r
-                                 TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;\r
+                                 TMCRequestStatus = TMC_STATUS_PENDING;\r
                                else\r
                                  RequestInProgess = 0;                 \r
                                \r
                                else\r
                                  RequestInProgess = 0;                 \r
                                \r
@@ -209,14 +206,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
-                               /* Check that no split transaction is already in progress and the data IN transfer tag is valid */\r
+                               /* Check that no split transaction is already in progress and the data transfer tag is valid */\r
                                if (RequestInProgess != 0)\r
                                {\r
                                if (RequestInProgess != 0)\r
                                {\r
-                                       TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;                                \r
+                                       TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;                                \r
                                }\r
                                }\r
-                               else if (USB_ControlRequest.wValue != NextTransferINTag)\r
+                               else if (USB_ControlRequest.wValue != CurrentTransferTag)\r
                                {\r
                                {\r
-                                       TMCRequestStatus = TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS;\r
+                                       TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS;\r
                                }\r
                                else\r
                                {\r
                                }\r
                                else\r
                                {\r
@@ -229,7 +226,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                \r
                                /* Write the request response bytes */\r
                                Endpoint_Write_Byte(TMCRequestStatus);\r
                                \r
                                /* Write the request response bytes */\r
                                Endpoint_Write_Byte(TMCRequestStatus);\r
-                               Endpoint_Write_Byte(NextTransferINTag);\r
+                               Endpoint_Write_Byte(CurrentTransferTag);\r
 \r
                                Endpoint_ClearIN();\r
                                Endpoint_ClearStatusStage();\r
 \r
                                Endpoint_ClearIN();\r
                                Endpoint_ClearStatusStage();\r
@@ -243,9 +240,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                \r
                                /* Check that an ABORT BULK IN transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateAbortBulkIn)\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
+                                 TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;\r
                                else if (IsTMCBulkINReset)\r
                                else if (IsTMCBulkINReset)\r
-                                 TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;\r
+                                 TMCRequestStatus = TMC_STATUS_PENDING;\r
                                else\r
                                  RequestInProgess = 0;\r
                                \r
                                else\r
                                  RequestInProgess = 0;\r
                                \r
@@ -267,7 +264,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                /* Check that no split transaction is already in progress */\r
                                if (RequestInProgess != 0)\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
+                                       Endpoint_Write_Byte(TMC_STATUS_SPLIT_IN_PROGRESS);                              \r
                                }\r
                                else\r
                                {\r
                                }\r
                                else\r
                                {\r
@@ -294,9 +291,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                                \r
                                /* Check that a CLEAR transaction has been requested and that the request has completed */\r
                                if (RequestInProgess != Req_InitiateClear)\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
+                                 TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;                          \r
                                else if (IsTMCBulkINReset || IsTMCBulkOUTReset)\r
                                else if (IsTMCBulkINReset || IsTMCBulkOUTReset)\r
-                                 TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;\r
+                                 TMCRequestStatus = TMC_STATUS_PENDING;\r
                                else\r
                                  RequestInProgess = 0;\r
                                \r
                                else\r
                                  RequestInProgess = 0;\r
                                \r
@@ -337,8 +334,26 @@ void TMC_Task(void)
        \r
        if (Endpoint_IsOUTReceived())\r
        {\r
        \r
        if (Endpoint_IsOUTReceived())\r
        {\r
-               // TEMP - Indicate data received\r
-               LEDs_SetAllLEDs(LEDS_ALL_LEDS);\r
+               TMC_MessageHeader_t MessageHeader;\r
+               \r
+               Endpoint_Read_Stream_LE(&MessageHeader, sizeof(MessageHeader), StreamCallback_AbortOUTOnRequest);\r
+               CurrentTransferTag = MessageHeader.Tag;\r
+\r
+               switch (MessageHeader.MessageID)\r
+               {\r
+                       case TMC_MESSAGEID_DEV_DEP_MSG_OUT:\r
+\r
+                               break;\r
+                       case TMC_MESSAGEID_DEV_DEP_MSG_IN:\r
+\r
+                               break;\r
+                       case TMC_MESSAGEID_DEV_VENDOR_OUT:\r
+\r
+                               break;\r
+                       case TMC_MESSAGEID_DEV_VENDOR_IN:\r
+                               break;\r
+               }\r
+               \r
                Endpoint_ClearOUT();\r
        }\r
        \r
                Endpoint_ClearOUT();\r
        }\r
        \r