Add stream callback flags and class specific control request handler code to the incomplete Test and Measurement Class device demo.

Change over the keyboard demo's manufacturer name back to the primary author of the demo.
pull/1469/head
Dean Camera 14 years ago
parent 4c9425c0d5
commit 89a32baf58

@ -183,9 +183,9 @@ USB_Descriptor_String_t PROGMEM LanguageString =
*/
USB_Descriptor_String_t PROGMEM ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(16), .Type = DTYPE_String},
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
.UnicodeString = L"Denver Gingerich"
.UnicodeString = L"Dean Camera"
};
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,

@ -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;
}

@ -65,12 +65,12 @@
#define Req_GetCapabilities 0x07
#define Req_IndicatorPulse 0x40
#define TMC_REQUEST_STATUS_SUCCESS 0x01
#define TMC_REQUEST_STATUS_PENDING 0x02
#define TMC_REQUEST_STATUS_FAILED 0x80
#define TMC_REQUEST_STATUS_NOTRANSFER 0x81
#define TMC_REQUEST_STATUS_NOCHECKINITIATED 0x82
#define TMC_REQUEST_STATUS_CHECKINPROGRESS 0x83
#define TMC_REQUEST_STATUS_SUCCESS 0x01
#define TMC_REQUEST_STATUS_PENDING 0x02
#define TMC_REQUEST_STATUS_FAILED 0x80
#define TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
#define TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
#define TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS 0x83
/* Type Defines */
typedef struct
@ -107,4 +107,7 @@
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_UnhandledControlRequest(void);
uint8_t StreamCallback_AbortINOnRequest(void);
uint8_t StreamCallback_AbortOUTOnRequest(void);
#endif

@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
LUFA_OPTS += -D NO_STREAM_CALLBACKS
# Create the LUFA source path variables by including the LUFA root makefile

@ -194,9 +194,9 @@ USB_Descriptor_String_t PROGMEM LanguageString =
*/
USB_Descriptor_String_t PROGMEM ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(16), .Type = DTYPE_String},
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
.UnicodeString = L"Denver Gingerich"
.UnicodeString = L"Dean Camera"
};
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,

Loading…
Cancel
Save