background image

Renesas USB Device 

USB Host Mass Storage Class Driver(HMSC) 

R01AN0513EJ0110  Rev.1.10 

 

Page 16 of 55 

Aug 10, 2011 

 

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 

USBC_PDT_SEQUENTIAL 

0x01 

Write-once device 

USBC_PDT_WRITEONCE 

0x04 

CD-ROM device 

USBC_PDT_CDROM 

0x05 

Optical device 

USBC_PDT_OPTICAL 

0x07 

Undefined device 

USBC_PDT_UNKNOWN 

0x1F 

User macro definitions 
Max. unit count 

USBC_MAXUNITNUM 

Max. boot partition count 

USBC_BOOTPARNUM 

Max. drive count 

USBC_MAXDRIVE 

10 

Max. device count 

USBC_MAXSTRAGE 

Drive start number 

USBC_DRIVE 

Internal memory drive number 

USBC_MEDIADRIVE 

Record code 
PBR record code 

USBC_PBR_ADDR 

0x01 

MBR record code 

USBC_MBR_ADDR 

0x02 

EMBR record code 

USBC_EMBR_ADDR 

0x03 

Boot record error code 

USBC_BOOT_ERROR 

0x05 

Boot record 
Recorder identification signature code USBC_BOOTRECORD_SIG 0xAA55 

USBC_STARTDISK 0x80 

MBR identification start code 

USBC_NOTSTARTDISK 0x00 

PBR identification nop code 

USBC_NOPCODE 

0x90 

USBC_JMPCODE1 0xEB 

PBR identification jmp code 

USBC_JMPCODE2 0xE9 

Partition type 
No partition 

USBC_PT_NONE 

0x00 

FAT12 USBC_PT_FAT12/USBC_PT_FAT12A 

0x01 

FAT16 USBC_PT_FAT16/USBC_PT_FAT16A 

0x04 

FAT16 USBC_PT_FAT16B 

0x06 

FAT16 USBC_PT_FAT16X 

0x0E 

FAT32 USBC_PT_FAT32/USBC_PT_FAT32A 

0x0B 

FAT32 USBC_PT_FAT32X 

0x0C 

Extended partition 

USBC_PT_EPRT/USBC_PT_EPRTA 

0x05 

Extended partition 

USBC_PT_EPRTB 

0x0F 

Extended partition (not supported) 

USBC_PT_EPRTC 

0x85 

7 Transfer 

end 

notification 

 Transfer 

end 

USBC_HMSC_OK 

0x00 

 

CBW transfer error 

USBC_HMSC_CBW_ERR 

-2 

 

Read data error 

USBC_HMSC_DAT_RD_ERR 

-3 

 

Write data error 

USBC_HMSC_DAT_WR_ERR 

-4 

 CSW 

error 

USBC_HMSC_CSW_ERR 

-5 

 Phase 

error 

USBC_HMSC_CSW_PHASE_ERR -6 

 Submit 

error 

USBC_HMSC_SUBMIT_ERR 

-7 

 

Summary of Contents for R8A66597

Page 1: ...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...

Page 2: ...nesas 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 ht...

Page 3: ...uler 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...

Page 4: ...D USB host mass storage class driver Its main functions are as follows 1 Activating HMSCD 2 Verifying connected devices 3 Checking drive information 4 Mounting drives 5 Accessing USB mass storage devi...

Page 5: ...unctionality Created by the customer to match the system specifications FSL FAT file system with specifications defined by the user FSI FSL HMSDD interface functions They should be modified to match F...

Page 6: ...bc_cstd_ MainTask usb_hmsc_ MainInit usb_hmsc_ MainLoop usb_hmsc_MainInit Initialize target system Initialize USB function Initialize scheduler function Set priority Register driver Return usb_hmsc_ M...

Page 7: ...SB0 and USB1 include HMSC Common header file common header file for MSCFW and MSC2FW MSC2FW For USB1 Configuration is the same as MSCFW RI600_4 ITRON Folder not included in non OS version config_Hmsc...

Page 8: ...xternal reference header file TFAT lib_src r_tfat_drv_if c TFAT interface functions Sample skip USB1 2 5 System Resources 2 5 1 System Resource Definitions when Running ITRON Version The uITRON resour...

Page 9: ...USBC_PRI_3 3 Scheduler registration task USB_HMSCSMP_TSK usb_hmsc_SampleAplTask Storage Device Driver Task Task ID default value USBC_TID_5 Task priority USB_HSTRG_PRI default value USBC_PRI_3 USB_HM...

Page 10: ...HCD read_sector R_usb_hmsc_ StrgReadSector R_usb_hmsc_ Read10 Read sector R_usb_hstd_ SetPipeRegistration transmission usb_hmsc_Submitutr CBW R_usb_hstd_ SetPipeRegistration recipition usb_hmsc_Submit...

Page 11: ...nt drives Drive number All drives All units Unit count FSL FSI Drive mount R_usb_hmsc_ StrgTaskOpen R_usb_hmsc_ TaskOpen R_usb_hmsc_StorageOpen callback devconfig R_usb_hmsc_ StrgDriveSearch Initializ...

