APPLICATION NOTERenesas USB Device                                                                                        ...
USB Basic Firmware1.     Document Overview     1.1      OverviewThis document is an instruction manual for the Renesas USB...
USB Basic Firmware2.     Overview     2.1     Features of USB-BASIC-F/WThe main features of USB-BASIC-F/W are as follows. ...
USB Basic Firmware  2.4             Task ConfigurationIn peripheral function mode, USB-BASIC-F/W comprises the peripheral ...
USB Basic FirmwareTable 2.1     Task FunctionsNo.   Module Name                                        Function1     USB i...
USB Basic Firmware          usbc_cstd_Main                   MainInit               Task                                  ...
USB Basic Firmware              usbc_cstd_Main                                                                MainInit    ...
USB Basic Firmware  2.7       Non-OS Task Operation ExampleAn example of the operation of a USB-BASIC-F/W task is shown be...
USB Basic Firmware  2.8       uITRON Task-Related OperationOperation related to USB-BASIC-F/W tasks is shown below.       ...
USB Basic Firmware3.     Using USB-BASIC-F/W     3.1      OverviewUSB-BASIC-F/W is a USB driver that is adapted for the cu...
USB Basic FirmwareTable 3.1    List of FunctionsType           Function                                                   ...
USB Basic Firmware                     HDCD_Task                                        No                 USBC_TRCV_MSG? ...
USB Basic Firmware4.     User-Defined Macros     4.1       OverviewUSB-BASIC-F/W includes macros for hardware register acc...
USB Basic Firmware4.1.2       uITRON System Call MacroThe uITRON system call macro is shown below.Modify the code as neces...
USB Basic Firmware4.1.3       Debug Information Output MacrosThis type of macro outputs debug information to a UART or dis...
USB Basic Firmware4.1.5        Register Bit Set/Clear/Modify MacrosThis type of macro sets, clears, or modifies the value ...
USB Basic Firmware5.     User-Defined Information     5.1      OverviewAn executable file customized to the customer’s req...
USB Basic Firmware5.2.3       597IP Function Designation (Number of Pipe)The number of pipe may be specified as either of ...
USB Basic Firmware5.2.8       USB Port DesignationThe USB port may be specified as either of the following two options.1) ...
USB Basic Firmware5.2.12      Create System call Designation (uITRON)It may be specified as either of the following two op...
USB Basic Firmware5.2.17       Software Retry Count at Pipe No-Response (Host Function Mode)It is necessary to specify the...
USB Basic Firmware5.2.21        User System Definition Information for Each DevicesThe user system definition information ...
USB Basic FirmwareTable 5.2      For the RX630, the user system definition information (r_usbc_cDefUsr.h)Section        Fl...
USB Basic FirmwareTable 5.3      For the R8A66597, the user system definition information (r_usbc_cDefUsr.h)Section       ...
USB Basic Firmware     5.3       User-Defined Information File (r_usb_cDefUsr.h)1.   USB Function designation2.   Power Co...
USB Basic Firmware5.3.4        Sleep Mode DesignationThe sleep mode may be specified as one of the following two options.1...
USB Basic Firmware5.3.7       User System Definition Information for Each DeviceThe user system definition information for...
USB Basic Firmware6.     Workspace     6.1      OverviewThe workspace of USB-BASIC-F/W is described below.Workspace of USB...
USB Basic Firmware  6.2        Structure of Files and folders6.2.1       Folder StructureThe folder structure in which the...
USB Basic Firmware6.2.2       List of FilesThe files provided in USB-BASIC-F/W are listed below. The files of USB2STDFW fo...
USB Basic Firmware                                                                               Project                  ...
USB Basic Firmware                                                                            Project                     ...
USB Basic Firmware7.     Sample Applications     7.1     Sample application for Data transfer (APL)USB-BASIC-F/W supports ...
USB Basic Firmware7.1.2      APL Global AreaThe APL global area in USB-BASIC-F/W is shown below.Table 7.1 List of APL glob...
USB Basic FirmwareTable 7.2 List of APL global area (Host function mode)     Type             Variable                    ...
USB Basic Firmware7.1.3      APL Constant DefinitionThe APL constant definition in USB-BASIC-F/W is shown below.Table 7.3 ...
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Eekol 2012 jan04_int_ems_an_01
Upcoming SlideShare
Loading in...5
×

Eekol 2012 jan04_int_ems_an_01

