|
bool | tusbh_msc_is_mounted (uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT |
| Check if device supports MassStorage interface or not. More...
|
|
bool | tusbh_msc_is_busy (uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT |
| Check if the interface is currently busy or not. More...
|
|
uint8_t const * | tusbh_msc_get_vendor_name (uint8_t dev_addr) |
| Get SCSI vendor's name of MassStorage device. More...
|
|
uint8_t const * | tusbh_msc_get_product_name (uint8_t dev_addr) |
| Get SCSI product's name of MassStorage device. More...
|
|
tusb_error_t | tusbh_msc_get_capacity (uint8_t dev_addr, uint32_t *p_last_lba, uint32_t *p_block_size) |
| Get SCSI Capacity of MassStorage device. More...
|
|
tusb_error_t | tusbh_msc_read10 (uint8_t dev_addr, uint8_t lun, void *p_buffer, uint32_t lba, uint16_t block_count) ATTR_WARN_UNUSED_RESULT |
| Perform SCSI READ 10 command to read data from MassStorage device. More...
|
|
tusb_error_t | tusbh_msc_write10 (uint8_t dev_addr, uint8_t lun, void const *p_buffer, uint32_t lba, uint16_t block_count) ATTR_WARN_UNUSED_RESULT |
| Perform SCSI WRITE 10 command to write data to MassStorage device. More...
|
|
tusb_error_t | tusbh_msc_request_sense (uint8_t dev_addr, uint8_t lun, uint8_t *p_data) |
| Perform SCSI REQUEST SENSE command, used to retrieve sense data from MassStorage device. More...
|
|
tusb_error_t | tusbh_msc_test_unit_ready (uint8_t dev_addr, uint8_t lun, msc_cmd_status_wrapper_t *p_csw) ATTR_WARN_UNUSED_RESULT |
| Perform SCSI TEST UNIT READY command to test if MassStorage device is ready. More...
|
|
void | tusbh_msc_mounted_cb (uint8_t dev_addr) |
| Callback function that will be invoked when a device with MassStorage interface is mounted. More...
|
|
void | tusbh_msc_unmounted_cb (uint8_t dev_addr) |
| Callback function that will be invoked when a device with MassStorage interface is unmounted. More...
|
|
void | tusbh_msc_isr (uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes) |
| Callback function that is invoked when an transferring event occurred. More...
|
|
The interface API includes status checking function, data transferring function and callback functions
tusb_error_t tusbh_msc_get_capacity |
( |
uint8_t |
dev_addr, |
|
|
uint32_t * |
p_last_lba, |
|
|
uint32_t * |
p_block_size |
|
) |
| |
Get SCSI Capacity of MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
[out] | p_last_lba | Last Logical Block Address of device |
[out] | p_block_size | Block Size of device in bytes |
- Return values
-
pointer | to product's name or NULL if specified device does not support MassStorage |
- Note
- MassStorage's capacity can be computed by last LBA x block size (in bytes). During enumeration, the stack has already retrieved (via SCSI READ CAPACITY 10) and store this information internally. There is no need for application to re-send SCSI READ CAPACITY 10 command
uint8_t const* tusbh_msc_get_product_name |
( |
uint8_t |
dev_addr | ) |
|
Get SCSI product's name of MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
- Returns
- pointer to product's name or NULL if specified device does not support MassStorage
- Note
- SCSI product's name is 16-byte length field in scsi_inquiry_data_t. During enumeration, the stack has already retrieved (via SCSI INQUIRY) and store this information internally. There is no need for application to re-send SCSI INQUIRY command or allocate buffer for this.
uint8_t const* tusbh_msc_get_vendor_name |
( |
uint8_t |
dev_addr | ) |
|
Get SCSI vendor's name of MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
- Returns
- pointer to vendor's name or NULL if specified device does not support MassStorage
- Note
- SCSI vendor's name is 8-byte length field in scsi_inquiry_data_t. During enumeration, the stack has already retrieved (via SCSI INQUIRY) and store this information internally. There is no need for application to re-send SCSI INQUIRY command or allocate buffer for this.
bool tusbh_msc_is_busy |
( |
uint8_t |
dev_addr | ) |
|
Check if the interface is currently busy or not.
- Parameters
-
[in] | dev_addr | device address |
- Return values
-
true | if the interface is busy meaning the stack is still transferring/waiting data from/to device |
false | if the interface is not busy meaning the stack successfully transferred data from/to device |
- Note
- This function is used to check if previous transfer is complete (success or error), so that the next transfer can be scheduled. User needs to make sure the corresponding interface is mounted (by tusbh_msc_is_mounted) before calling this function
bool tusbh_msc_is_mounted |
( |
uint8_t |
dev_addr | ) |
|
Check if device supports MassStorage interface or not.
- Parameters
-
[in] | dev_addr | device address |
- Return values
-
true | if device supports |
false | if device does not support or is not mounted |
void tusbh_msc_isr |
( |
uint8_t |
dev_addr, |
|
|
tusb_event_t |
event, |
|
|
uint32_t |
xferred_bytes |
|
) |
| |
Callback function that is invoked when an transferring event occurred.
- Parameters
-
[in] | dev_addr | Address of device |
[in] | event | an value from tusb_event_t |
[in] | xferred_bytes | Number of bytes transferred via USB bus |
- Note
- event can be one of following
- TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully.
- TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
- TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
-
void tusbh_msc_mounted_cb |
( |
uint8_t |
dev_addr | ) |
|
Callback function that will be invoked when a device with MassStorage interface is mounted.
- Parameters
-
[in] | dev_addr | Address of newly mounted device |
- Note
- This callback should be used by Application to set-up interface-related data
tusb_error_t tusbh_msc_read10 |
( |
uint8_t |
dev_addr, |
|
|
uint8_t |
lun, |
|
|
void * |
p_buffer, |
|
|
uint32_t |
lba, |
|
|
uint16_t |
block_count |
|
) |
| |
Perform SCSI READ 10 command to read data from MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
[in] | lun | Targeted Logical Unit |
[out] | p_buffer | Buffer used to store data read from device. Must be accessible by USB controller (see TUSB_CFG_ATTR_USBRAM) |
[in] | lba | Starting Logical Block Address to be read |
[in] | block_count | Number of Block to be read |
- Return values
-
TUSB_ERROR_NONE | on success |
TUSB_ERROR_INTERFACE_IS_BUSY | if the interface is already transferring data with device |
TUSB_ERROR_DEVICE_NOT_READY | if device is not yet configured (by SET CONFIGURED request) |
TUSB_ERROR_INVALID_PARA | if input parameters are not correct |
- Note
- This function is non-blocking and returns immediately. The result of USB transfer will be reported by the interface's callback function
tusb_error_t tusbh_msc_request_sense |
( |
uint8_t |
dev_addr, |
|
|
uint8_t |
lun, |
|
|
uint8_t * |
p_data |
|
) |
| |
Perform SCSI REQUEST SENSE command, used to retrieve sense data from MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
[in] | lun | Targeted Logical Unit |
[in] | p_data | Buffer to store response's data from device. Must be accessible by USB controller (see TUSB_CFG_ATTR_USBRAM) |
- Return values
-
TUSB_ERROR_NONE | on success |
TUSB_ERROR_INTERFACE_IS_BUSY | if the interface is already transferring data with device |
TUSB_ERROR_DEVICE_NOT_READY | if device is not yet configured (by SET CONFIGURED request) |
TUSB_ERROR_INVALID_PARA | if input parameters are not correct |
- Note
- This function is non-blocking and returns immediately. The result of USB transfer will be reported by the interface's callback function
Perform SCSI TEST UNIT READY command to test if MassStorage device is ready.
- Parameters
-
[in] | dev_addr | device address |
[in] | lun | Targeted Logical Unit |
- Return values
-
TUSB_ERROR_NONE | on success |
TUSB_ERROR_INTERFACE_IS_BUSY | if the interface is already transferring data with device |
TUSB_ERROR_DEVICE_NOT_READY | if device is not yet configured (by SET CONFIGURED request) |
TUSB_ERROR_INVALID_PARA | if input parameters are not correct |
- Note
- This function is non-blocking and returns immediately. The result of USB transfer will be reported by the interface's callback function
void tusbh_msc_unmounted_cb |
( |
uint8_t |
dev_addr | ) |
|
Callback function that will be invoked when a device with MassStorage interface is unmounted.
- Parameters
-
[in] | dev_addr | Address of newly unmounted device |
- Note
- This callback should be used by Application to tear-down interface-related data
tusb_error_t tusbh_msc_write10 |
( |
uint8_t |
dev_addr, |
|
|
uint8_t |
lun, |
|
|
void const * |
p_buffer, |
|
|
uint32_t |
lba, |
|
|
uint16_t |
block_count |
|
) |
| |
Perform SCSI WRITE 10 command to write data to MassStorage device.
- Parameters
-
[in] | dev_addr | device address |
[in] | lun | Targeted Logical Unit |
[in] | p_buffer | Buffer containing data. Must be accessible by USB controller (see TUSB_CFG_ATTR_USBRAM) |
[in] | lba | Starting Logical Block Address to be written |
[in] | block_count | Number of Block to be written |
- Return values
-
TUSB_ERROR_NONE | on success |
TUSB_ERROR_INTERFACE_IS_BUSY | if the interface is already transferring data with device |
TUSB_ERROR_DEVICE_NOT_READY | if device is not yet configured (by SET CONFIGURED request) |
TUSB_ERROR_INVALID_PARA | if input parameters are not correct |
- Note
- This function is non-blocking and returns immediately. The result of USB transfer will be reported by the interface's callback function