Renesas X 600 Series Manual

Renesas X 600 Series Manual

Usb host mass storage class driver (hmsc)

Advertisement

Quick Links

Renesas USB Device
USB Host Mass Storage Class Driver (HMSC)
Introduction
This document is a manual describing use of the USB host mass storage class driver with Renesas USB Device.
Target Device
RX62N Group, R8A66597
This application note also applies to other microcontrollers in the RX 600 Series that have the same USB module as
the RX62N Group microcontrollers. When using this code in an end product or other application, its operation must be
tested and evaluated thoroughly.
Contents
1.
Overview ........................................................................................................................................... 2
2.
Device Class Driver (HDCD)............................................................................................................. 4
3.
USB Mass Storage Class Driver (HMSCD) .................................................................................... 12
4.
Host Control Driver Interface(HCI) Functions ................................................................................. 21
5.
Device Driver Interface(DDI) Functions .......................................................................................... 26
6.
File System Interface (FSI) ............................................................................................................. 31
7.
Sample Device Driver (HMSDD)..................................................................................................... 34
8.
Sample Application Program (APL) ................................................................................................ 42
9.
Including Resources in µITRON and Non-OS Versions ................................................................. 50
10. Limitations ....................................................................................................................................... 54
R01AN0513EJ0110 Rev.1.10
Aug 10, 2011
APPLICATION NOTE
R01AN0513EJ0110
Rev.1.10
Aug 10, 2011
Page 1 of 55

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the X 600 Series and is the answer not in the manual?

Questions and answers

