UM0290 STR7/STR9 USB firmware library
19/76
1. Device property implementation
The device property structure fields are described below:
–void Init(void): Init procedure of the USB IP. It is called once at the start of the
application to manage the initialization process.
–void Reset(void): Reset procedure of the USB IP. It is called when the macrocell
receives a RESET signal from the bus. The user program should set up the
endpoints in this procedure, in order to set the default control endpoint and enable
them to receive.
–void Process_Status_IN(void): Callback procedure, it is called when a status in a
stage is finished. The user program can take control with this callback to perform
class and application related processes.
–void Process_Status_OUT(void): Callback procedure, it is called when a status
out stage is finished. As with Process_Status_IN, the user program can perform
actions after a status out stage.
–RESULT(a) *(Class_Data_Setup)(BYTE RequestNo): Callback procedure, it is
called when a class request is recognized and this request needs a data stage.
The core can not process such requests. In this case, the user program gets the
chance to use custom procedures to analyze the request, and prepare the data
and pass the data to the USB core to exchange with the host. The parameter
RequestNo indicates the request number. The return parameter of this function
has the type: RESULT. It indicates to the core the result of the request processing.
–RESULT (*Class_NoData_Setup)(BYTE RequestNo) Callback procedure, it is
called when a non-standard device request is recognized which does not need a
data stage. The core can not process such requests. The user program can have
the chance to use custom procedures to analyze the request and take action. The
return parameter of this function has type: RESULT. It indicates to the core the
result of the request processing.
–RESULT (*Class_GET_Interface_Setting)(u8 Interface, u8 AlternateSetting):
This routine is used to test the received set interface standard request. The user
must verify the "Interface" and "AlternateSetting" depending on the specific
implementation and return the USB_UNSUPPORT(a) and in case of error in this two
fields.
–BYTE* GetDeviceDescriptor(WORD Length): The core gets the device
descriptor.
–BYTE* GetConfigDescriptor(WORD Length): The core gets the configuration
descriptor.
–BYTE* GetStringDescriptor(WORD Length): The core gets the string descriptor.
–WORD MaxPacketSize: The maximum packet size of the device default control
endpoint.
a. * The RESULT type is the following:
typedef enum _RESULT {
USB_SUCCESS = 0,/* request process sucessfully */
USB_ERROR, /* error
USB_UNSUPPORT, /* request not supported
USB_NOT_READY/* The request process has not been finished,*/
/* endpoint will be NAK to further requests*/
} RESULT;