Page 12: ...ed when HCD is changed This can use Host mass storage class driver without changing it HMSCD supports storage commands necessary for accessing USB storage devices and sample storage commands HMSCD has...

Page 13: ...ration flag 3 6 HMSCD Functions Table 3 3 lists the functions of HMSCD Table 3 3 HMSCD Functions Function Name Description 1 usb_hmsc_SmpBotDescriptor Confirms mass storage class and BOT protocol 2 us...

Page 14: ...ansfer Length Data length of transmit receive data uint8_t bmCBWFlags CBW Direction Data transmit receive direction uint8_t bCBWLUN Logical Unit Number Unit number uint8_t bCBWCBLength CBWCB Length Co...

Page 15: ...status Storage command OK USBC_MSC_CSW_OK 0x00 Storage command FAIL USBC_MSC_CSW_NG 0x01 2 Phase error USBC_MSC_CSW_PHASE_ERR 0x02 Descriptor check USBC_ATAPI 0x05 USB subclass code USBC_SCSI 0x06 US...

Page 16: ...MBR record code USBC_MBR_ADDR 0x02 EMBR record code USBC_EMBR_ADDR 0x03 4 Boot record error code USBC_BOOT_ERROR 0x05 Boot record Recorder identification signature code USBC_BOOTRECORD_SIG 0xAA55 USB...

Page 17: ...ipeInfo uint8_t table uint16_t msgnum uint16_t speed uint16_t length uint8_t table Interface descriptor table address uint16_t msgnum Pipe information table offset uint16_t speed Communication speed A...

Page 18: ...Notes Table 3 12 usb_hmsc_DataOut Name TRANSMIT DATA Command Execution Call format uint16_t usb_hmsc_DataOut uint16_t drvnum uint8_t buff uint32_t size uint16_t drvnum Drive number uint8_t buff Transm...

Page 19: ...Driver number Return values void Description Updates usb_ghmsc_CbwTagNo in the global area Notes When usb_ghmsc_CbwTagNo 0 the value is incremented by 1 Table 3 16 usb_hmsc_CheckCsw Name Check CSW Ca...

Page 20: ...eration 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 i...

Page 21: ...t16_t usb_ghmsc_OutPipe USBC_MAXSTRAGE 2 Pipe number using OUT direction endpoint 5 uint16_t usb_ghmsc_InPipe USBC_MAXSTRAGE 2 Pipe number using IN direction endpoint 6 uint8_t usb_ghmsc_Data 5120 Dat...

Page 22: ...l back run function uint8_t errcnt Error count Error information area used by HCD uint8_t segment Segment information Continuous communication determination 4 5 HCI Function Details Table 4 4 usb_hmsc...

Page 23: ...e CSW Call format uint16_t usb_hmsc_GetCsw uint16_t drvnum Arguments uint16_t drvnum Drive number Return values uint16_t USBC_HMSC_OK Normal end USBC_HMSC_CSW_ERR CBW transfer error USBC_HMSC_SUBMIT_E...

Page 24: ...Notes Table 4 10 R_usb_hmsc_MassStorageReset Name MassStorageReset Request Execution Call format uint16_t R_usb_hmsc_MassStorageReset uint16_t drvnum for uITRON Arguments uint16_t drvnum Drive number...

Page 25: ...ocessWaitTmo void Arguments uint16_t tmo Timeout duration ms Return values uint16_t Status Description Uses the TRCV_MSG system call to wait for receipt of a message Notes The message in the HMSCD are...

Page 26: ...on in the MGR classcheck call back or call it from a function registered in the classcheck call back 3 R_usb_hmsc_TaskOpen Starts HMSCD This function is called by the R_usb_hmsc_StrgTaskOpen function...

Page 27: ...e count and drive count and analyzes the interface descriptor table Confirms that the items listed below match HMSCD and reads the serial number if operation is possible Updates the pipe information t...

Page 28: ...nd is executed to get error information Table 5 7 R_usb_hmsc_Write10 Name WRITE10 command executed Call format uint16_t R_usb_hmsc_Write10 uint16_t side uint8_t buff uint32_t secno uint16_t seccnt uin...

Page 29: ...buff uint16_t side Drive number Arguments uint8_t buff Receive data area Return values uint16_t Error code Description Creates and executes the INQUIRY command Notes When a command error occurs the RE...

Page 30: ...de Drive number Arguments uint8_t buff Transmit data area Return values uint16_t Error code Description Creates and executes the MODE_SELECT6 command Notes When a command error occurs the REQUEST_SENS...

Page 31: ..._tfat_disk_write Writes data 5 usb_hmsc_SmpFsiSectorInitialized Initializes global variable of FSL 6 usb_hmsc_SmpFsiOffsetSectorRead Gets the offset sector 7 usb_hmsc_SmpFsiFileSystemInitialized Sets...

Page 32: ...ulates the logical block address from the sector number It calculates the read data count from the sector count and sector size global variables Table 6 5 write_sector R_tfat_disk_write Name Write Sec...

Page 33: ...s Table 6 7 usb_hmsc_SmpFsiOffsetSectorRead Name Read Offset Sector Call format uint32_t usb_hmsc_SmpFsiOffsetSectorRead uint16_t side Arguments uint16_t side Drive number Return values uint32_t Offse...

Page 34: ...to one partition in case of TFAT can be connected The max unit count and max partition count can be changed in the header file A device that does not respond to the GetMaxUnit request operates as a s...

Page 35: ...ice address 17 usb_hmsc_SmpCheckAddr Returns the device address of the drive or an error if the drive is unused 18 usb_hmsc_SmpDrive2Msgnum Changes drive number to device number 20 R_usb_hmsc_StrgTask...

Page 36: ...l response are checked up to three times The function reads the logical block address 0x00 area of all accessible units and increments the drive count for each Notes When a GetMaxUnit request produces...

Page 37: ...The data that is read is used to determine whether the partition type is PBR or MBR The determination covers all four partition types and the block address is set When an extended partition exists the...

Page 38: ...r uint16_t seccnt Sector count Arguments uint32_t trans_byte Transfer data length Return values uint16_t USBC_DONE Normal end USBC_ERROR Error end Description Reads the sector information of the drive...

Page 39: ...access to logical unit PREVENT_ALLOW Enable disable media removal READ_FORMAT_CAPACITY Get formattable capacity READ_CAPACITY Get capacity information of logical unit READ10 Read data WRITE10 Write da...

Page 40: ...evice address Notes Table 7 20 usb_hmsc_SmpCheckAddr Name Check Drive Number Call format uint16_t usb_hmsc_SmpCheckAddr uint16_t side Arguments uint16_t side Drive number Return values uint16_t Device...

Page 41: ...xample the drives are managed as shown below when USBC_DRIVE is set to 1 the USB storage device has three units unit 0 has three partitions total of three partitions including extensions unit 1 has no...

Page 42: ...ple Operating Environment 8 1 2 Overview of Application Program Functions The HMSC bundles a sample application APL intended for switch operation on the board such as RX62N RSK After enumeration the p...

Page 43: ...gistration API R_usb_hmsc_Registration function is used to register the open function For details of the HMSC registration API see table5 17 The HMSC registration API should be called in the initializ...

Page 44: ...for mount drive USBC_HMSC_FILEWRITE 0x1002 Sequence for write once hmscdemo txt file in the MSC device USBC_HMSC_FILEREAD 0x1001 Sequence for read once hmscdemo txt file from the MSC device USBC_KEY_...

Page 45: ...msc_MainInit Host MSC initialization function usb_hmsc_MainLoop Host MSC main loop usb_hmsc_SetTaskPri Task Priority Setting Processing Only non OS usb_hmsc_sample Application Task Processing Only uIT...

Page 46: ...ocessing Call format usb_hmsc_MainInit Arguments void Return values void Description The initialization processing includes the following Interrupt settings DMA initialization settings USB block opera...

Page 47: ...he a data of 512 bytes is written in hmscdemo txt file 5 hmscdemo txt file is read until the file operation switch is pushed 6 During the Read process each time the device is read 100 times LED0 3 on...

Page 48: ...ferring to usb_shmsc_SmpAplProcess Notes Table 8 12 R_usb_hmsc_AplClear Name Application Global Variable Initialization Processing Call format R_usb_hmsc_AplClear Arguments void Return values void Des...

Page 49: ...ce Attach detection USB Reset usbc cstd MainTask SET_CONFIGURATION usb2 hmsc MainLoop USB device Task process flag set Return usb2 hmsc MainLoop Yes No usb2 hstd HcdTask usb2 hstd MgrTask usb2 hmsc St...

Page 50: ...add it to the project file Delete these lines GLB __RI_DEFAULT_FINTHDR_0 to GLB __RI_DEFAULT_FINTHDR_19 LWORD __RI_DEFAULT_FINTHDR_0 to LWOR __RI_DEFAULT_FINTHDR_19 9 1 1 MSC Registration In the samp...

Page 51: ...Aug 10 2011 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_bl...

Page 52: ..._TID_4 Task ID define USB_HMSC_PRI USBC_PRI_3 Priority define USB_HMSC_MBX USB2_HMSC_TSK Mailbox ID define USB_HMSC_MPL USB2_HMSC_TSK Memorypool ID Host Sample Task define USB_HSTRG_TSK USBC_TID_5 Tas...

Page 53: ...n 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 HCD Task usb_h...

Page 54: ...of members of different types Depending on the compiler the address alignment of the structure members may be shifted 3 When there is no response to a GetMaxUnit request for three seconds or more the...

Page 55: ...iver R01AN0513EJ0110 Rev 1 10 Page 55 of 55 Aug 10 2011 Website and Support Renesas Electronics Website http www renesas com Inquiries http www renesas com inquiry All trademarks and registered tradem...

Page 56: ......

Page 57: ...010 First edition issued 1 10 Aug 10 2011 Add Target device R8A66597 2 Add 1 3 Related Documents 7 8 Add 2 4 1 Folder Structure Update 2 4 2 File Structure 9 Add 2 5 2 System Resource Definitions when...

Page 58: ...supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is sup...

Page 59: ...artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life 8 You shou...

Reviews: