![FTDI FT51A Application Note Download Page 154](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158154.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
153
Copyright © 2015 Future Technology Devices International Limited
'F', 0x00, 'T', 0x00, 'D', 0x00, 'I', 0x00,
// String 2 (Product): "FT51A"
0x0C, USB_DESCRIPTOR_TYPE_STRING,
'F', 0x00, 'T', 0x00, '5', 0x00, '1', 0x00,
'A', 0x00,
// String 3 (Serial Number): "FT424242"
0x12, USB_DESCRIPTOR_TYPE_STRING,
'F', 0x00, 'T', 0x00, '4', 0x00, '2', 0x00,
'4', 0x00, '2', 0x00, '4', 0x00, '2', 0x00,
// END OF STRINGS
0x00
};
FTDI applications will place the string descriptors in a block of 256 bytes starting at offset 0x80 in
the program code. This is achieved using the following code.
// String descriptors - allow a maximum of 256 bytes for this
#define
STRING_DESCRIPTOR_LOCATION 0x80
#define
STRING_DESCRIPTOR_ALLOCATION 0x100
__code
__at
(STRING_DESCRIPTOR_LOCATION)
uint8_t
string_descriptor[STRING_DESCRIPTOR_ALLOCATION] = {
The reason for this is to allow tools to edit the string descriptors. The ft51str.exe tool can edit
string descriptors during the process of programming the device allowing unique serial numbers
(or other strings) to be coded into the device.
3.2.3
Standard Requests
The standard request handler must return FT51_OK if the request was handled by the application
or FT51_FAILED if not.
The USB Specification requires that the Set Address, Set Configuration, Get Configuration, Get
Status, Get Descriptor for device and configuration descriptors be implemented. The sample code
in this section illustrates the basic requests required to implement a USB device.
FT51_STATUS
standard_req_cb
(USB_device_request *req)
{
FT51_STATUS status =
FT51_FAILED
;
switch
(req->bRequest)
{
case
USB_REQUEST_CODE_GET_STATUS:
status = standard_req_get_status(req);
break
;
case
USB_REQUEST_CODE_CLEAR_FEATURE:
case
USB_REQUEST_CODE_SET_FEATURE:
status = standard_req_get_set_feature(req);
break
;
case
USB_REQUEST_CODE_GET_DESCRIPTOR:
status = standard_req_get_descriptor(req);
break
;
case
USB_REQUEST_CODE_SET_CONFIGURATION: