aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c')
-rw-r--r--Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c161
1 files changed, 154 insertions, 7 deletions
diff --git a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c
index d56a7f7bc..c3e54ab3a 100644
--- a/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c
+++ b/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c
@@ -43,7 +43,7 @@ TMC_Capabilities_t Capabilities =
{
.ListenOnly = false,
.TalkOnly = false,
- .PulseIndicateSupported = true,
+ .PulseIndicateSupported = false,
},
.Device =
@@ -52,6 +52,15 @@ TMC_Capabilities_t Capabilities =
},
};
+/** Current TMC control request that is being processed */
+uint8_t RequestInProgess = 0;
+
+/** Stream callback abort flag for bulk IN data */
+bool IsTMCBulkINReset = false;
+
+/** Stream callback abort flag for bulk OUT data */
+bool IsTMCBulkOUTReset = false;
+
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
@@ -122,42 +131,154 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
case Req_InitiateAbortBulkOut:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see if a split request is already being processed before starting a new one */
+ if (RequestInProgess != 0)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS);
+ }
+ else
+ {
+ /* Indicate that all in-progress/pending data OUT requests should be aborted */
+ IsTMCBulkOUTReset = true;
+
+ /* Save the split request for later checking when a new request is received */
+ RequestInProgess = Req_InitiateAbortBulkOut;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
case Req_CheckAbortBulkOutStatus:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see the correct split request is in progress before the status can be retrieved */
+ if (RequestInProgess != Req_InitiateAbortBulkOut)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS);
+ }
+ else
+ {
+ // TODO: CLEAR BULK OUT
+
+ /* Clear the pending split request value so that a new request can be made */
+ RequestInProgess = 0;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
case Req_InitiateAbortBulkIn:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see if a split request is already being processed before starting a new one */
+ if (RequestInProgess != 0)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS);
+ }
+ else
+ {
+ /* Indicate that all in-progress/pending data IN requests should be aborted */
+ IsTMCBulkINReset = true;
+
+ /* Save the split request for later checking when a new request is received */
+ RequestInProgess = Req_InitiateAbortBulkIn;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
case Req_CheckAbortBulkInStatus:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see the correct split request is in progress before the status can be retrieved */
+ if (RequestInProgess != Req_InitiateAbortBulkIn)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS);
+ }
+ else
+ {
+ // TODO: CLEAR BULK IN
+
+ /* Clear the pending split request value so that a new request can be made */
+ RequestInProgess = 0;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
case Req_InitiateClear:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see if a split request is already being processed before starting a new one */
+ if (RequestInProgess != 0)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS);
+ }
+ else
+ {
+ /* Indicate that all in-progress/pending data IN and OUT requests should be aborted */
+ IsTMCBulkINReset = true;
+ IsTMCBulkOUTReset = true;
+
+ /* Save the split request for later checking when a new request is received */
+ RequestInProgess = Req_InitiateClear;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
case Req_CheckClearStatus:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{
-
+ Endpoint_ClearSETUP();
+
+ /* Check to see the correct split request is in progress before the status can be retrieved */
+ if (RequestInProgess != Req_InitiateClear)
+ {
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS);
+ }
+ else
+ {
+ // TODO: CLEAR STATUS
+
+ /* Clear the pending split request value so that a new request can be made */
+ RequestInProgess = 0;
+
+ Endpoint_Write_Byte(TMC_REQUEST_STATUS_SUCCESS);
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_ClearStatusStage();
}
break;
@@ -193,3 +314,29 @@ void TMC_Task(void)
Endpoint_ClearOUT();
}
}
+
+/** Stream callback function for the Endpoint stream write functions. This callback will abort the current stream transfer
+ * if a TMC Abort Bulk IN request has been issued to the control endpoint.
+ */
+uint8_t StreamCallback_AbortINOnRequest(void)
+{
+ /* Abort if a TMC Bulk Data IN abort was received */
+ if (IsTMCBulkINReset)
+ return STREAMCALLBACK_Abort;
+
+ /* Continue with the current stream operation */
+ return STREAMCALLBACK_Continue;
+}
+
+/** Stream callback function for the Endpoint stream read functions. This callback will abort the current stream transfer
+ * if a TMC Abort Bulk OUT request has been issued to the control endpoint.
+ */
+uint8_t StreamCallback_AbortOUTOnRequest(void)
+{
+ /* Abort if a TMC Bulk Data IN abort was received */
+ if (IsTMCBulkOUTReset)
+ return STREAMCALLBACK_Abort;
+
+ /* Continue with the current stream operation */
+ return STREAMCALLBACK_Continue;
+}