![FTDI FT51A Скачать руководство пользователя страница 156](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158156.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
155
Copyright © 2015 Future Technology Devices International Limited
USB_transfer(
USB_EP_0
,
USB_DIR_IN
, buf, 2);
return
FT51_OK
;
}
return
FT51_FAILED
;
}
The endpoint status may only return a valid status for endpoint zero when the device is not
configured. When the device is in the configured state then it can return statuses for all endpoints.
3.2.3.2
Set Features
The control endpoints must respond to SET_FEATURE and CLEAR_FEATURE requests. This example
code will provide a response for endpoint stall SET and CLEAR operations.
FT51_STATUS
standard_req_get_set_feature
(USB_device_request *req)
{
USB_ENDPOINT_NUMBER ep_number = LSB(req->wIndex) & 0x0F;
USB_ENDPOINT_DIR ep_dir = (LSB(req->wIndex) >> 7);
USB_STATE state = USB_get_state();
if
(req->bmRequestType == (USB_BMREQUESTTYPE_DIR_DEV_TO_HOST |
USB_BMREQUESTTYPE_RECIPIENT_ENDPOINT))
{
// Only support the endpoint halt feature in this device
if
(req->wValue == USB_FEATURE_ENDPOINT_HALT)
{
// Only allow this if the device is configured or the endpoint
// is zero if the device is not configured.
if
(((state <
CONFIGURED
) && (ep_number == 0))
|| (state >=
CONFIGURED
))
{
// Perform a stall or a clear
if
(req->bRequest == USB_REQUEST_CODE_CLEAR_FEATURE)
{
// Feature selector CLEAR
USB_clear_endpoint(ep_number, ep_dir);
}
else
{
// Feature selector SET
USB_stall_endpoint(ep_number, ep_dir);
}
USB_transfer(
USB_EP_0
,
USB_DIR_IN
, NULL, 0);
return
FT51_OK
;
}
}
}
return
FT51_FAILED
;
}
The endpoint features only apply to endpoint zero when the device is not configured. When the
device is configured then it can apply to all endpoints.
3.2.3.3
Get Descriptors
The Get Descriptor response depends on the type of descriptor requested. Only device and
configuration descriptors are required but string descriptors are commonly used.