417

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
417
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Eekol 2012 jan04_int_ems_an_01"

  1. 1. APPLICATION NOTERenesas USB Device R01AN0512EJ0110 Rev.1.10USB Basic Firmware Jun 10, 2011IntroductionThis document is an instruction manual for the Renesas USB Device USB basic firmware, a sample program for USBinterface control using the Renesas USB Device.Target DeviceRX62N, RX630 and R8A66597Contents 1. Document Overview .......................................................................................................................... 2 2. Overview ........................................................................................................................................... 3 3. Using USB-BASIC-F/W................................................................................................................... 10 4. User-Defined Macros ...................................................................................................................... 13 5. User-Defined Information ................................................................................................................ 17 6. Workspace ...................................................................................................................................... 28 7. Sample Applications........................................................................................................................ 33 8. Peripheral Driver (PCD) .................................................................................................................. 41 9. Peripheral Control Transfer............................................................................................................. 53 10. Host Driver (HCD) ........................................................................................................................... 56 11. Host Control Transfer ...................................................................................................................... 65 12. Host Manager (MGR) ...................................................................................................................... 74 13. Non-OS Scheduler .......................................................................................................................... 89 14. uITRON System .............................................................................................................................. 97 15. HUB class driver(HUBCD) .............................................................................................................. 99 16. Data Transfer ................................................................................................................................ 105 17. DTC Transfer................................................................................................................................. 116 18. EXDMA Transfer ........................................................................................................................... 121 19. Restrictions.................................................................................................................................... 125R01AN0512EJ0110 Rev.1.10 Page 1 of 126Jun 10, 2011
  2. 2. USB Basic Firmware1. Document Overview 1.1 OverviewThis document is an instruction manual for the Renesas USB Devices USB basic firmware, a sample program for USBinterface control using the Renesas USB Devices.This firmware includes uITRON ver. and OS less ver.This document is intended to be used together with the device’s data sheet. 1.2 Related Documents[1] Universal Serial Bus Revision 2.0 Specification [http://www.usb.org/developers/docs/][2] Renesas USB Device Hardware Manual Available from the Renesas websiteRenesas Website [http://www.renesas.com/index.html]USB Device Page [http://www.renesas.com/prod/usb/] 1.3 List of TermsTerms and abbreviations used in this document are listed below.USB: Universal Serial BusUSB-BASIC-F/W: USB basic firmware for Renesas USB Device (non-OS/uITRON)non-OS: USB basic firmware for OS less systemuITRON: USB basic firmware for uITRON systemHEW: High-performance Embedded WorkshopPCD: Peripheral control driver of USB-BASIC-F/WPDCD: Peripheral device class driver (device driver and USB class driver)HCD: Host control driver of USB-BASIC-F/WMGR: Peripheral device state manager of HCDHDCD: Host device class driver (device driver and USB class driver)HUBCD: Hub class sample driverAPL: Application programHTST: Host electrical testTask: Processing unitscheduler: Used to schedule functions, like a simplified OSScheduler macro: Used to call a scheduler function (non-OS)R01AN0512EJ0110 Rev.1.10 Page 2 of 126Jun 10, 2011
  3. 3. USB Basic Firmware2. Overview 2.1 Features of USB-BASIC-F/WThe main features of USB-BASIC-F/W are as follows. [Overall]• Can control RX62N, RX630 and R8A66597 by common source code.• Can use same source code in uITRON or non-OS.• Can operate in either host function or peripheral function mode.• Multiple device class drivers may be installed without the need to customize USB-BASIC-F/W. (Device class drivers can be registered up to the maximum number of devices that can be connected.) [Host function mode]• When a no-response condition is detected during data transfer, the transfer is retried (n retries per transfer on the same pipe: specified by user in file r_usbc_cDefUsr.h).• Common API for control transfer, bulk transfer and interrupt transfer is provided.• API for devices connect/disconnect processing is provided.• API for suspend/resume processing is provided.• HUBCD sample program code is provided.• Sample application for data transfer is added. (This application operates as Vendor class.)• A single pipe can perform multiple exclusive data communication tasks in order to manage HDCD pipe information tables. [Peripheral function mode]• Operation can be confirmed by using USBCommandVerifier.exe. (USBCV is available for download from http://www.usb.org/developers/developers/tools/.)• API for control transfer is provided.• Common API for bulk transfer and interrupt transfer is provided.• API for devices connect/disconnect processing is provided.• API for suspend/resume processing is provided.• Sample application for data transfer is added. (This application operates as Vendor class.)The following functions must be provided by the customer to match the system under development.• Overcurrent detection processing when connecting USB cables (host function mode).• Descriptor analysis (host function mode).• Device class driver 2.2 Development GoalsUSB-BASIC-F/W was developed with the following goals in mind.• To simplify the development of USB communication programs by customers using Renesas USB Device.• To provide source code examples for hardware control of USB. 2.3 FunctionsThe functions provided by USB-BASIC-F/W are as follows.• In host function mode, enumeration as low-speed/full-speed/high-speed device (However, operating speed is different by devices ability.)• In peripheral function mode, enumeration as USB1.1/2.0/3.0 host• Device connect/disconnect, suspend/resume, and USB bus reset processing• Control transfer on pipe 0• Data transfer on pipes 1 to 9 (bulk or interrupt transfer: CPU access/DTC or DMA access)• Transfer error determination and transfer retryR01AN0512EJ0110 Rev.1.10 Page 3 of 126Jun 10, 2011
  4. 4. USB Basic Firmware 2.4 Task ConfigurationIn peripheral function mode, USB-BASIC-F/W comprises the peripheral driver, which controls H/W, and theapplication. In host function mode, USB-BASIC-F/W comprises the host driver, which controls H/W, the manager,which manages device states, the hub class driver, which controls devices connected to the down ports of the USB hub,and the application.Peripheral driver and host driver initiate hardware control according to messages from the various tasks or interrupthandler. They also notify the appropriate task when hardware control ends, of processing results, and of hardwarerequests.Manager manages the states of devices connected and performs enumeration. In addition, manager issues a message tohost driver or hub class driver when the application changes the device state. Hub class driver is sample program codefor managing the states of devices connected to the down ports of the USB hub and performing enumeration. uITRON Scheduler Function non-OS Figure 2.1 Task Configuration of USB-BASIC-F/WR01AN0512EJ0110 Rev.1.10 Page 4 of 126Jun 10, 2011
  5. 5. USB Basic FirmwareTable 2.1 Task FunctionsNo. Module Name Function1 USB interrupt handler • USB interrupt handler void usb_cstd_UsbHandler(void) (USB packet transmit/receive end and special signal detection)2 Peripheral driver (PCD) • Hardware control in peripheral function mode void • Peripheral transaction management usb_pstd_PcdTask(USBC_VP_INT_t)3 Host driver (HCD) • Hardware control in host function mode void • Host transaction management usb_hstd_HcdTask(USBC_VP_INT_t)4 Host manager (MGR) • Device state management void • Enumeration usb_hstd_MgrTask(USBC_VP_INT_t) • HCD/HUBCD control message determination5 Hub class driver (HUBCD) • HUB down port device state management void usb_hhub_Task(USBC_VP_INT_t) • HUB down port enumeration6 Device class driver (PDCD/HDCD) Provided by the customer as appropriate for the system.7 Device driver (HDD) Provided by the customer as appropriate for the system.8 Application (APL) Provided by the customer as appropriate for the system. 2.5 Non-OS Scheduler FunctionA scheduler function manages requests generated by the tasks and hardware according to the relative priority of thetasks. When multiple requests are generated by tasks with the same priority, they are executed using a FIFOconfiguration. To assure commonality with non-OS and uITRON-compatible firmware, requests between tasks areimplemented by transmitting and receiving messages. In addition, call-back functions are used for responses to tasksindicating the end of a request, so the customer need only install appropriate class drivers for the system and there is noneed to modify the scheduler itself. 2.6 Sequence OutlineLike USB-BASIC-F/W comprises usbc_cstd_MainTask, MainInit, MainLoop and usb_cstd_UsbHandler. In non-OS,the compositions add scheduler.When an interrupt occurs, the function mode that is selected by USB operational mode setting is checked andnotification is sent by means of a message to PCD/HCD. When the PCD or HCD task receives a message from the USBinterrupt handler, it determines the interrupt source and executes the appropriate processing. (For a sequence outline ofPCD/HCD task, see sections 8 and 10.)The PCD or HCD is selected by USB function setting. (For a USB function setting, see sections 5.)R01AN0512EJ0110 Rev.1.10 Page 5 of 126Jun 10, 2011
  6. 6. USB Basic Firmware usbc_cstd_Main MainInit Task Initialize USB MainInit() function Register driver Start Idle Task usb_cstd_UsbHandler Initialize scheduler function USBC_HOST_PP Operating mode? MainLoop() Set priority USBC_PERI_PP Set USB Clear interrupt Clear interrupt Idle Task operating mode source source Send message Send message Return to PCD to HCD Return USB_FUNCSEL_PP == USB_FUNCSEL_PP == Task USBC_PERI_PP USBC_HOST_PP No USBC_TRCV_MSG? MainLoop MainLoop Yes Application Application Processing No No Tasks starting is Task processing Task processing Return controlled flag set? flag set? by scheduler Yes Yes Scheduler PCD task HCD task No PDCD task MGR task Processing request? HUB task Yes Select request with Scheduler HDCD task top priority Return Set task Scheduler processing flag Return Return Figure 2.2 Sequence Outline (non-OS)R01AN0512EJ0110 Rev.1.10 Page 6 of 126Jun 10, 2011
  7. 7. USB Basic Firmware usbc_cstd_Main MainInit Task Initialize USB MainInit() function Start Idle task Start PCD task Start MGR task Start HCD task MainLoop() Register driver Set USB operating mode Return Task usb_cstd_UsbHandler USBC_HOST_PP Operating mode? USBC_TRCV_MSG? USBC_PERI_PP Clear interrupt Clear interrupt Processing source source Send message Send message to PCD to HCD Return Figure 2.3 Sequence Outline (uITRON)R01AN0512EJ0110 Rev.1.10 Page 7 of 126Jun 10, 2011
  8. 8. USB Basic Firmware 2.7 Non-OS Task Operation ExampleAn example of the operation of a USB-BASIC-F/W task is shown below. Execution request received by MGR task in host function mode Note: Operation is the same in peripheral function mode. Execution request MainLoop HCD task MGR task execution Application No USBC_TRCV_MSG? No Yes Flag set ? Processing Yes HCD task Return MGR task MGR task HUB task No USBC_TRCV_MSG? HDCD task Yes Processing Scheduler Return return HUB task No USBC_TRCV_MSG? Yes Processing Return HDCD task No USBC_TRCV_MSG? Yes Processing Return Figure 2.4 Task Operation Example (non-OS)R01AN0512EJ0110 Rev.1.10 Page 8 of 126Jun 10, 2011
  9. 9. USB Basic Firmware 2.8 uITRON Task-Related OperationOperation related to USB-BASIC-F/W tasks is shown below. Figure 2.5 Task-Related Operation (uITRON)R01AN0512EJ0110 Rev.1.10 Page 9 of 126Jun 10, 2011
  10. 10. USB Basic Firmware3. Using USB-BASIC-F/W 3.1 OverviewUSB-BASIC-F/W is a USB driver that is adapted for the customer’s system by making changes to the non-OSscheduler macros or uITRON system control macros (r_usbc_cItron.h, r_usbc_cMacSystemcall.h), user information(r_usbc_cDefUsr.h, r_usb_cDefUsr.h), and non-OS settings (r_usbc_cKernelId.h, main.c, r_usb_PSMPL_apl.c,r_usb2_HSMPL_apl.c) to add HDCD and PDCD tasks. 3.2 Changing USB-BASIC-F/WIn order to use USB-BASIC-F/W, it is necessary to make changes to the following program code and header files.1. It is necessary select the project and the build configuration in USB-BASIC-F/W. ⎯ Select the project of the non-OS or uITRON from HEW project, and select the build configuration of the appropriate function (Host mode or Peripheral mode) for the system under development from HEW build configuration in USB-BASIC-F/W and set the selected project in the active condition.2. Sample application source code for executing data transfer is provided. These should be changed as needed to match the system under development. ⎯ Initialization of the control MCU, interrupt handlers, interrupt control, DTC or DMA control, etc. (See table 3.1.) ⎯ For the non-OS, adjustments to the duration of the specified wait time functions (usbc_cpu_DelayXms() function, usbc_cpu_Delay1us() function) ⎯ For the non-OS, settings of functions that disable or enable USB-related interrupts in order to use the scheduler function (usb_cstd_IntDisable() function, usb_cstd_IntEnable() function) The USB interrupt disable function (usb_cstd_IntDisable() function) and USB interrupt enable function (usb_cstd_IntEnable() function) disable and enable, respectively. Make any necessary changes to the settings to match the MCU being used.3. For using R8A66597, it is necessary to make changes to the hardware settings in the usb_cstd_Pinconfig function in r_usb_cSignal.c to match the system under development. Make sure to refer to section 5 regarding the definitions for the settings. ⎯ External bus operating voltage (set by user-defined information) ⎯ FIFO access endian specification (common with CPU endian mode: set by user-defined information) ⎯ Interrupt pin operation level ⎯ DMA pin operation level ⎯ BRDY interrupt operating mode ⎯ SOF pin operating mode ⎯ Low-power sleep operation specification (set by user-defined information)4. Some files must be customized by the customer. ⎯ Refer to 5, User-Defined Information, and make appropriate changes to the user settings.5. Debug Information Output Function ⎯ Make the appropriate settings in the file r_usbc_cMacPrint.h to enable or disable output of debug information. (Debug information can be output by creating a serial driver, or the like.)R01AN0512EJ0110 Rev.1.10 Page 10 of 126Jun 10, 2011
  11. 11. USB Basic FirmwareTable 3.1 List of FunctionsType Function Descriptionvoid usb_cstd_TargetInit(void) System initializationvoid usb_cstd_UsbIntHand(void) USB interrupt handlervoid usb_cstd_Dma0/1IntHand(void) DTC/DMA interrupt handlervoid usbc_cpu_UsbintInit(void) USB interrupt enablevoid usbc_cpu_DmaintInit(void) DTC/DMA interrupt enableuint16_t usb_cstd_D0fifo2BufStartDma(uint32_t SourceAddr) DTC/DMA read startuint16_t usb_cstd_Buf2D0fifoStartDma(uint32_t DistAddr) DTC/DMA write startvoid usb_cstd_StopDma(void) DTC/DMA stopvoid usb_cstd_IntEnable(void) USB interrupt enable for scheduler function of non-OSvoid usb_cstd_IntDisable(void) USB interrupt disable for scheduler function of non-OSvoid usbc_cpu_Delay1us(uint16_t time) 1us delayvoid usbc_cpu_DelayXns(uint16_t time) 1ms delay 3.3 Creating HDCD and PDCD TasksUSB-BASIC-F/W includes sample application source code for executing data transfer, it is necessary to create HDCDor PDCD tasks to match the system under development. It must also be configured to enable control of the schedulerfunction of the non-OS firmware.For the non-OS, HDCD or PDCD tasks should be configured to run USBC_TRCV_MSG at the start of processing, andin case of USBC_NG, to end the function.For the non-OS, the following processing routines must be added to HDCD to enable control by the scheduler function.Refer to the sample application function (usb2_hstd_MainTask() function).1. Class check processing (to check the class driver during enumeration)2. Initialization processing3. Enumeration waits processing (so that when multiple devices are attached, the other devices wait until enumeration of the current device ends) Note: RX62N does not require this processing.4. Task processing (created to match the system)For non-OS, the following processing routines must be added to PDCD to enable control by the scheduler function.Refer to the sample function (usb_pstd_MainTask() function).5. Task processing (created to match the system)R01AN0512EJ0110 Rev.1.10 Page 11 of 126Jun 10, 2011
  12. 12. USB Basic Firmware HDCD_Task No USBC_TRCV_MSG? Yes R8A66597 only Processing contents USB_MSG USB_MSG USB_MSG USB_MSG_CLS_ _CLS_INIT _CLS_WAIT _CLS_TASK CHECKREQUEST 1. Class check 2. Initialization 3. Enumeration 4. Task processing processing wait processing processing enumeration Return PDCD_Task USBC_TRCV_MSG ? 5. Task processing Return Figure 3.1 PDCD/HDCD Sequence for non-OS 3.4 NoteThe customer will need to make a variety of customizations, for example designating classes, issuing vendor-specificrequests, making settings with regard to the communication speed or program capacity, or making individual settingsthat affect the user interface.Note: USB-BASIC-F/W is not guaranteed to provide USB communication operation. The customer should verify operation when utilizing it in a system and confirm the ability to connect to a variety of different types of devices.R01AN0512EJ0110 Rev.1.10 Page 12 of 126Jun 10, 2011
  13. 13. USB Basic Firmware4. User-Defined Macros 4.1 OverviewUSB-BASIC-F/W includes macros for hardware register access (including FIFO access), so an executable filecustomized to the customer’s requirements can be generated by rewriting the macro header files. Make appropriatechanges to the macros for accessing the registers and FIFOs to match the system under development. The macroscomprise the six types listed below. Scheduler macros are defined in (r_usbc_cMacSystemcall.h), debug output macrosin (r_usbc_cMacPrint.h), and register access macros in (r_usb_cMacUsr.h).1. Non-OS scheduler macros2. uITRON system call macros3. Debug output macros4. Register and FIFO data register read/write macros5. Register bit set/clear/modify macros6. Status register bit clear macro7. Status register bit set macro4.1.1 Non-OS Scheduler MacrosUSB-BASIC-F/W includes the file r_usbc_cScheduler.c, which contains functions for registering the scheduler macrosUSBC_SND_MSG, USBC_ISND_MSG, USBC_WAI_MSG, USBC_TRCV_MSG, USBC_PGET_BLK, andUSBC_REL_BLK. Functions are registered to scheduler macros in r_usbc_cMacSystemcall.h.[Function registration example] #define USBC_SND_MSG(ID, MESS) usbc_cstd_SndMsg((uint8_t)ID,(USBC_MSG_t*)MESS) #define USBC_ISND_MSG(ID, MESS) usbc_cstd_iSndMsg((uint8_t)ID,(USBC_MSG_t*)MESS) #define USBC_WAI_MSG(ID, MESS, TM) usbc_cstd_WaiMsg((uint8_t)ID, (USBC_MSG_t*)MESS, (uint16_t)TM) #define USBC_TRCV_MSG(ID, MESS, TM) usbc_cstd_RecMsg((uint8_t)ID,(USBC_MSG_t**)MESS,(USBC_TM_t)TM) #define USBC_PGET_BLK(ID, BLK) usbc_cstd_PgetBlk((uint8_t)ID,(USBC_MH_t*)BLK) #define USBC_REL_BLK(ID, BLK) usbc_cstd_RelBlk((uint8_t)ID,(USBC_MH_t)BLK)[USB_NG registration example] #define USBC_CRE_TSK(ID,INFO) USBC_NGR01AN0512EJ0110 Rev.1.10 Page 13 of 126Jun 10, 2011
  14. 14. USB Basic Firmware4.1.2 uITRON System Call MacroThe uITRON system call macro is shown below.Modify the code as necessary to match the ITRON version used.Note that ITRON macros are redefined for USB-BASIC-F/W in the file r_usbc_cMacSystemcall.h, so the ITRONmacros are defined by conditional compilation even when ITRON is not used. Therefore, this file should be also bemodified to match the ITRON version used. #define USBC_CRE_TSK(ID,INFO) cre_tsk( (USBC_ID_t)ID, (USBC_TSK_t*)INFO ) #define USBC_DEL_TSK(ID) del_tsk( (USBC_ID_t)ID ) #define USBC_STA_TSK(ID,CODE) sta_tsk( (USBC_ID_t)ID, (USBC_VI_t)CODE ) #define USBC_ACT_TSK(ID) act_tsk( (USBC_ID_t)ID ) #define USBC_TER_TSK(ID) ter_tsk( (USBC_ID_t)ID ) #define USBC_EXT_TSK() ext_tsk( ) #define USBC_REF_TST(ID, STS) ref_tst( (USBC_ID_t)ID, (USBC_RTST_t*)STS ) #define USBC_DLY_TSK(TIME) dly_tsk( (USBC_RT_t)TIME ) #define USBC_CRE_MBX(ID, INFO) cre_mbx( (USBC_ID_t)ID, (USBC_MBX_t*)INFO ) #define USBC_DEL_MBX(ID) del_mbx( (USBC_ID_t)ID ) #define USBC_SND_MSG(ID, MESS) snd_mbx( (USBC_ID_t)ID, (USBC_MSG_t*)MESS ) #define USBC_ISND_MSG(ID, MESS) isnd_mbx( (USBC_ID_t)ID, (USBC_MSG_t*)MESS ) #define USBC_RCV_MSG(ID, MESS) rcv_mbx( (USBC_ID_t)ID, (USBC_MSG_t**)MESS ) #define USBC_PRCV_MSG(ID, MESS) prcv_mbx( (USBC_ID_t)ID, (USBC_MSG_t**)MESS ) #define USBC_TRCV_MSG(ID, MESS, TM) trcv_mbx( (USBC_ID_t)ID, (USBC_MSG_t**)MESS, (USBC_TM_t)TM ) #define USBC_CRE_MPL(ID, INFO) cre_mpf( (USBC_ID_t)ID, (USBC_MPL_t*)INFO ) #define USBC_DEL_MPL(ID) del_mpf( (USBC_ID_t)ID ) #define USBC_PGET_BLK(ID, BLK) pget_mpf( (USBC_ID_t)ID, (USBC_MH_t*)BLK ) #define USBC_IPGET_BLK(ID, BLK) ipget_mpf( (USBC_ID_t)ID, (USBC_MH_t*)BLK ) #define USBC_REL_BLK(ID, BLK) rel_mpf( (USBC_ID_t)ID, (USBC_MH_t)BLK ) #define USBC_CRE_SEM(ID, INFO) cre_sem( (USBC_ID_t)ID, (USBC_SEM_t*)INFO ) #define USBC_WAI_SEM(ID) wai_sem( (USBC_ID_t)ID ) #define USBC_POL_SEM(ID) pol_sem( (USBC_ID_t)ID ) #define USBC_SIG_SEM(ID) sig_sem( (USBC_ID_t)ID ) #define USBC_CRE_ALM(ID, INFO) cre_alm( (USBC_ID_t)ID, (USBC_ALM_t*)INFO ) #define USBC_STA_ALM(ID, TIME) sta_alm( (USBC_ID_t)ID, (USBC_RT_t)TIME ) #define USBC_STP_ALM(ID) stp_alm( (USBC_ID_t)ID ) #define USBC_DEL_ALM(ID) del_alm( (USBC_ID_t)ID )R01AN0512EJ0110 Rev.1.10 Page 14 of 126Jun 10, 2011
  15. 15. USB Basic Firmware4.1.3 Debug Information Output MacrosThis type of macro outputs debug information to a UART or display device. A serial driver or display device driver isrequired. #define USBC_SPRINTF0(FORM) fprintf(stderr,FORM) #define USBC_SPRINTF1(FORM,x1) fprintf(stderr,FORM,x1) #define USBC_SPRINTF2(FORM,x1,x2) fprintf(stderr,FORM,x1,x2) #define USBC_SPRINTF3(FORM,x1,x2,x3) fprintf(stderr,FORM,x1,x2,x3) #define USBC_SPRINTF4(FORM,x1,x2,x3,x4) fprintf(stderr,FORM,x1,x2,x3,x4) #define USBC_SPRINTF5(FORM,x1,x2,x3,x4,x5) fprintf(stderr,FORM,x1,x2,x3,x4,x5) #define USBC_SPRINTF6(FORM,x1,x2,x3,x4,x5,x6) fprintf(stderr,FORM,x1,x2,x3,x4,x5,x6) #define USBC_SPRINTF7(FORM,x1,x2,x3,x4,x5,x6,x7) fprintf(stderr,FORM,x1,x2,x3,x4,x5,x6,x7) #define USBC_SPRINTF8(FORM,x1,x2,x3,x4,x5,x6,x7,x8) fprintf(stderr,FORM,x1,x2,x3,x4,x5,x6,x7,x8) #define USBC_PRINTF0(FORM) printf(FORM) #define USBC_PRINTF1(FORM,x1) printf(FORM,x1) #define USBC_PRINTF2(FORM,x1,x2) printf(FORM,x1,x2) #define USBC_PRINTF3(FORM,x1,x2,x3) printf(FORM,x1,x2,x3) #define USBC_PRINTF4(FORM,x1,x2,x3,x4) printf(FORM,x1,x2,x3,x4) #define USBC_PRINTF5(FORM,x1,x2,x3,x4,x5) printf(FORM,x1,x2,x3,x4,x5) #define USBC_PRINTF6(FORM,x1,x2,x3,x4,x5,x6) printf(FORM,x1,x2,x3,x4,x5,x6) #define USBC_PRINTF7(FORM,x1,x2,x3,x4,x5,x6,x7) printf(FORM,x1,x2,x3,x4,x5,x6,x7) #define USBC_PRINTF8(FORM,x1,x2,x3,x4,x5,x6,x7,x8) printf(FORM,x1,x2,x3,x4,x5,x6,x7,x8)If no debug information will be output, the following lines should be commented out as shown. //#define USBC_DEBUGSIO_PP /* enable serial out (printf) */ //#define USBC_DEBUGLCD_PP /* enable display out (lprintf) */4.1.4 Register and FIFO Data Register Read/Write MacrosThis type of macro performs read or write access to registers or FIFO port registers. #define USB_RD( r, v ) do { (( v ) = ( USB_IP.r.WORD )); } while(0) #define USB_WR( r, v ) do { (( USB_IP.r.WORD ) = ( v )); } while(0) #define USB_RDW( r, v ) do { (( v ) = ( USB_IP.r )); } while(0) #define USB_WRW( r, v ) do { (( USB_IP.r ) = ( v )); } while(0) #define USB_RD_FF( r, v ) do { (( v ) = ( USB_IP.r )); } while(0) #define USB_WR_FF( r, v ) do { (( USB_IP.r ) = ( v )); } while(0)R01AN0512EJ0110 Rev.1.10 Page 15 of 126Jun 10, 2011
  16. 16. USB Basic Firmware4.1.5 Register Bit Set/Clear/Modify MacrosThis type of macro sets, clears, or modifies the value of bits in registers.Each macro is written to accommodate the RMW (Read Modify Write) instruction, and it uses a register and FIFO dataregister read/write macro of the type mentioned above.Notes: 1. These macros do not need to be modified by the customer. 2. Do not use the bit clear macro to clear bits in status registers. /* set bit(s) of USB register */ /* r : USB register */ /* v : value to set */ #define USB_SET_PAT( r, v ) do { (( USB_IP.r.WORD ) |= ( v )); } while(0) /* reset bit(s) of USB register */ /* r : USB register */ /* m : bit pattern to reset */ #define USB_CLR_PAT( r, m ) do { (( USB_IP.r.WORD ) &= ( (uint16_t)(~(m)) )); } while(0) /* modify bit(s) of USB register */ /* r : USB register */ /* v : value to set */ /* m : bit pattern to modify */ #define USB_MDF_PAT( r, v, m ) do { uint16_t mtmp; USB_RD( r, mtmp ); mtmp &= ( (uint16_t)(~(m)) ); mtmp |= ( (uint16_t)(v & m) ); USB_WR( r, mtmp ); } while(0)4.1.6 Status Register Bit Clear MacroThis macro clears bits in status registers.This macro is written to accommodate the RMW (Read Modify Write) instruction, and it uses a register and FIFO dataregister read/write macro of the type mentioned above. This macro is designed to avoid deleting status bits that havechanged during the execution of the RMW instruction.Notes: 1. This macro does not need to be modified by the customer. 2. This macro should only be used for status registers where writing 1 has no effect. /* reset bit(s) of USB status */ /* r : USB register */ /* m : bit pattern to reset */ #define USB_CLR_STS( r, m ) USB_WR( r, ( (uint16_t)(~(m)) ) )R01AN0512EJ0110 Rev.1.10 Page 16 of 126Jun 10, 2011
  17. 17. USB Basic Firmware5. User-Defined Information 5.1 OverviewAn executable file customized to the customer’s requirements can be generated by rewriting the user system definitioninformation file (r_usbc_cDefUsr.h) and user-defined information file (r_usb_cDefUsr.h) included in USB-BASIC-F/W.The items listed below should be changed to match the system under development. 5.2 User System Definition Information File (r_usbc_cDefUsr.h)1. Target device designation2. Installed USB-IP type designation3. 597IP function designation (number of Pipe)4. 597IP function designation (number of Device Address)5. 597IP function designation (buffer size)6. Transfer speed designation7. Bus width designation8. USB port designation9. External bus operating voltage designation10. Oscillating frequency of connected resonator11. Operating environment designation12. Create Systemcall designation (uITRON)13. CPU byte endian designation14. DTC/DMA designation15. Low Power Mode designation16. PID = NAK setting at transfer end enable designation (peripheral function mode)17. Software retry count at pipe no-response (host function mode)18. Control read data buffer size (host function mode)19. Device address initial value (host function mode)20. Hub down port count (host function mode)5.2.1 Target Device DesignationThe target device may be specified as either of the following two options.1) USBC_ASSP_PP: R8A665972) USBC_RX600_PP: RX62N or RX630Example: RX62N or RX630 #define USBC_TARGET_CHIP_PP USBC_RX600_PPThis setting is selected by the macro definition of HEW project in USB-BASIC-F/W.The macro definition is selected from option category in Standard toolchain of compiler tab.5.2.2 Installed USB-IP Type DesignationThe USB-IP type may be specified as either of the following three options.1) USBC_592IP_PP: Installed 592IP2) USBC_596IP_PP: Installed 596IP3) USBC_597IP_PP: Installed 597IPExample: Installed 597IP #define USBC_IPSEL_PP USBC_597IP_PPR01AN0512EJ0110 Rev.1.10 Page 17 of 126Jun 10, 2011
  18. 18. USB Basic Firmware5.2.3 597IP Function Designation (Number of Pipe)The number of pipe may be specified as either of the following two options.1) USBC_IP_PIPE_9_PP: 1-9 of PIPE use2) USBC_IP_PIPE_7_PP: 1-7 of PIPE useExample: 1-9 of PIPE use #define USBC_IP_PIPE_PP USBC_IP_PIPE_9_PP5.2.4 597IP Function Designation (Number of Device Address)The number of device address may be specified as either of the following two options.1) USBC_IP_DEVADD_A_PP: 10 device address use2) USBC_IP_DEVADD_5_PP: 5 device address useExample: 5 device address use #define USBC_IP_DEVADD_PP USBC_IP_DEVADD_5_PP5.2.5 597IP Function Designation (Buffer Size)The buffer type may be specified as either of the following two options.1) USBC_PIPEBUFF_FIX_PP: PIPEBUF is fixation2) USBC_PIPEBUFF_CHANGE_PP: PIPEBUF is changeableExample: PIPEBUF is fixation #define USBC_PIPEBUF_MODE_PP USBC_PIPEBUF_CHANGE_PP5.2.6 Transfer Speed DesignationThe target speed may be specified as either of the following two options.1) USBC_HS_PP: High-Speed support2) USBC_FS_PP: Full-Speed supportExample: Full-Speed support #define USBC_SPEEDSEL_PP USBC_FS_PP5.2.7 Bus Width DesignationThe bus width may be specified as either of the following two options.1) USBC_BUSSIZE_16_PP: 16 bits2) USBC_BUSSIZE_32_PP: 32 bitsExample: 16 bits #define USBC_BUSSIZE_PP USBC_BUSSIZE_16_PPR01AN0512EJ0110 Rev.1.10 Page 18 of 126Jun 10, 2011
  19. 19. USB Basic Firmware5.2.8 USB Port DesignationThe USB port may be specified as either of the following two options.1) USBC_1PORT_PP: 1 USB Port use2) USBC_2PORT_PP: 2 USB Ports useExample: 1 USB Port use #define USBC_PORTSEL_PP USBC_1PORT_PP5.2.9 Operating Environment DesignationThe operating environment may be specified as either of the following two options.1) USBC_FW_OS_PP: OS support2) USBC_FW_NONOS_PP: No OS supportExample: No OS support #define USBC_FW_PP USBC_FW_NONOS_PPThis setting is selected by the macro definition of HEW project in USB-BASIC-F/W.The macro definition is selected from option category in Standard toolchain of compiler tab.5.2.10 External Bus Operating Voltage DesignationThe external bus operating voltage may be specified as either of the following two options.1) USBC_VIF1: 1.8 V applied to external bus pins.2) USBC_VIF3: 3.3 V external bus pins.Example: 3.3 V #define USB_LDRVSEL USBC_VIF3For the RX62N and RX630, use the USBC_VIF3 setting.5.2.11 Oscillating Frequency of Connected ResonatorOscillating frequency of connected resonator may be specified as one of the following three options.1) USBC_XTAL48: 48 MHz resonator connected.2) USBC_XTAL24: 24 MHz resonator connected.3) USBC_XTAL12: 12 MHz resonator connected.Example: 24 MHz resonator #define USBC_XINSEL USBC_XTAL24For the RX62N and RX630. Use the USBC_XTAL24 setting.R01AN0512EJ0110 Rev.1.10 Page 19 of 126Jun 10, 2011
  20. 20. USB Basic Firmware5.2.12 Create System call Designation (uITRON)It may be specified as either of the following two options that the Task Creation System call is supported or notsupported.1) USBC_OS_CRE_USE_PP: Task Creation System call support2) USBC_OS_CRE_NOTUSE_PP: No Task Creation System call supportExample: No Task Creation System call support #define USBC_OS_CRE_MODE_PP USBC_OS_CRE_NOTUSE_PP5.2.13 CPU Byte Endian DesignationThe CPU byte endian may be specified as either of the following two options.This setting is for CPU access to FIFO.1) USBC_BYTE_LITTLE_PP: Little Endian (Definition from upper byte)2) USBC_BYTE_BIG_PP: Big Endian (Definition from under byte)Example: Little endian #define USBC_CPUBYTE_PP USBC_BYTE_LITTLE_PP5.2.14 DTC/DMA DesignationThe DTC/DMA may be specified as either of the following two options.1) USBC_TRANS_DMA_PP: DMA2) USBC_TRANS_DTC_PP: DTCExample: DTC #define USBC_TRANS_MODE_PP USBC_TRANS_DTC_PPThe RX62N and RX630 support only DTC. Use the USBC_TRANS_DTC_PP setting.5.2.15 Low Power Mode DesignationThe low power mode may be specified as either of the following two options.1) USBC_LPWR_NOT_USE_PP: Not low power mode2) USBC_ LPWR_USE_PP: Low power modeExample: Not low power mode #define USBC_LPWR_MODE_PP USBC_LPWR_NOT_USE_PPFor the R8A66597, use the USBC_LPWR_NOT_USE_PP setting.5.2.16 PID = NAK Setting at Transfer End Enable Designation (Peripheral Function Mode)It may be specified as either of the following two options that the PID = NAK set or not set at transfer end enable.1) USBC_NONPERIODIC_PP: PID = NAK2) USBC_PERIODIC_PP: No PID = NAKExample: PID = NAK #define USBC_PERIODIC_MODE_PP USBC_PERIODIC_PPR01AN0512EJ0110 Rev.1.10 Page 20 of 126Jun 10, 2011
  21. 21. USB Basic Firmware5.2.17 Software Retry Count at Pipe No-Response (Host Function Mode)It is necessary to specify the number of software retries when a no-response condition occurs during a transfer.Example: Up to one retry by USB-BASIC-F/W at pipe no-response #define USBC_PIPEERR 1u5.2.18 Control Read Data Buffer Size (Host Function Mode)It is necessary to specify the data buffer size when a control read transfer is received.Example: 20-byte device descriptor, 256-byte configuration descriptor #define USBC_DEVICESIZE 20u #define USBC_CONFIGSIZE 256u5.2.19 Device Address (Host Function Mode)It is necessary to specify the device address of the device connected to PORT0.Example: Device address starts from 2. #define USBC_DEVICEADDR 2uFor the RX62N, addresses in the range 1 to 5 may be specified.For the R8A66597, addresses in the range 1 to 10 may be specified.5.2.20 Hub Down Port Count (Host Function Mode)It is necessary to specify the number of hub down ports that can be connected.Example: Connected hub has 4 down ports. #define USBC_HUBDOWNPORT 4uR01AN0512EJ0110 Rev.1.10 Page 21 of 126Jun 10, 2011
  22. 22. USB Basic Firmware5.2.21 User System Definition Information for Each DevicesThe user system definition information for each device is shown below.Table 5.1 For the RX62N, the user system definition information (r_usbc_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.2.1 - USBC_TARGET_CHIP_PP o USBC_RX600_PP This setting is selected by the macro definition of HEW project.5.2.2 - USBC_IPSEL_PP o USBC_597IP_PP5.2.3 - USBC_IP_PIPE_PP o USBC_IP_PIPE_9_PP5.2.4 - USBC_IP_DEVADD_PP o USBC_IP_DEVADD_5_PP5.2.5 - USBC_PIPEBUF_MODE_PP o USBC_PIPEBUF_FIX_PP5.2.6 - USBC_SPEEDSEL_PP o USBC_FS_PP5.2.7 - USBC_BUSSIZE_PP o USBC_BUSSIZE_16_PP5.2.8 - USBC_PORTSEL_PP o USBC_1PORT_PP5.2.9 - USBC_LDRVSEL o USBC_VIF3 (NOT_USED)5.2.10 - USBC_XINSEL o USBC_XTAL245.2.11 O USBC_FW_PP USBC_FW_NONOS_PP This setting is USBC_FW_OS_PP selected by the macro definition of HEW project.5.2.12 O USBC_OS_CRE_MODE_PP o USBC_OS_CRE_NOTUSE_PP If USBC_OS_CRE_USE_PP USB_C_FW_NO NOS_PP setting in 5,2,11, use the default setting. If RI600 is used, use the default setting.5.2.13 O USBC_CPUBYTE_PP o USBC_BYTE_LITTLE_PP USBC_BYTE_BIG_PP5.2.14 - USBC_TRANS_MODE_PP o USBC_TRANS_DTC_PP5.2.15 O USBC_LPWR_MODE_PP o USBC_LPWR_NOT_USE_PP USBC_LPWR_USE_PP5.2.16 O USBC_PERIODIC_MODE_P o USBC_NONPERIODIC_PP P USBC_PERIODIC_PP5.2.17 O USBC_PIPEERROR o 1u5.2.18 O USBC_DEVICESIZE o 20u O USBC_CONFIGSIZE o 256u5.2.19 O USBC_DEVICEADDR o 1u5.2.20 O USBC_HUBDOWNPORT o 4u* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.R01AN0512EJ0110 Rev.1.10 Page 22 of 126Jun 10, 2011
  23. 23. USB Basic FirmwareTable 5.2 For the RX630, the user system definition information (r_usbc_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.2.1 - USBC_TARGET_CHIP_PP o USBC_RX600_PP This setting is selected by the macro definition of HEW project.5.2.2 - USBC_IPSEL_PP o USBC_597IP_PP5.2.3 - USBC_IP_PIPE_PP o USBC_IP_PIPE_9_PP5.2.4 - USBC_IP_DEVADD_PP o USBC_IP_DEVADD_5_PP5.2.5 - USBC_PIPEBUF_MODE_PP o USBC_PIPEBUF_FIX_PP5.2.6 - USBC_SPEEDSEL_PP o USBC_FS_PP5.2.7 - USBC_BUSSIZE_PP o USBC_BUSSIZE_16_PP5.2.8 - USBC_PORTSEL_PP o USBC_1PORT_PP5.2.9 - USBC_LDRVSEL o USBC_VIF3 (NOT_USED)5.2.10 - USBC_XINSEL o USBC_XTAL245.2.11 O USBC_FW_PP USBC_FW_NONOS_PP This setting is USBC_FW_OS_PP selected by the macro definition of HEW project.5.2.12 O USBC_OS_CRE_MODE_PP o USBC_OS_CRE_NOTUSE_PP If USBC_OS_CRE_USE_PP USB_C_FW_NO NOS_PP setting in 5,2,11, use the default setting. If RI600 is used, use the default setting.5.2.13 O USBC_CPUBYTE_PP o USBC_BYTE_LITTLE_PP USBC_BYTE_BIG_PP5.2.14 - USBC_TRANS_MODE_PP o USBC_TRANS_DTC_PP5.2.15 O USBC_LPWR_MODE_PP o USBC_LPWR_NOT_USE_PP USBC_LPWR_USE_PP5.2.16 O USBC_PERIODIC_MODE_P o USBC_NONPERIODIC_PP P USBC_PERIODIC_PP5.2.17 - USBC_PIPEERROR o 1u5.2.18 - USBC_DEVICESIZE o 20u - USBC_CONFIGSIZE o 256u5.2.19 - USBC_DEVICEADDR o 1u5.2.20 - USBC_HUBDOWNPORT o 4u* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.R01AN0512EJ0110 Rev.1.10 Page 23 of 126Jun 10, 2011
  24. 24. USB Basic FirmwareTable 5.3 For the R8A66597, the user system definition information (r_usbc_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.2.1 - USBC_TARGET_CHIP_PP o USBC_ASSP_PP This setting is selected by the macro definition of HEW project.5.2.2 - USBC_IPSEL_PP o USBC_597IP_PP5.2.3 - USBC_IP_PIPE_PP o USBC_IP_PIPE_9_PP5.2.4 - USBC_IP_DEVADD_PP o USBC_IP_DEVADD_A_PP5.2.5 - USBC_PIPEBUF_MODE_PP o USBC_PIPEBUF_CHANGE_PP5.2.6 - USBC_SPEEDSEL_PP o USBC_HS_PP5.2.7 - USBC_BUSSIZE_PP o USBC_BUSSIZE_16_PP5.2.8 O USBC_PORTSEL_PP o USBC_2PORT_PP USBC_1PORT_PP5.2.9 O USBC_LDRVSEL USBC_VIF1 (NOT_USED) o USBC_VIF35.2.10 O USBC_XINSEL USBC_XTAL12 o USBC_XTAL24 USBC_XTAL485.2.11 - USBC_FW_PP o USBC_FW_NONOS_PP This setting is selected by the macro definition of HEW project.5.2.12 - USBC_OS_CRE_MODE_PP o USBC_OS_CRE_NOTUSE_PP5.2.13 O USBC_CPUBYTE_PP o USBC_BYTE_LITTLE_PP USBC_BYTE_BIG_PP5.2.14 - USBC_TRANS_MODE_PP o USBC_TRANS_DTC_PP5.2.15 - USBC_LPWR_MODE_PP o USBC_LPWR_NOT_USE_PP5.2.16 O USBC_PERIODIC_MODE_P o USBC_NONPERIODIC_PP P USBC_PERIODIC_PP5.2.17 O USBC_PIPEERROR o 1u5.2.18 O USBC_DEVICESIZE o 20u O USBC_CONFIGSIZE o 256u5.2.19 O USBC_DEVICEADDR o 1u5.2.20 O USBC_HUBDOWNPORT o 4u* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.R01AN0512EJ0110 Rev.1.10 Page 24 of 126Jun 10, 2011
  25. 25. USB Basic Firmware 5.3 User-Defined Information File (r_usb_cDefUsr.h)1. USB Function designation2. Power Consumption Control Function designation3. Auto Clock Mode designation4. Sleep Mode designation5. Hardware address designation6. Hi-speed operation enable/disable5.3.1 USB Function DesignationThe hardware function may be specified as one of the following three options.1) USBC_HOST_PP: Used as USB host.2) USBC_PERI_PP: Used as USB peripheral.3) USBC_HOST_PERI_PP: Used as both USB host and USB peripheral.Example: USB peripheral #define USBC_FUNCSEL_PP USBC_PERI_PP5.3.2 Power Consumption Control Function DesignationIt is necessary to specify the power consumption control function.Reference: The power consumption control function may be specified as one of the following three options.1) USBC_NOT_STOP_PP: The power consumption control is not used (clock does not stop).2) USBC_XCKE_USE_PP: The power consumption control function is used with the clock in the stopped state.3) USBC_PCUT_USE_PP: The low-power sleep state is used. (This setting is for M66592 and M66596.)Example: The power consumption control is not used #define USBC_OSCSEL_PP USBC_CLK_NOT_STOP_PPThis function is not used by the RX62N and RX630. Use the USBC_CLK_NOT_STOP_PP setting.For the R8A66597, use the USBC_NOT_STOP_PP or the USBC_XCKE_USE_PP setting.5.3.3 Auto Clock Mode DesignationThe hardware function may be specified as one of the following two options.1) USBC_ATCKM_NOT_USE_PP: No auto clock mode2) USBC_ATCKM_USE_PP: Auto clock mode (This setting is for M66592 and M66596.)Example: No auto clock mode #define USBC_ATCKMSEL_PP USBC_ATCKM_NOT_USE_PPThis function is not used by the RX62N, RX630 and R8A66597. Use the USBC_ATCKM_NOT_USE_PP setting.R01AN0512EJ0110 Rev.1.10 Page 25 of 126Jun 10, 2011
  26. 26. USB Basic Firmware5.3.4 Sleep Mode DesignationThe sleep mode may be specified as one of the following two options.1) USBC_LPSM_DISABLE_PP: No sleep mode2) USBC_LPSM_ENABLE_PP: Sleep mode (The setting is for R8A66597.)Example: No sleep mode #define USBC_LPWRSEL_PP USBC_LPSM_DISABLE_PPThis function is not used by the RX62N and RX630. Use the USBC_LPSM_DISABLE_PP setting.5.3.5 Hardware Address DesignationIt is necessary to specify the standard address for accessing the hardware.For each register, the address is specified as an offset from the designated standard address.Example: 0x05000000 #define USBC_BASE (uint32_t)(0x05000000)This setting is not used by the RX62N and RX630.(#define USB0 specifies the address.)5.3.6 Hi-Speed Operation Enable/DisableEither of the following two options may be selected for hi-speed operation.1) USBC_HS_DISABLE: Full- or low-speed operation will be selected automatically according to the connected device.2) USBC_HS_ENABLE: Hi-, full-, or low-speed operation will be selected automatically according to the connected device.Example: Disabled #define USBC_HSESEL USBC_HS_DISABLEFor the RX62N and RX630, select USBC_HS_DISABLE.R01AN0512EJ0110 Rev.1.10 Page 26 of 126Jun 10, 2011
  27. 27. USB Basic Firmware5.3.7 User System Definition Information for Each DeviceThe user system definition information for each device is shown below.Table 5.4 For the RX62N, the user system definition information (r_usb_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.3.1 O USBC_FUNCSEL_PP USBC_HOST_PP This setting is USBC_PERI_PP selected by the USBC_HOST_PERI_PP macro definition of HEW project.5.3.2 - USBC_OSCSEL_PP o USBC_CLK_NOT_STOP_PP5.3.3 - USBC_ATCKMSEL_PP o USBC_ATCKM_NOT_USE_PP5.3.4 - USBC_LPWRSEL_PP o USBC_LPWR_DISABLE_PP5.3.5 - USB_BASE o 0x000A00005.3.6 - USB_HSESEL o USBC_HS_DISABLE* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.Table 5.5 For the RX630, the user system definition information (r_usb_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.3.1 - USBC_FUNCSEL_PP USBC_PERI_PP This setting is selected by the macro definition of HEW project.5.3.2 - USBC_OSCSEL_PP o USBC_CLK_NOT_STOP_PP5.3.3 - USBC_ATCKMSEL_PP o USBC_ATCKM_NOT_USE_PP5.3.4 - USBC_LPWRSEL_PP o USBC_LPWR_DISABLE_PP5.3.5 - USB_BASE o 0x000A00005.3.6 - USB_HSESEL o USBC_HS_DISABLE* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.Table 5.6 For the R8A66597, the user system definition information (r_usb_cDefUsr.h)Section Flag Set Object Set Value RemarksNumber * (o: default setting)5.3.1 O USBC_FUNCSEL_PP USBC_HOST_PP This setting is USBC_PERI_PP selected by the macro definition of HEW project.5.3.2 O USBC_OSCSEL_PP o USBC_CLK_NOT_STOP_PP USBC_CLK_XCKE_USE_PP5.3.3 - USBC_ATCKMSEL_PP o USBC_ATCKM_NOT_USE_PP5.3.4 O USBC_LPWRSEL_PP o USBC_LPWR_DISABLE_PP USBC_LPWR_ENABLE_PP5.3.5 O USB_BASE o 0x050000005.3.6 O USB_HSESEL o USBC_HS_ENABLE USBC_HS_DISABLE* : Flag - : Not selected(Use the default setting.), O: Select from Set Value.R01AN0512EJ0110 Rev.1.10 Page 27 of 126Jun 10, 2011
  28. 28. USB Basic Firmware6. Workspace 6.1 OverviewThe workspace of USB-BASIC-F/W is described below.Workspace of USB-BASIC-F/W includes two projects.1. NonOS_StdFw: non-OS2. Itron_StdFw: uITRON (R8A66597 is not supported)And, USB-BASIC-F/W includes build configurations.[For the RX62N]1. PORT0_P: PORT0 is Peripheral mode2. PORT1_H: PORT1 is Host mode3. PORT0_P_PORT1_H:USB0 is Peripheral mode and USB1 is Host mode[For the RX630]4. RX630_PORT0_P: PORT0 is Peripheral mode[For the R8A66597]5. ASSP_PERI: PORT0 is Peripheral mode6. ASSP_HOST: PORT1 is Host modeEach configuration selects source files as compiled.In peripheral function mode, USB-BASIC-F/W comprises two tasks, PCD and sample application, and a scheduler. Inhost function mode, it comprises four tasks, HCD, MGR, HUB, and sample application, and a scheduler. Sampleapplication is run as tasks.R01AN0512EJ0110 Rev.1.10 Page 28 of 126Jun 10, 2011
  29. 29. USB Basic Firmware 6.2 Structure of Files and folders6.2.1 Folder StructureThe folder structure in which the files are provided in USB-BASIC-F/W is shown below. These provided files in USB-BASIC-F/W include sample application and sample code of resource for hardware.< HEW workspace: USBSTDFW >(USB-BASIC-F/W) +⎯⎯⎯ USBSTDFW For USB0 | +⎯⎯⎯ class | | +⎯⎯⎯ hubd Sample hub driver | | +⎯⎯⎯ smpl USB standard request sample | +⎯⎯⎯ include Common header file | +⎯⎯⎯ USB20 | +⎯⎯⎯ HCD Host control driver | +⎯⎯⎯ PCD Peripheral control driver | +⎯⎯⎯ LIB Common library +⎯⎯⎯ USB2STDFW For USB1 (RX630 and R8A66597 are not used.) | Structure is same to USBSTDFW +⎯⎯⎯ USBCSTDFW For USB0 and USB1 | +⎯⎯⎯ include Common header file(The following is sample code) +⎯⎯⎯ RI600_4 For uITRON | +⎯⎯⎯ config_Pstd For PORT0_P and RX630_PORT0_P | +⎯⎯⎯ config_Hstd For PORT1_H | +⎯⎯⎯ config_Cstd For PORT0_P_PORT1_H +⎯⎯⎯ HwResourceForUSB Resource for hardware | +⎯⎯⎯ RX62N For RX62N | +⎯⎯⎯ RX630 For RX630 +⎯⎯⎯ SmplMain +⎯⎯⎯ APL Sample application +⎯⎯⎯ Project Each projectsR01AN0512EJ0110 Rev.1.10 Page 29 of 126Jun 10, 2011
  30. 30. USB Basic Firmware6.2.2 List of FilesThe files provided in USB-BASIC-F/W are listed below. The files of USB2STDFW folder are left out.Table 6.1 List of FilesFolder File Name Description Project (O: Selected ) 1) 2) 3) 4) 5) 6) * * * * * *HCD r_usb_hControlRW.c Control read/write processing O O OHCD r_usb_hDriver.c HCD task O O OHCD r_usb_hDriverAPI.c HCD/MGR API functions O O OHCD r_usb_hIntFIFO.c INTR, INTN, BEMP interrupt O O O processingHCD r_usb_hManager.c MGR task O O OHCD r_usb_hSignal.c USB signal control, oscillation control O O O processingHCD r_usb_hStdFunction. USB function extension library O O O c functionsHCD r_usb_hLibUSBIP.c USB library functions O O OPCD r_usb_pControlRW.c Control read/write processing O O O OPCD r_usb_pDriver.c PCD task O O O OPCD r_usb_pDriverAPI.c PCD API functions O O O OPCD r_usb_pIntFIFO.c INTR, INTN, BEMP interrupt O O O O processingPCD r_usb_pSignal.c USB signal control, oscillation control O O O O processingPCD r_usb_pStdRequest.c USB standard request responses O O O OPCD r_usb_pStdFunction. USB function extension library O O O O c functionsPCD r_usb_pLibUSBIP.c USB library functions O O O OLIB r_usb_cDataIO.c Data read/write, FIFO access O O O O O O processingLIB r_usb_cIntFIFO.c INTR, INTN, BEMP interrupt O O O O O O processingLIB r_usb_cIntHandler.c USB interrupt handler O O O O O OLIB r_usb_cLibUSBIP.c USB library functions O O O O O OLIB r_usb_cSignal.c USB signal control, oscillation control O O O O O O processingLIB r_usb_cStdFunction. USB function extension library O O O O O O c functions (host/peripheral mixed)USBCSTDFW r_usbc_cScheduler.c Scheduler control O O O O O Oinclude r_usbc_cDefUSBIP.h USB driver definitions O O O O O Oinclude r_usbc_cItron.h System header file O O O O O Oinclude r_usbc_cKernelID.h ID definitions (Task ID, etc.) O O O O O Oinclude r_usbc_cMacSystem Macro definitions (scheduler macros) O O O O O O call.hinclude r_usbc_cMacPrint.h Macro definitions O O O O O O (macros for displaying debug information)include r_usbc_cTypedef.h Variable type definitions O O O O O Oinclude r_usbc_cDef592IP.h Register definitions for 592IP (not used by RX62N)R01AN0512EJ0110 Rev.1.10 Page 30 of 126Jun 10, 2011
  31. 31. USB Basic Firmware Project (O: Selected )include r_usbc_cDef596IP.h Register definitions for 596IP (not used by RX62N)include r_usbc_cDef597IP.h Register definitions for 597IP O O (not used by RX62N)include r_usbc_cUsbDefBitD USB register definitions for RX600 O O O O efine.h seriesinclude r_usb_cDefUsr.h User setting (hardware operation O O O O O O designation) definitionsinclude r_usbc_cDefUsrPp.h USB driver definitions O O O O O Oinclude r_usb_cExtern.h USB-BASIC-F/W external reference O O O O O O definitionsinclude r_usb_cMacUsr.h Macro definitions (register access O O O O O O macros)include r_usb_cRevision.h Common library revision designations O O O O O Ohubd r_usb_hHubsys.c HUBCD functions (non-OS) O O Ohubd r_usb_hHubsys_uitro HUBCD functions (uITRON) O O n.cSMPL r_usb_pClassVendor. Peripheral class requests O O O O cSMPL r_usb_smp_cSub.c Common library functions O O O O O OSMPL r_usb_smp_hSub.c Host standard requests O O OSmplMain main.c Sample main program O O O O O OSmplMain RX62NRSK.c RX62N RSK processing O O O O OSmplMain RX630RSK.c RX630 RSK processing OSmplMain RX62NRSK_Extern.h RX62N RSK external reference O O O O O definitionsSmplMain RX630RSK_Extern.h RX630 RSK external reference O definitionsAPL r_usbc_PHSMPL_apl Host and Peripheral sample application O .cAPL r_usbc_PHSMPL_dat Data for Host and Peripheral sample O a.c applicationAPL r_usbc_cdata.c Data transfer data for port 0 and port 1 O sample applicationAPL r_usbc_cdata.h Data transfer settings for port 0 and O port 1 sample applicationAPL r_usb2_HSMPL_apl. Host port 1 sample application O cAPL r_usb_HSMPL_apl.c Host sample application for R8A66597 OAPL r_usb2_cdata.c Data transfer data for port 1 sample O applicationAPL r_usb2_cdata.h Data transfer settings for port 1 sample O applicationAPL r_usb_PSMPL_apl.c Peripheral port 0 sample application O O OAPL r_usb_PSMPL_data. Data for peripheral port 0 sample O O O c applicationAPL r_usb_cdata.c Data transfer data for port 0 sample O O O O applicationAPL r_usb_cdata.h Data transfer settings for port 0 sample O O O O applicationconfig_Pstd r_usb_RX62N.cfg Configuration file Oconfig_Pstd ritable_pstd.src Vector table setting OR01AN0512EJ0110 Rev.1.10 Page 31 of 126Jun 10, 2011
  32. 32. USB Basic Firmware Project (O: Selected )config_Pstd r_usb_RX630.cfg Configuration file Oconfig_Pstd ritable_rx630_pstd.sr Vector table setting O cconfig_Hstd r_usb_RX62N.cfg Configuration file Oconfig_Hstd ritable_hstd.src Vector table setting Oconfig_Cstd r_usb_RX62N.cfg Configuration file Oconfig_Cstd ritable_cstd.src Vector table setting OHwResourceF ritable_rx62n.src Vector table setting for RX62N (non- O O OorUSB OS only)HwResourceF ritable_rx630.src Vector table setting for RX630 (non-OS OorUSB only)HwResourceF ritable_assp.src Vector table setting for R8A66597 O OorUSB (non-OS only)HwResourceF dbsct.c Section setting O O O O O OorUSBHwResourceF resetprg.c Reset program O O O O O OorUSBHwResourceF Output file of HEW O O O O O OorUSBRX62N iodefine.h IO definition file for RX62N O O O O ORX630 iodefine.h IO definition file for RX630 O* 1): PORT0_P, 2): PORT1_H, 3): PORT0_P_PORT1_H, 4): RX630_PORT0_P , 5): ASSP_PERI , 6): ASSP_HOSTR01AN0512EJ0110 Rev.1.10 Page 32 of 126Jun 10, 2011
  33. 33. USB Basic Firmware7. Sample Applications 7.1 Sample application for Data transfer (APL)USB-BASIC-F/W supports the sample application (APL) that can transfer data using pipes 1, 2, 6, and 7 in host orperipheral function mode as vendor specific class. When writing custom applications, refer to r_usb2_HSMPL_apl.cand r_usb_PSMPL_apl.c and make the applications.7.1.1 APL SequenceThe APL sequence in USB-BASIC-F/W is shown below. Host function mode Peripheral function mode APL APL R_usb2_hstd_ Initialize data SetPipeInfo transfer processing R_usb2_hstd_ SetPipeRegistration Initialize data transfer processing Data transfer ERROR complete ? R_usb2_hstd_ YES TransferStart Reset data transfer processing Data transfer ERROR complete ? R_usb_pstd_ TransferStart YES Count down of data transfer counter return Data transfer NO counter is not 0 ? YES R_usb2_hstd_ TransferStart All data transfer NO counter is 0 ? YES Reset data transfer processing R_usb2_hstd_ TransferStart Figure 7.1 APL sequenceR01AN0512EJ0110 Rev.1.10 Page 33 of 126Jun 10, 2011
  34. 34. USB Basic Firmware7.1.2 APL Global AreaThe APL global area in USB-BASIC-F/W is shown below.Table 7.1 List of APL global area (Peripheral function mode) Type Variable Description1 USBC_UTR_t usb_gcstd_SmplTrnMsg[ ] Message area of pipes for data transfer request2 uint32_t usb_gcstd_SmplTrnCnt[ ] Data transfer counter of pipes3 uint32_t usb_gcstd_SmplTrnSize[ ] Data transfer size of pipes4 uint8_t * usb_gcstd_SmplTrnPtr[ ] Data address pointer of pipes for data transfer5 uint8_t usb_gcstd_SmplTrnData1[ ] Data address of pipe1 for data transfer6 uint8_t usb_gcstd_SmplTrnData2[ ] Data address of pipe2 for data transfer7 uint8_t usb_gcstd_SmplTrnData3[ ] Data address of pipe3 for data transfer8 uint8_t usb_gcstd_SmplTrnData4[ ] Data address of pipe4 for data transfer9 uint8_t usb_gcstd_SmplTrnData5[ ] Data address of pipe5 for data transfer10 uint8_t usb_gcstd_SmplTrnData6[ ] Data address of pipe6 for data transfer11 uint8_t usb_gcstd_SmplTrnData7[ ] Data address of pipe7 for data transfer12 uint8_t usb_gcstd_SmplTrnData8[ ] Data address of pipe8 for data transfer13 uint8_t usb_gcstd_SmplTrnData9[ ] Data address of pipe9 for data transfer14 uint16_t usb_gpstd_SmplEpTbl1[ ] Pipe information table for data transfer application15 uint16_t usb_gpstd_SmplEpTbl2[ ] Dummy of pipe information table16 uint16_t usb_gpstd_SmplEpTbl3[ ] Dummy of pipe information table17 uint16_t usb_gpstd_SmplEpTbl4[ ] Dummy of pipe information table18 uint16_t usb_gpstd_SmplEpTbl5[ ] Dummy of pipe information table19 uint16_t * usb_gpstd_SmplEpPtr[ ] Pointer table of pipe information table20 uint8_t usb_gpstd_SmplDeviceDescriptor[ ] Device descriptor for data transfer application21 uint8_t usb_gpstd_SmplQualifierDescriptor[ Qualifier descriptor for data transfer ] application22 uint8_t usb_gpstd_SmplConfigurationH_1[ Configuration descriptor of hi-speed for data ] transfer application23 uint8_t usb_gpstd_SmplConfigurationF_1[ ] Configuration descriptor of full-speed for data transfer application24 uint8_t * usb_gpstd_SmplConPtr[ ] Pointer table of configuration descriptor for data transfer application25 uint8_t * usb_gpstd_SmplConPtrOther[ ] Pointer table of other speed configuration descriptor for data transfer application26 uint8_t usb_gpstd_StringDescriptor0[ ] String Descriptor0 for data transfer application27 uint8_t usb_gpstd_StringDescriptor1[ ] String Descriptor1 for data transfer application28 uint8_t usb_gpstd_StringDescriptor2[ ] String Descriptor2 for data transfer application29 uint8_t usb_gpstd_StringDescriptor3[ ] String Descriptor3 for data transfer application30 uint8_t usb_gpstd_StringDescriptor4[ ] String Descriptor4 for data transfer application31 uint8_t usb_gpstd_StringDescriptor5[ ] String Descriptor5 for data transfer application32 uint8_t * usb_gpstd_StrPtr[ ] Pointer table of string descriptor for data transfer descriptorR01AN0512EJ0110 Rev.1.10 Page 34 of 126Jun 10, 2011
  35. 35. USB Basic FirmwareTable 7.2 List of APL global area (Host function mode) Type Variable Description1 USBC_UTR_t usb2_gcstd_SmplTrnMsg[ ] Message area of pipes for data transfer request2 uint32_t usb2_gcstd_SmplTrnCnt[ ] Data transfer counter of pipes3 uint32_t usb2_gcstd_SmplTrnSize[ ] Data transfer size of pipes4 uint8_t * usb2_gcstd_SmplTrnPtr[ ] Data address pointer of pipes for data transfer5 uint8_t usb2_gcstd_SmplTrnData1[ ] Data address of pipe1 for data transfer6 uint8_t usb2_gcstd_SmplTrnData2[ ] Data address of pipe2 for data transfer7 uint8_t usb2_gcstd_SmplTrnData3[ ] Data address of pipe3 for data transfer8 uint8_t usb2_gcstd_SmplTrnData4[ ] Data address of pipe4 for data transfer9 uint8_t usb2_gcstd_SmplTrnData5[ ] Data address of pipe5 for data transfer10 uint8_t usb2_gcstd_SmplTrnData6[ ] Data address of pipe6 for data transfer11 uint8_t usb2_gcstd_SmplTrnData7[ ] Data address of pipe7 for data transfer12 uint8_t usb2_gcstd_SmplTrnData8[ ] Data address of pipe8 for data transfer13 uint8_t usb2_gcstd_SmplTrnData9[ ] Data address of pipe9 for data transfer14 uint16_t usb2_gpstd_SmplDefEpTbl[ ] Pipe information table for data transfer application15 uint16_t usb2_gpstd_SmplTmpEpTbl[ ] Pipe information table for data transfer application16 const uint16_t usb2_gpstd_SmplTpl[ ] Target peripheral list(TPL) for data transfer application17 uint16_t usb2_gpstd_SmplAdr Temporary area of device address for data transfer application18 uint16_t usb2_gpstd_SmplClassSeq Sequence control data for data transfer application19 uint8_t * usb2_hcls_SmplDeviceTable Temporary area of pointer of device descriptor data for data transfer application20 uint8_t * usb2_hcls_SmplConfigTable Temporary area of pointer of configuration descriptor data for data transfer application21 uint8_t * usb2_hcls_SmplInterfaceTable Temporary area of pointer of interface descriptor data for data transfer application22 uint16_t usb2_hcls_SmplDevaddr Temporary area of pointer of device address data for data transfer application23 uint16_t usb2_hcls_SmplSpeed Temporary area of pointer of device speed data for data transfer applicationR01AN0512EJ0110 Rev.1.10 Page 35 of 126Jun 10, 2011
  36. 36. USB Basic Firmware7.1.3 APL Constant DefinitionThe APL constant definition in USB-BASIC-F/W is shown below.Table 7.3 List of APL constant definition (Peripheral function mode) Constant Name Value Description1 Data length of descriptors USB_SMPLCONFLEN 46 Data length of usb_gpstd_SmplConfigurationH_1[ ]/ usb_gpstd_SmplConfigurationF_1[ ] USB_SD1LEN 32 Data length of usb_gpstd_StringDescriptor1[ ] USB_SD2LEN 28 Data length of usb_gpstd_StringDescriptor2[ ]2 Select using pipe for data transfer application USBC_USEPIPE_ALL_PP 1 Use pipe1 to pipe9 USBC_USEPIPE_1267_PP 2 Use pipe 1,2,6 and 7 USBC_USEPIPE_MODE_PP 2 Set to use pipe 1,2,6 and 73 Table size of usb_gcstd_SmplTrnMsg[ ] usb_gcstd_SmplTrnCnt[ ] usb_gcstd_SmplTrnSize[ ] *usb_gcstd_SmplTrnPtr[ ] USB_TBL_MAX 10 Use area between pipe0 and pipe9 (This value is index of the tables.)4 Data transfer size USB_SMPL_TRNSIZE1 512 Data transfer size of pipe1 are 512 bytes USB_SMPL_TRNSIZE2 512 Data transfer size of pipe2 are 512 bytes USB_SMPL_TRNSIZE3 512 Data transfer size of pipe3 are 512 bytes USB_SMPL_TRNSIZE4 512 Data transfer size of pipe4 are 512 bytes USB_SMPL_TRNSIZE5 512 Data transfer size of pipe5 are 512 bytes USB_SMPL_TRNSIZE6 512 Data transfer size of pipe6 are 512 bytes USB_SMPL_TRNSIZE7 512 Data transfer size of pipe7 are 512 bytes USB_SMPL_TRNSIZE8 0 Data transfer size of pipe8 are 0 byte USB_SMPL_TRNSIZE9 0 Data transfer size of pipe9 are 0 byte5 Data transfer times USB_SMPL_TRNCNT1 512 Data transfer times of pipe1 are 512 times USB_SMPL_TRNCNT2 512 Data transfer times of pipe2 are 512 times USB_SMPL_TRNCNT3 512 Data transfer times of pipe3 are 512 times USB_SMPL_TRNCNT4 512 Data transfer times of pipe4 are 512 times USB_SMPL_TRNCNT5 512 Data transfer times of pipe5 are 512 times USB_SMPL_TRNCNT6 512 Data transfer times of pipe6 are 512 times USB_SMPL_TRNCNT7 512 Data transfer times of pipe7 are 512 times USB_SMPL_TRNCNT8 0 Pipe8 do not transfer USB_SMPL_TRNCNT9 0 Pipe9 do not transferR01AN0512EJ0110 Rev.1.10 Page 36 of 126Jun 10, 2011

×