Summary of Contents for Renesas X 600 Series

  • Page 1: Table Of Contents

    USB Host Mass Storage Class Driver (HMSC) Aug 10, 2011 Introduction This document is a manual describing use of the USB host mass storage class driver with Renesas USB Device. Target Device RX62N Group, R8A66597 This application note also applies to other microcontrollers in the RX 600 Series that have the same USB module as the RX62N Group microcontrollers.
  • Page 2: Overview

    [4] RX62N Group, RX621 Group User’s Manual: Hardware (Document No.R01UH0033EJ) [5] R8A66597 Datasheet (Document No. REJ03F0229) [6] Renesas USB Device USB Basic Firmware Application note (Document No.R01AN0512EJ) [7] RX600 Series USB Host Mass Storage Class Driver Installation Guide (Document No R01AN0523EJ) Renesas Electronics Website [http:// www.renesas.com/]...
  • Page 3 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Task : Processing unit Scheduler Macro : Macro for calling the scheduler function (non-OS only) SW1/SW2/SW3 : User switches on the RX62N-RSK (Caution 1) ****(): Function call ****(capital letter) command: Storage device control command (Caution 1) When RX62N-RSK used in conjunction with the R8A66597, SW1 is allocated to the port used by the interruption.
  • Page 4: Device Class Driver (Hdcd)

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Device Class Driver (HDCD) Basic Functions The term HDCD refers collectively to HMSDD (host mass storage device driver) and HMSCD (USB host mass storage class driver). Its main functions are as follows.
  • Page 5 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Software Configuration Figure 2.1 shows the configuration of HDCD, and table 2.1 lists the modules. User Application (APL) File System Library (FSL) File System Interface (FSI) Mass Storage Device Driver (HMSDD)
  • Page 6 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) H/W reset For non-OS usb_hmsc_ PowerON_Reset_PC MainLoop  Initialize MCU Task processing flag set ? Initialize section HCD task Initialize library MGR task Set stack HUB task usbc_cstd_ HMSC task MainTask Device driver usbc_cstd_ MainTask Application usb_hmsc_ MainInit Scheduler usb_hmsc_ MainLoop Return For uITRON...
  • Page 7 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) File Structure 2.4.1 Folder Structure The folder structure in which the files are provided in HDCD is shown below. <HEW WorkSpace> +---WorkSpace +---MSCFW For USB0 +---HMSC Host MSC Driver +---include Host MSC header file...
  • Page 8 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) 2.4.2 File Structure Table 2.2 File Structure Folder Name File Name Description Note r_usb_HMSC_apl.c Sample application Sample MSCFW r_usb_HMSCfsi.c FSL interface functions Sample MSCFW r_usb_hStorageDriver.c Device driver (HMSDD) Sample MSCFW r_usb_HMSCddi.c...
  • Page 9 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) 2.5.2 System Resource Definitions when Running Non-OS Version The non-OS resources used by HDCD are listed below. They are defined in the r_usb_cKernelId.h header file. Table 2.4 Non-OS Resources Name Description...
  • Page 10 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Accessing USB Storage Devices FSI converts sector numbers to logical block addresses and sector counts to transfer data sizes. From the drive number, HMSDD determines if a USB storage device is being accessed. HMSCD converts drive numbers to unit numbers and accesses USB storage devices via HCD according to the BOT protocol.
  • Page 11 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSCD activation HMSCD determines if USB communication is possible from the descriptor information of the connected device. Figure 2.4 shows the operation sequence at HMSCD activation. HMSDD HMSCD R_usb_hmsc_ StrgTaskOpen Activate...
  • Page 12: Usb Mass Storage Class Driver (Hmscd)

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) USB Mass Storage Class Driver (HMSCD) Basic Functions HMSCD is registered in HCD when the application (APL) starts the device driver. The functions of HMSCD are as follows. 1. Verifying devices (determining if USB storage devices are ready to operate) 2.
  • Page 13 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSCD Global Area Table 3.2 lists details of the HMSCD global area. Table 3.2 HMSCD Global Area Format Variable Name Description uint16_t usb_ghmsc_AttSts HMSCD operation state USBC_MSC_CBW_t usb_ghmsc_Cbw[USBC_MAXSTRAGE] CBW transmit structure...
  • Page 14 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSCD Structures Tables 3.4 and 3.5 show the contents of the HMSCD structures. Table 3.4 USBC_MSC_CBW_t Structure Member Name Description Remarks uint32_t dCBWSignature CBW Signature 0x55534243: USBC uint32_t dCBWTag CBW Tag...
  • Page 15 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSCD Constant Definitions Tables 3.6 and 3.7 list the HMSCD constant definitions. Table 3.6 HMSCD Constant Definitions (MSDCD Common Macro Definitions) Description Definition Name Value BOT wrapper CBW data length USBC_MSC_CBWLENGTH...
  • Page 16 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 3.7 HMSCD Constant Definitions (HDCD Dedicated Macro Definitions) Description Value HMSCD connection state Device not connected USBC_HMSC_DEV_DET 0x00 Device connected USBC_HMSC_DEV_ATT 0x01 Device type Direct access device USBC_PDT_DIRECT 0x00 Sequential device...
  • Page 17 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSCD Function Details Table 3.8 usb_hmsc_SmpBotDescriptor() Name Check Descriptor Call format nit16_t usb_hmsc_SmpBotDescriptor(uint8_t *table, uint16_t msgnum) uint8_t *table Interface descriptor table address Arguments uint16_t msgnum Driver number USBC_DONE Normal end Return values...
  • Page 18 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 3.10 usb_hmsc_NoData() Name NO DATA Command Execution Call format uint16_t usb_hmsc_NoData(uint16_t drvnum) Arguments uint16_t drvnum Drive number Transfer end notification: See HMSCD constant Return values uint16_t definitions. Description The NO DATA command is executed.
  • Page 19 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 3.14 usb_hmsc_SetElsCbw() Name Initialize CBW Parameters for Other Commands Call format void usb_hmsc_SetElsCbw(uint8_t *data, uint32_t trans_byte, uint16_t side) uint8_t *data Command data address Arguments uint32_t trans_byte Transfer data size uint16_t...
  • Page 20 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 3.19 R_usb_hmsc_Information() Name Check HMSCD Operation State Call format uint16_t R_usb_ hmsc_Information(uint16_t pipe_offset) Arguments uint16_t pipe_offset Return values uint16_t Pipe information table Description Returns the value of the pipe information table.
  • Page 21: Host Control Driver Interface(Hci) Functions

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Host Control Driver Interface(HCI) Functions Functions and Features For the case of uITRON, until the drive is mounted, HCI uses the HCD class area to send and receive messages. When mounting of the drive is finished, it uses the HMSCD dedicated area. For the case of non-OS,HCI uses the HMSCD area to send and receive messages.
  • Page 22 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HCI Interface Messages Table 4.3 shows the HCI message structure. Table 4.3 Interface Message Structure (USBC_UTR_t) Format Variable Description Remarks USBC_MH_t msghead Message header for SI7000/4 uITRON information area uint16_t msginfo...
  • Page 23 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 4.6 usb_hmsc_SendData() Name Transmit Data Call format uint16_t usb_hmsc_SendData(uint16_t drvnum, uint8_t *buff, uint32_t size) uint16_t drvnum Drive number Arguments uint8_t *buff Transmit data area uint32_t size Transmit data size USBC_HMSC_OK...
  • Page 24 Renesas USB Device USB Host Mass Storage Class Driver Table 4.9 R_usb_ hmsc_GetMaxUnit() Name GetMaxUnit Request Execution Call format uint16_t R_usb_ hmsc_GetMaxUnit(uint16_t addr) : for uITRON Arguments uint16_t addr Device address USBC_DONE GetMaxLUN not supported Return values uint16_t USBC_ERROR Error end...
  • Page 25 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 4.12 usb_hmsc_TransWaitTmo() Name Wait for HCD Data Communication End or Timeout Call format uint16_t usb_hmsc_TransWaitTmo(uint16_t tmo) Arguments uint16_t Timeout duration (ms) Return values uint16_t Status Description Uses the TRCV_MSG system call to wait for receipt of a message.
  • Page 26: Device Driver Interface(Ddi) Functions

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Device Driver Interface(DDI) Functions Functions and Features The DDI functions comprise the HMSCD start function, end function, check connected device function, and sample storage command functions. DDI Functions Table 5.1 lists the DDI functions.
  • Page 27 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) DDI Function Details Table 5.2 R_usb_hmsc_Initialized() Name Initialize HMSCD Call format void R_usb_hmsc_Initialized(uint16_t data1, uint16_t data2) uint16_t data1 Not used Arguments uint16_t data2 Not used Return values void Description Initializes an internal variable of HMSCD.
  • Page 28 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 5.5 R_usb_hmsc_TaskClose() Name Release HMSCD Call format void R_usb_hmsc_TaskClose(void) Arguments void Return values void Description Releases HMSCD. Notes Table 5.6 R_usb_hmsc_Read10() Name READ10 command Execution. uint16_t R_usb_hmsc_Read10(uint16_t side, uint8_t *buff, uint32_t secno, uint16_t seccnt,...
  • Page 29 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 5.9 R_usb_hmsc_TestUnit() Name TEST_UNIT_READY command execution. Call format uint16_t R_usb_hmsc_TestUnit(uint16_t side) Arguments uint16_t side Drive number Return values uint16_t Error code Description Creates and executes the TEST_UNIT_READY command. When a command error occurs, the REQUEST_SENSE command is executed to get error Notes information.
  • Page 30 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 5.14 R_usb_hmsc_ModeSense10() Name MODE_SENSE10 command execution. Call format uint16_t R_usb_hmsc_ModeSense10(uint16_t side, uint8_t *buff) uint16_t side Drive number Arguments uint8_t *buff Receive data area Return values uint16_t Error code Description Creates and executes the MODE_SENSE10 command.
  • Page 31: File System Interface (Fsi)

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) File System Interface (FSI) Functions and Features Create the FSL to match the specifications of the interface. FSI Functions Table 6.1 lists the functions of the sample FSI. Table 6.1 FSI Functions...
  • Page 32 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 6.4 read_sector() / R_tfat_disk_read() Name Read Sector Call format int read_sector(int side, unsigned char *buff, unsigned long secno, long seccnt) side Drive number unsigned char *buff Read data area Arguments...
  • Page 33 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 6.6 usb_hmsc_SmpFsiSectorInitialized() Name Initialize Global Variables Call format void usb_hmsc_SmpFsiSectorInitialized(uint16_t side, uint32_t offset, uint16_t size) uint16_t side Drive number Arguments uint32_t offset Offset sector number uint16_t size Sector size Return values...
  • Page 34: Sample Device Driver (Hmsdd)

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Sample Device Driver (HMSDD) Basic Functions HMSDD is started by the application in order to use HMSCD. HMSDD selects a storage device by the drive number. When HMSDD starts, HMSCD is registered in HCD. HMSDD has the following functions.
  • Page 35 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSDD Functions Table 7.2 lists the functions of HMSDD. Table 7.2 HMSDD Functions Function Name Description R_usb_hmsc_StrgTaskOpen() Starts HMSDD. R_usb_hmsc_StrgDriveSearch() Reads partition information and searches for drive. usb_hmsc_SmpDevNextDriveSearch() Searches for new drive number.
  • Page 36 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) HMSDD Function Details Table 7.4 R_usb_hmsc_StrgTaskOpen() Name Start HMSDD Call format void R_usb_hmsc_StrgTaskOpen(void) Arguments void Return values void Starts HMSCD. Description Initializes the max. drive count to USBC_DRIVE. Notes Table 7.5...
  • Page 37 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 7.8 usb_hmsc_SmpDevReadPartition() Name Read PBR Sector Information Call format uint16_t usb_hmsc_SmpDevReadPartition(uint16_t unit, uint32_t trans_byte) uint16_t unit Unit number Arguments uint32_t trans_byte Transmit data length (sector count) USBC_DONE Drive detected Return values...
  • Page 38 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 7.12 R_usb_hmsc_StrgDriveClose() Name Unmount Drive Call format uint16_t R_usb_hmsc_StrgDriveClose(uint16_t side) Arguments uint16_t side Drive number USBC_DONE Normal end Return values uint16_t USBC_ERROR Error end Unmounts the drive specified by the argument. (The sector information is cleared.) Description Other than a common check, an error response occurs in the following case.
  • Page 39 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 7.15 R_usb_hmsc_StrgUserCommand() Name Issue Storage Command Call format uint16_t R_usb_hmsc_StrgUserCommand(uint16_t side, uint16_t command, uint8_t *buff) uint16_t side Drive number Arguments uint16_t command Command to be issued uint8_t *buff Data pointer...
  • Page 40 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 7.18 usb_hmsc_SmpDrive2Part() Name Search Partition Number Call format uint16_t usb_hmsc_SmpDrive2Part(uint16_t side) Arguments uint16_t side Drive number Return values uint16_t Partition number Description Searches the partition number from the drive number and returns the partition number.
  • Page 41 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Drive Management HMSDD sets USBC_DRIVE as the initial drive number of the connected storage device. HMSDD also supports connection of storage devices with multiple units and multiple drives. It is only necessary to specify the drive number from the application to access the relevant partition block of any unit.
  • Page 42: Sample Application Program (Apl)

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Sample Application Program (APL) Application Overview 8.1.1 Operating Environment The figure below shows a sample operating environment for the software. USB mass storage device USB Commnnication (BOT protocol) Text Data file Write "aaaaa"...
  • Page 43 Application Task(usb_hmsc_Task Function)Registration For the µITRON version, register the application task in the configuration file. For the non-OS version, see Renesas USB device USB Basic Firmware User’s Manual for information on registering the application task. Once the application task is registered as indicated above, the class checking function (table 5.3, R_usb_hmsc_Check ()) is called when the MSC device is attached.
  • Page 44 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) APL Constant Definition Table 8.3 APL Constant Definition Constant Name Value Descriptions Host MSC constant name USBC_HMSC_DRIVE_OPEN 0x1003 Callback sequence when the MSC device is in the state of the configured state.
  • Page 45 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) List of APL Functions Table 8.4 List of Functions of Sample Application File Name Function Name Description Remarks r_usb_HMSC_apl.c usb_hmsc_PrAplTitle Host MSC application title display function usb_hmsc_MainInit Host initialization function usb_hmsc_MainLoop...
  • Page 46 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Description of APL Functions The functions of the application program are described below. Table 8.5 usb_hmsc_PrAplTitle Name Display Application Title Call format usb_hmsc_PrAplTitle ⎯ ⎯ Arguments void ⎯ ⎯ Return void...
  • Page 47 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 8.8 usb_hmsc_SetTaskPri Name Task Priority Setting Processing (Only non-OS version) Call format usb_hmsc_SetTaskPri ⎯ ⎯ Arguments void Return ⎯ ⎯ void values Description Sets the priority of a task. Notes Table 8.9 usb_hmsc_sample...
  • Page 48 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Table 8.11 usb_hmsc_SampleAplSpecifiedPath Name Callback function for device driver (Only non-OS version) Call format usb_hmsc_SampleAplSpecifiedPath Arguments USBC_CLSINFO_t * mess Message is transmitted USBC_SND_MSG Return ⎯ ⎯ void values Callback function registered when APL calls API of the device driver.
  • Page 49 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) usbc̲cstd̲MainTask() USB device HCD/MGR MGR/HCD Driver registration Start usb̲hmsc̲MainInit() (HDCD registration) R_usb_hmsc_Registration() usbc̲cstd̲IdleTaskStart() Connect to USB device (Attach detection) usb2̲hmsc̲MainLoop() USB Reset usb̲hmsc̲Task() Enumeration usb2̲hmsc̲MainLoop() GET_DESCRIPTOR Callback Classcheck Task process R̲usb̲hmsc̲ClassCheck() flag set? usb2̲hstd̲HcdTask()
  • Page 50: Including Resources In Μitron And Non-Os Versions

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) Including Resources in µITRON and Non-OS Versions The methods of including resources when using the µITRON and non-OS versions are described below.   Including Resources in µITRON  When using the µITRON version (RI600), it is necessary to register tasks, mailboxes, memory pools, and interrupt vectors in the ITRON configuration file.
  • Page 51 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) 9.1.4 MSC Memory Pool Registration In the sample program, the MSC memory pool is registered as follows. memorypool[]{ name = USB_HMSC_MPL; wait_queue = TA_TFIFO; section = BRI_HEAP; siz_block = 64; num_block = 10;...
  • Page 52 USB Host Mass Storage Class Driver(HMSC)   Including Resources in Non-OS Scheduler In the sample program, it is composed of HCD, MGR, HUB, HMSCD, HMSDD, APL, and the scheduler. FAT file system library (TFAT) uses Renesas M3S-TFAT-Tiny-RX Table 9.1 Taks Lists Task Task function name...
  • Page 53 Renesas USB Device USB Host Mass Storage Class Driver(HMSC) 9.2.3 Task call The task used is called by the main loop function (usb_hmsc_MainLoop () function). In the usb_hmsc_MainLoop () function of r_usb_HMSC_apl.c, the task is called as follows. void usb_hmsc_MainLoop(void) if( R_usbc_cstd_CheckSchedule() == USBC_FLGSET ) usb_hstd_HcdTask((USBC_VP_INT)0);...
  • Page 54: 10. Limitations

    Renesas USB Device USB Host Mass Storage Class Driver(HMSC) 10. Limitations The following limitations apply to HMCD. 1. The program in this application note was created for the USB0-IP module. Only areas where it is important to recognize the difference between USB0-IP and USB1-IP are noted in the task ID definitions, etc.
  • Page 55 Renesas USB Device USB Host Mass Storage Class Driver 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. R01AN0513EJ0110 Rev.1.10 Page 55 of 55 Aug 10, 2011...
  • Page 57 Revision Record Description Rev. Date Page Summary 1.00 Dec.13.2010 — First edition issued 1.10 Aug.10.2011 — Add Target device R8A66597 Add 1.3 Related Documents Add 2.4.1 Folder Structure Update 2.4.2 File Structure Add 2.5.2 System Resource Definitions when Running Non-OS Version Update Fig.2.3 42-54...
  • Page 58 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.
  • Page 59 Electronics product for any application categorized as "Specific" without the prior written consent of Renesas Electronics. Further, you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as "Specific"...

This manual is also suitable for:

Rx62n groupR8a66597

Table of Contents