APPLICATION NOTE RX62N Group USB Basic Firmware R01AN0495EJ0100 Rev.1.00 Apr 15, 2011 Introduction This document is an installation guide for the Renesas USB Basic firmware (herein referred to as USB-BASIC-F/W), a sample program for USB interface control using the USB device. This document is intended for use with the instruction manual for the Renesas USB Basic firmware and the device data sheet when developing software.
USB Basic Firmware 1. Introduction 1.1 Feature Overview The USB-BASIC-F/W is a sample program for USB interface control using the RX62N. The main features and functions of USB-RX62N are as follows: Can operate three patterns: host function, peripheral function and host/peripheral function.
USB Basic Firmware 2. Operating USB-BASIC-F/W Without Modifications 2.1 Sample Application Operation Confirmation 2.1.1 Sample Application Operating Specifications The USB-BASIC-F/W comes with a sample vendor class driver and application. USB Bulk and Interrupt data transfers can be executed without modification to the firmware. For RX62N RSK, USB PORT0 can be used as the USB peripheral port and USB PORT1 can be used as the USB host port.
USB Basic Firmware 2.1.2 (1) Setup Hardware The connection topology for each device is described below. Please refer to the corresponding instruction manual concerning RX62N RSK setup, emulator use, etc.
USB Basic Firmware Build configuration can be customized. When NonOS_StdFw is selected as the active project Only the specified source files will be compiled. Figure.ure.2.5 Project Selection Examples (using HEW) 3) 4) 5) 6) Select [Debug Æ Connect]. You will be prompted to select the emulator mode; select the mode according to the emulator you are using. Download the program by selecting: [Debug Æ Download Æ All Download Modules].
USB Basic Firmware 2.1.3 (1) Sample Application Operation Image When running the sample application on one RX62N RSK device USB-BASIC-F/W operations can be confirmed by selecting PORT0_P_PORT1_H in the build configuration in the HEW environment, as shown in the connection image below. The USB bus analyzer can be used to monitor the transmission contents of the USB data transfer. Figure .2.2.
USB Basic Firmware 2.2 Confirming Operations with USBCV When using USB-BASIC-F/W with USB peripheral functions, operations can be confirmed with the “USBCommandVerifier (USBCV) without modifying USB-BASIC-F/W. The connection topology for each device is shown below. Figure .2.4 Example of Confirming Operations with USBCV (USB peripheral functions) R01AN0495EJ0100 Rev.1.
USB Basic Firmware 3. Customized USB-BASIC-F/W Operations USB-BASIC-F/W can operate as a USB driver to match the user system by modifying the scheduler macro (“r_usbc_cItron.h” / “r_usbc_cMacSystemcall.h”), user defined information (“r_usbc_cDefUsr.h”/ “r_usb_cDefUsr.h”), and nonOS settings (“r_usbc_cKernelId.h” / “main.c” / “r_usb_PSMPL_apl.c” / “r_usb2_HSMPL_apl.c”), and adding the nonOS HDCD/PDCD to the MainLoop function.
USB Basic Firmware 3.1.2 Changed items for RX62N CPU Changed file name:[main.c] [RX62NRSK.c] The changed items for CPU are as follows. These should be changed as needed to match the system under development. ⎯ Initialization of the control MCU, interrupt handlers, interrupt control, DTC control, etc.
USB Basic Firmware 3.1.5 Changed items for user definition (H/W operation specification) Changed file name: [r_usb_cDefUsr.h] These should be changed as needed to match the system under development. ⎯ ⎯ ⎯ ⎯ USB function designation Clock mode designation Sleep mode designation H/W adress designation R01AN0495EJ0100 Rev.1.
USB Basic Firmware 3.2 Use as USB peripheral function 3.2.1 Setting of Vendor ID/ Product ID Changed file name:[ r_usbc_cDefUsr.h] It is necessary to change Vendor ID/ Product ID that uses the system under development. #define #define 3.2.2 USB_VENDORID USB_PRODUCTID 0x1234u 0x5678u /* Vendor ID */ /* Product ID * / Descriptor Table Generation Changed file name:[ r_usb_PSMPL_data.c] [ r_usb_PSMPL_apl.
USB Basic Firmware R_usb_pstd_SmplDescriptorChange Full-speed Hi-speed connection Hi-speed usb_gpstd_SmplConfigurationH_1[1] = USBC_DT_CONFIGURATION; usb_gpstd_SmplConfigurationF_1[1] = USBC_DT_OTHER_SPEED_CONF; usb_gpstd_SmplConPtr[0] = usb_gpstd_SmplConfigurationH_1; usb_gpstd_SmplConPtrOther[0] = usb_gpstd_SmplConfigurationF_1; usb_gpstd_SmplEpTbl1[(USB_EPL * 0) + 3] = 512; usb_gpstd_SmplEpTbl1[(USB_EPL * 1) + 3] = 512; usb_gpstd_SmplEpTbl1[(USB_EPL * 2) + 3] = 512; usb_gpst
USB Basic Firmware 3.2.3 PIPE Definition Changed file name:[ r_usb_PSMPL_data.c] PDCD must store appropriate pipe settings for the relevant class driver as a pipe information table. PDCD must register the pipe information table at the time of driver registration. 1) Pipe Information Table A pipe information table comprises the following six items (uint16_t × 6: [RX-62N]). 1. 2. 3. 4. 5. 6.
USB Basic Firmware : Processing only nonOS usbc_cstd_Main Task MainInit MainInit() Initialize hardware Start Idle task Wait for hardware ready hardware usb_cstd_TargetInit() usb_cstd_WaitUsbip() usb_cstd_AsspConfig() Pin control 1 MainLoop usb_cstd_SwReset() Software reset usb_cstd_InitialClock() Idle task Start oscillator usb_cstd_Pinconfig() Pin control 2 R_usb_pstd_PcdOpen() Start PCD tak PCD task R_usb_pstd_SmplRegistration() Register drivers Set PERI function usb_cstd_SetHwFu
USB Basic Firmware (2) Register the PDCD The structure used to register information in PDCD is described below. The call-back function is executed when the device state changes, etc. The sample application is described in the R_usb_pstd_SmplRegistration function in r_usb_PSMPL_apl.c.
USB Basic Firmware Table 3.1 Members of USB_PCDREG_t Structure Variable Name **pipetbl *devicet *qualitbl **configtbl **othertbl **stringtbl classinit devdefault devconfig devdetach devsuspend devresume interface ctrltrans Description Register the address of the pipe information table. Register the device descriptor address. Register the device qualifier descriptor address. Register the address of the configuration descriptor address table.
USB Basic Firmware 3.2.5 Example of Creating a Peripheral Application The following is an example of embedding a USB-BASIC-F/W data transfer sample application. For more details, refer to r_usb_PSMPL_apl.c. (1) Example of creating a main task “r_usb_PSMPL_apl.c” void usbc_cstd_MainTask(USBC_VP_INT stacd) { /* Sample application initial process */ usb_pstd_MainInit(); Å USB function Initialization(Start the PCD, Register the PDCD) Refer to 3.2.
USB Basic Firmware Example of creating register the PCDC (2) “r_usb_PSMPL_apl.
USB Basic Firmware (3) Example of coding a Peripheral sample application “r_usb_PSMPL_apl.c” void usb_pstd_MainLoop(void) { if( R_usbc_cstd_CheckSchedule() == USBC_FLGSET ) { /* PCD Task */ usb_pstd_PcdTask((USBC_VP_INT)0); /* Main Task */ usb_pstd_MainTask((USBC_VP_INT)0); } /* Scheduler */ R_usbc_cstd_Scheduler(); } “r_usb_PSMPL_apl.
USB Basic Firmware 3.3 Use as USB host function 3.3.1 Setting of a connected USB device Changed file name:[ r_usb2_HSMPL_apl.c] A TPL is generated for each device class. In project, vendor IDs and product IDs are registered as sets. Register all supported sets in the relevant device class. When all products in the relevant device class are supported, do not specify specific vendor IDs and product IDs. Instead, register USB_NOVENDOR and USB_NOPURODUCT as a set.
USB Basic Firmware 3.3.3 How to Start/Register the HDCD To execute host functions with the USB-BASIC-F/W firmware, you will need to create an HDCD based on the user system, and register that HDCD in the HCD/MGR. For nonOS firmware, you will need to configure the HDCD to enable the scheduler control function. (1) HCD Task Start Sequence The start sequence of the HCD/MGR task is shown below. The sample is described in r_usb2_HSMPL_apl.c. R01AN0495EJ0100 Rev.1.
USB Basic Firmware Figure 3.6 HCD/MGR Start Sequence R01AN0495EJ0100 Rev.1.
USB Basic Firmware (2) Register the HDCD The structure used to register information in PDCD is described below. The sample application is described in the R_usb_hstd_SmplRegistration function inusb2_HSMPL_apl.c.
USB Basic Firmware 3.3.4 Example of Creating a Host Application The following is an example of embedding a USB-BASIC-F/W data transfer sample application. . For more details, refer to r_usb2_HSMPL_apl.c. (1) Example of creating a main task “r_usb2_HSMPL_apl.c” void usbc_cstd_MainTask(USBC_VP_INT stacd) { /* Sample application initial process */ usb2_hstd_MainInit(); Å USB function Initialization(Start the HCD, Register the HDCD) Refer to 3.3.
USB Basic Firmware Register the HDCD (2) “r_usb2_HSMPL_apl.
USB Basic Firmware (3) Example of coding a Host sample application “r_usb2_HSMPL_apl.c” void usb_pstd_MainLoop(void) { if( R_usbc_cstd_CheckSchedule() == USBC_FLGSET ) { usb2_hstd_HcdTask((USBC_VP_INT)0); usb2_hstd_MgrTask((USBC_VP_INT)0); usb2_hhub_Task((USBC_VP_INT)0); usb2_hcls_SmplTask(); } R_usbc_cstd_Scheduler(); } /* HCD Task */ /* MGR Task */ /* HUB Task */ /* Scheduler */ “r_usb2_HSMPL_apl.
USB Basic Firmware 4. Software Configuration USB-BASIC-F/W comprises the peripheral driver, which implements the peripheral function mode, the Host driver, which implements the host function mode, the Host manager, which manages device states, the HUB class driver, which controls devices connected to the down ports of the USB hub, and the main task, which operates as the application.
USB Basic Firmware Table 4.
USB Basic Firmware usbc_cstd_MainTask() PCD Driver registration (Requisite PDCD registration) usb_pstd_MainInit HOST PCD Start USB Host connection (VBUS detection) CallbackRegistration() D+ Pull-up usb_pstd_MainLoop() Enumeration SET_CONFIGURATION PDCD usb_pstd_MainLoop() Callback devconfig R_usb_pstd_SmplOpen() No Flag set usb_ptsd_UsrDataInit() Initialize a Data area Yes usb_pstd_PcdTask usb_pstd_MainTask usb_pstd_UsrDataTranStart() Start the data transfer R_usbc_cstd_Schedu
USB Basic Firmware usb2_hstd_MainTask() MGR/HCD MGR/HCD Start Driver registration (Requisite HDCD registration) usb2_hstd_MainInit USB device USB device connection (Attach detection) CallbackRegistration() Reset usb2_hstd_MainLoop() Enumeration GET_DESCRIPTOR HDCD usb2_hstd_MainLoop() Task processing flag set? usb2_hcls_SmpTask() Callback Classcheck R_usb2_hstd_SmplClassCheck USBC_MSG_CLS_CHC EKREQUEST No SET_CONFIGURATION Yes usb2_hstd_HcdTask Callback devconfig R_usb2_hstd_
USB Basic Firmware 4.1 List of Files 4.1.1 Folder Structure The folder structure in which the files are provided in USB-BASIC-F/W is shown below. RX62N is equipped with two independent USB ports: USBSTDFW for PORT0 and USB2STDFW for PORT1. The user’s operating environment and USB functions are readily supported in the HEW environment, making it easy for the user to select only the target source files.
USB Basic Firmware Website and Support Renesas Electronics Website http://www.renesas.com/ Inquiries http://www.renesas.com/inquiry All trademarks and registered trademarks are the property of their respective owners. R01AN0495EJ0100 Rev.1.
Revision Record Rev. 1.00 Date Apr.15.
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. If the descriptions under General Precautions in the Handling of MPU/MCU Products and in the body of the manual differ from each other, the description in the body of the manual takes precedence. 1.
Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website.