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

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

Data Structures

struct  uhi_msc_lun_t
 Logical Unit Number (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,
  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.

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

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

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, uhi_msc_dev_t::nb_lun, and NULL.

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.
Parameters
[in]lunLUN number
Returns
Pointer on the LUN information structure.

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

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

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

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.

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

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.

Note
The sector size used to define the data section is the sector size returned by LUN in field.
Parameters
[in]lunLUN number
[in]addrSector address to read
[out]ramRAM address used to store the data
[in]nb_sectorNumber of sector to read
[in]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, callback, 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.

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
Parameters
[in]lunLUN number
[in]callbackCallback to call at the end of SCSI command
Returns
True, if the Small Computer System Interface (SCSI) command has been accepted.

References callback, NULL, 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.

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

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.

Note
The sector size used to define the data section is the sector size returned by LUN in field.
Parameters
[in]lunLUN number
[in]addrSector address to write
[in]ramRAM address of data to write
[in]nb_sectorNumber of sector to write
[in]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, callback, 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.