Instruction manual
Renesas USB MCU and USB ASSP USB Basic Host and Peripheral firmware
R01AN0512EJ0210 Rev.2.10 Page 53 of 157
Apr 1, 2013
<Example class request processing function>
void usb_pvendor_UsrCtrlTransFunction(USB_UTR_t *ptr, USB_REQUEST_t *preq,
uint16_t ctsq)
{
If (preq->ReqTypeType == USB_CLASS)
{
/* Switch on control transfer stage. */
switch (ctsq)
{
/* Idle or Setup stage */
case USB_CS_IDST: usb_ pvendor _ControlTrans0(ptr); break;
/* Control read Data stage */
case USB_CS_RDDS: usb_ pvendor _ControlTrans1(ptr, preq); break;
/* Control write Data stage */
case USB_CS_WRDS: usb_ pvendor _ControlTrans2(ptr, preq); break;
/* Status stage of a control write without a Data stage.*/
case USB_CS_WRND: usb_ pvendor _ControlTrans3(ptr, preq); break;
/* Control read Status stage */
case USB_CS_RDSS: usb_ pvendor _ControlTrans4(ptr, preq); break;
/* Control write Status stage */
case USB_CS_WRSS: usb_ pvendor _ControlTrans5(ptr, preq); break;
/* Control sequence error */
case USB_CS_SQER: R_usb_pstd_ControlEnd(ptr, (uint16_t)USB_DATA_ERR);
break;
/* Illegal */
default: R_usb_pstd_ControlEnd(ptr, (uint16_t)USB_DATA_ERR); break;
}
}
else
{
usb_cstd_SetStall(ptr, (uint16_t)USB_PIPE0);
}
}
1. Data stage processing
If the received request is supported, please transfer the data to host by using the R_usb_pstd_ControlRead() or
R_usb_pstd_ControlWrite API.
If the received request is not supported, return STALL to host by using R_usb_pstd_SetStall() API.
The following function is called in the class request processing function..
a). usb_ pvendor _ControlTrans1()
b). usb_ pvendor _ControlTrans2()
2. Status stage processing
If there was no problem in the setup or data stage, finish the control transfer with a proper status stage by calling
R_usb_pstd_ControlEnd() with USB_DATA_END as the 2nd parameter.
If a parameter is received which is not supported in the setup stage or the data stage, return a STALL packet to host by
using the usb_pstd_ControlEnd() API.
The following function is called in the class request processing function..
a). usb_ pvendor _ControlTrans3()
b). usb_ pvendor _ControlTrans4()
c). usb_ pvendor _ControlTrans5()