![FTDI FT51A Application Note Download Page 155](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158155.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
154
Copyright © 2015 Future Technology Devices International Limited
status = USB_set_configuration(req);
break
;
case
USB_REQUEST_CODE_GET_CONFIGURATION:
status = USB_get_configuration();
break
;
case
USB_REQUEST_CODE_SET_ADDRESS:
status = USB_set_address(req);
break
;
default
:
case
USB_REQUEST_CODE_GET_INTERFACE:
case
USB_REQUEST_CODE_SET_INTERFACE:
// Unknown or unsupported request.
status =
FT51_FAILED
;
break
;
}
return
status;
}
This call-back is only activated when the USB_process() function is called after a SETUP packet has
been received from the host.
If FT51_FAILED is returned then the USB_process() function will cause a stall on the control
endpoint to signal to the host that the SETUP request failed.
3.2.3.1
Get Status
The minimum requirement for a response to the standard request GET_STATUS is for endpoint and
device statuses.
FT51_STATUS
standard_req_get_status
(USB_device_request *req)
{
USB_STATE state = USB_get_state();
USB_ENDPOINT_NUMBER ep_number = LSB(req->wIndex) & 0x0F;
USB_ENDPOINT_DIR ep_dir = (LSB(req->wIndex) >> 7);
uint8_t buf[2];
buf[0] = buf[1] = 0;
// Get Status for endpoints only
if
(req->bmRequestType == (USB_BMREQUESTTYPE_DIR_DEV_TO_HOST |
USB_BMREQUESTTYPE_RECIPIENT_ENDPOINT))
{
if
(((state <
CONFIGURED
) && (ep_number == 0))
|| (state >=
CONFIGURED
))
{
if
(USB_ep_stalled(ep_number, ep_dir))
{
buf[0] = USB_GET_STATUS_ENDPOINT_HALT;
}
USB_transfer(
USB_EP_0
,
USB_DIR_IN
, buf, 2);
return
FT51_OK
;
}
}
else
if
(req->bmRequestType == (USB_BMREQUESTTYPE_DIR_DEV_TO_HOST |
USB_BMREQUESTTYPE_RECIPIENT_DEVICE))
{
// This must match the configuration descriptor's bmAttributes
buf[0] = USB_GET_STATUS_DEVICE_SELF_POWERED;