Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
UHI for Mass Storage Class

Common APIs used by high level application to use this USB host class.

Modules

 Implementation of UHI Mass Storage Class
 Class internal implementation.
 
 USB host Mass Storage interface for control access module
 Layer added on UHI MSC interface to allow the usage of control access module.
 
 Interface with USB Host Core (UHC)
 Define and functions required by UHC.
 

Data Structures

struct  uhi_msc_lun_t
 LUN structure information. More...
 

Functions

uint8_t uhi_msc_get_lun (void)
 Gives the number of LUN available Note: A LUN can be available, but with a status LUN_NOT_PRESENT. More...
 
bool uhi_msc_is_available (void)
 Tests if the interface UHI Mass Storage is available The UHI Mass Storage can be busy during the enumeration of a USB Device MSC. More...
 

Struct to access at Logical Unit Numbers (LUNs)

enum  lun_status_t {
  LUN_GOOD = 0,
  LUN_FAIL = 1,
  LUN_NOT_PRESENT = 2,
  LUN_BUSY = 3
}
 Status of LUN. More...
 
typedef void(* uhi_msc_scsi_callback_t )(bool)
 Callback type used by uhi_msc_scsi() functions. More...
 

Functions to access at LUNs

uhi_msc_lun_tuhi_msc_get_lun_desc (uint8_t lun)
 Gives information about a LUN. More...
 
bool uhi_msc_scsi_test_unit_ready (uint8_t lun, uhi_msc_scsi_callback_t callback)
 Checks and update the status of the LUN. More...
 
bool uhi_msc_scsi_read_10 (uint8_t lun, uint32_t addr, uint8_t *ram, uint8_t nb_sector, uhi_msc_scsi_callback_t callback)
 Reads a LUN data section to RAM buffer Note: The sector size used to define the data section is the sector size returned by LUN in field. More...
 
bool uhi_msc_scsi_write_10 (uint8_t lun, uint32_t addr, const uint8_t *ram, uint8_t nb_sector, uhi_msc_scsi_callback_t callback)
 Writes a RAM buffer in a LUN data section Note: The sector size used to define the data section is the sector size returned by LUN in field. More...
 

typedef void(* uhi_msc_scsi_callback_t)(bool)

Callback type used by uhi_msc_scsi() functions.

Status of LUN.

Enumerator
LUN_GOOD 

Success, memory ready.

LUN_FAIL 

An error occurred.

LUN_NOT_PRESENT 

Memory unplugged.

LUN_BUSY 

Memory not initialized or changed.

uint8_t uhi_msc_get_lun ( void  )

Gives the number of LUN available Note: A LUN can be available, but with a status LUN_NOT_PRESENT.

It is the case for a card reader without card.

Returns
Number of LUN available

References uhi_msc_dev_t::dev, and uhi_msc_dev_t::nb_lun.

Referenced by uhi_msc_mem_get_lun().

uhi_msc_lun_t* uhi_msc_get_lun_desc ( uint8_t  lun)

Gives information about a LUN.

Parameters
lunLUN number
Returns
Pointer on the LUN information structure.

References uhi_msc_dev_t::lun, and uhi_msc_dev_t::nb_lun.

Referenced by uhi_msc_mem_read_10_ram(), uhi_msc_mem_read_capacity(), uhi_msc_mem_read_sector_size(), uhi_msc_mem_test_unit_ready(), uhi_msc_mem_wr_protect(), and uhi_msc_mem_write_10_ram().

bool uhi_msc_is_available ( void  )

Tests if the interface UHI Mass Storage is available The UHI Mass Storage can be busy during the enumeration of a USB Device MSC.

Returns
true, if UHI Mass Storage is available

References b_uhi_msc_free.

Referenced by uhi_msc_mem_get_lun(), uhi_msc_mem_read_10_ram(), uhi_msc_mem_read_capacity(), uhi_msc_mem_read_sector_size(), uhi_msc_mem_test_unit_ready(), uhi_msc_mem_wr_protect(), and uhi_msc_mem_write_10_ram().

bool uhi_msc_scsi_read_10 ( uint8_t  lun,
uint32_t  addr,
uint8_t *  ram,
uint8_t  nb_sector,
uhi_msc_scsi_callback_t  callback 
)

Reads a LUN data section to RAM buffer Note: The sector size used to define the data section is the sector size returned by LUN in field.

Parameters
lunLUN number
addrSector address to read
ramRAM address used to store the data
nb_sectorNumber of sector to read
callbackCallback to call at the end of scsi command
Returns
true, if the scsi command has been accepted

References sbc_read_capacity10_data::block_len, uhi_msc_lun_t::capacity, MSB0W, MSB1W, MSB2W, MSB3W, SBC_READ10, uhi_msc_scsi(), uhi_msc_scsi_callback, uhi_msc_scsi_read_10_done(), uhi_msc_select_lun(), and USB_CBW_DIRECTION_IN.

Referenced by uhi_msc_mem_read_10_ram().

bool uhi_msc_scsi_test_unit_ready ( uint8_t  lun,
uhi_msc_scsi_callback_t  callback 
)

Checks and update the status of the LUN.

Parameters
lunLUN number
callbackCallback to call at the end of scsi command
Returns
true, if the scsi command has been accepted

References SPC_TEST_UNIT_READY, uhi_msc_scsi(), uhi_msc_scsi_callback, uhi_msc_scsi_test_unit_ready_done(), uhi_msc_select_lun(), and USB_CBW_DIRECTION_OUT.

Referenced by uhi_msc_mem_test_unit_ready().

bool uhi_msc_scsi_write_10 ( uint8_t  lun,
uint32_t  addr,
const uint8_t *  ram,
uint8_t  nb_sector,
uhi_msc_scsi_callback_t  callback 
)

Writes a RAM buffer in a LUN data section Note: The sector size used to define the data section is the sector size returned by LUN in field.

Parameters
lunLUN number
addrSector address to write
ramRAM address of data to write
nb_sectorNumber of sector to write
callbackCallback to call at the end of scsi command
Returns
true, if the scsi command has been accepted

References sbc_read_capacity10_data::block_len, uhi_msc_lun_t::capacity, MSB0W, MSB1W, MSB2W, MSB3W, SBC_WRITE10, uhi_msc_scsi(), uhi_msc_scsi_callback, uhi_msc_scsi_write_10_done(), uhi_msc_select_lun(), and USB_CBW_DIRECTION_OUT.

Referenced by uhi_msc_mem_write_10_ram().