mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
parent
400c2d2e50
commit
12a145b27d
@ -364,7 +364,7 @@ bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request
|
|||||||
tud_control_status(rhport, request);
|
tud_control_status(rhport, request);
|
||||||
|
|
||||||
// Invoke callback
|
// Invoke callback
|
||||||
if ( tud_cdc_line_state_cb) tud_cdc_line_state_cb(itf, dtr, rts);
|
if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -44,6 +44,14 @@ typedef enum {
|
|||||||
DFU_REQUEST_ABORT = 6,
|
DFU_REQUEST_ABORT = 6,
|
||||||
} dfu_requests_t;
|
} dfu_requests_t;
|
||||||
|
|
||||||
|
typedef struct TU_ATTR_PACKED
|
||||||
|
{
|
||||||
|
uint8_t status;
|
||||||
|
uint8_t poll_timeout[3];
|
||||||
|
uint8_t state;
|
||||||
|
uint8_t istring;
|
||||||
|
} dfu_status_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USBD Driver API
|
// USBD Driver API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -88,10 +96,19 @@ bool dfu_rtd_control_complete(uint8_t rhport, tusb_control_request_t const * req
|
|||||||
|
|
||||||
bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * request)
|
bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * request)
|
||||||
{
|
{
|
||||||
// Handle class request only
|
|
||||||
TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS);
|
|
||||||
TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE);
|
TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE);
|
||||||
|
|
||||||
|
// dfu-util will try to claim the interface with SET_INTERFACE request before sending DFU request
|
||||||
|
if ( TUSB_REQ_TYPE_STANDARD == request->bmRequestType_bit.type &&
|
||||||
|
TUSB_REQ_SET_INTERFACE == request->bRequest )
|
||||||
|
{
|
||||||
|
tud_control_status(rhport, request);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle class request only from here
|
||||||
|
TU_VERIFY(request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS);
|
||||||
|
|
||||||
switch ( request->bRequest )
|
switch ( request->bRequest )
|
||||||
{
|
{
|
||||||
case DFU_REQUEST_DETACH:
|
case DFU_REQUEST_DETACH:
|
||||||
@ -99,6 +116,14 @@ bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * requ
|
|||||||
tud_dfu_rt_reboot_to_dfu();
|
tud_dfu_rt_reboot_to_dfu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DFU_REQUEST_GETSTATUS:
|
||||||
|
{
|
||||||
|
// status = OK, poll timeout = 0, state = app idle, istring = 0
|
||||||
|
uint8_t status_response[6] = { 0, 0, 0, 0, 0, 0 };
|
||||||
|
tud_control_xfer(rhport, request, status_response, sizeof(status_response));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default: return false; // stall unsupported request
|
default: return false; // stall unsupported request
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user