Add TMC device capabilities to the incomplete TMC demo.
[pub/USBasp.git] / Demos / Device / Incomplete / TestAndMeasurement / TestAndMeasurement.c
index 6a2cff4..d56a7f7 100644 (file)
 \r
 #include "TestAndMeasurement.h"\r
 \r
+/** Contains the (usually static) capabilities of the TMC device. This table is requested by the\r
+ *  host upon enumeration to give it information on what features of the Test and Measurement USB\r
+ *  Class the device supports.\r
+ */\r
+TMC_Capabilities_t Capabilities =\r
+       {\r
+               .Status     = TMC_REQUEST_STATUS_SUCCESS,\r
+               .TMCVersion = VERSION_BCD(1.00),\r
+               \r
+               .Interface  =\r
+                       {\r
+                               .ListenOnly             = false,\r
+                               .TalkOnly               = false,\r
+                               .PulseIndicateSupported = true,\r
+                       },\r
+\r
+               .Device     =\r
+                       {\r
+                               .SupportsAbortINOnMatch = false,\r
+                       },\r
+       };\r
+\r
+\r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
  *  setup of all components and the main program loop.\r
  */\r
@@ -141,7 +164,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                case Req_GetCapabilities:\r
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                       \r
+                               /* Acknowledge the SETUP packet, ready for data transfer */\r
+                               Endpoint_ClearSETUP();\r
+                                       \r
+                               /* Write the device capabilities to the control endpoint */\r
+                               Endpoint_Write_Control_Stream_LE(&Capabilities, sizeof(TMC_Capabilities_t));\r
+                               \r
+                               /* Finalize the stream transfer to send the last packet or clear the host abort */\r
+                               Endpoint_ClearOUT();\r
                        }\r
                        \r
                        break;\r
@@ -153,4 +183,13 @@ void TMC_Task(void)
        /* Device must be connected and configured for the task to run */\r
        if (USB_DeviceState != DEVICE_STATE_Configured)\r
          return;\r
+         \r
+       Endpoint_SelectEndpoint(TMC_OUT_EPNUM);\r
+       \r
+       if (Endpoint_IsOUTReceived())\r
+       {\r
+               // TEMP - Indicate data received\r
+               LEDs_SetAllLEDs(LEDS_ALL_LEDS);\r
+               Endpoint_ClearOUT();\r
+       }\r
 }\r