Instruction manual

Renesas USB MCU and USB ASSP USB Basic Host and Peripheral firmware
R01AN0512EJ0210 Rev.2.10 Page 52 of 157
Apr 1, 2013
4.3.2 The USB_REQUEST structure
USB_REQUEST_t is the structure where the latest USB request other than the standard request is stored.
This structure is used as the argument to the call-back function that was registered in member ctrltrans of the
USB_PCDREG_t structure.
Table 4-8 shows the member of USB_REQUEST_t structure.
Table 4-8 Member of USB_REQUEST_t structure
Type Member Description
uint16_t ReqType The value is bmRequestType[D7-D0] of request.
(The value is BMREQUESTTYPE of USBREQ register.)
When this value is used, mask with USBC_BMREQUESTTYPE(0x00FFu).
uint16_t ReqTypeType The value is Type of bmRequestType[D6-D5] of request.
(The value is b6-5 of BMREQUESTTYPE of USBREQ register.)
When this value is used, mask with USBC_BMREQUESTTYPETYPE(0x0060u)
uint16_t ReqTypeRecip The value is Recipient of bmRequestType[D4-D0] of request.
(The value is b4-0 of BMREQUESTTYPE of USBREQ register.)
When this value is used, mask with
USBC_BMREQUESTTYPERECIP(0x001Fu)
uint16_t ReqRequest The value is bRequest of request.
(The value is BREQUEST of USBREQ register.)
When this value is used, mask with USBC_BREQUEST(0xFF00u)
uint16_t ReqValue The value is wValue of request.
(The value is USBVAL register.)
uint16_t ReqIndex The value is wIndex of request.
(The value is USBINDEX register.)
uint16_t ReqLength The value is wLength of request.
(The value is USBLENG register.)
4.4 Peripheral Control Transfer
This section provides a transfer control sample program which uses the API provided by the USB-BASIC-F/W. The
sample illustrates a control transfer that occurs when a class request is made from PDCD.
The following functions are required for control transfer processing.
1. Setup stage class request function. (This function shall match the user system. Refer to
4.4.1, Class request
processing.)
2. Data stage API functions (R_usb_pstd_ControlRead / R_usb_pstd_ControlWrite).
3. Status stage API function (R_usb_pstd_ControlEnd)
Note: Class request functions must be created by the user.
4.4.1 Class request processing
When a class control request is received by USB-BASIC-FW, the contents of the request are stored in the global variable
usb_gpstd_ReqReg (type USB_REQUEST_t). Then, the function (the class request processing call-back) registered in
ctrltrans of the USB_PCDREG_t structure is run. The USB communication structure (USB_UTR_t), the request
information and control transfer stage information are set as the argument of the called function. The user needs to
describe the class request processing in this class request processing call-back. This class request processing function is
called at the data stage and the status stage.
An example of how to create a class request processing function is described below. This is also the ctrltrans member of
structure USB_PCDREG_t.