tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages

Functions

void tusbd_msc_mounted_cb (uint8_t coreid)
 Callback function that will be invoked when this interface is mounted (configured) by USB host. More...
 
void tusbd_msc_unmounted_cb (uint8_t coreid)
 Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) More...
 
uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void **pp_buffer, uint32_t lba, uint16_t block_count)
 Callback that is invoked when tinyusb stack received SCSI_CMD_READ_10 command from host. More...
 
uint16_t tusbd_msc_write10_cb (uint8_t coreid, uint8_t lun, void **pp_buffer, uint32_t lba, uint16_t block_count)
 Callback that is invoked when tinyusb stack received SCSI_CMD_WRITE_10 command from host. More...
 
msc_csw_status_t tusbd_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void const **pp_buffer, uint16_t *p_length)
 Callback that is invoked when tinyusb stack received an SCSI command other than SCSI_CMD_WRITE_10 and SCSI_CMD_READ_10 command from host. More...
 

Detailed Description

Function Documentation

void tusbd_msc_mounted_cb ( uint8_t  coreid)

Callback function that will be invoked when this interface is mounted (configured) by USB host.

Parameters
[in]coreidUSB Controller ID of the interface
Note
This callback should be used by Application to set-up interface-related data
uint16_t tusbd_msc_read10_cb ( uint8_t  coreid,
uint8_t  lun,
void **  pp_buffer,
uint32_t  lba,
uint16_t  block_count 
)

Callback that is invoked when tinyusb stack received SCSI_CMD_READ_10 command from host.

Parameters
[in]coreidUSB Controller ID
[in]lunTargeted Logical Unit
[out]pp_bufferPointer to buffer which application need to update with the response data's address. Must be accessible by USB controller (see TUSB_CFG_ATTR_USBRAM)
[in]lbaStarting Logical Block Address to be read
[in]block_countNumber of requested block
Return values
non-zeroActual number of block that application processed, must be less than or equal to block_count.
zeroIndicate error in retrieving data from application. Tinyusb device stack will STALL the corresponding endpoint and return failed status in command status wrapper phase.
Note
Host can request dozens of Kbytes in one command e.g block_count = 128, it is insufficient to require application to have that much of buffer. Instead, application can return the number of blocks it can processed, the stack after transferred that amount of data will continue to invoke this callback with adjusted lba and block_count.

Although this callback is called by tinyusb device task (non-isr context), however as all the classes share the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.
msc_csw_status_t tusbd_msc_scsi_cb ( uint8_t  coreid,
uint8_t  lun,
uint8_t  scsi_cmd[16],
void const **  pp_buffer,
uint16_t *  p_length 
)

Callback that is invoked when tinyusb stack received an SCSI command other than SCSI_CMD_WRITE_10 and SCSI_CMD_READ_10 command from host.

Parameters
[in]coreidUSB Controller ID
[in]lunTargeted Logical Unit
[in]scsi_cmdSCSI command contents, application should examine this command block to know which command host requested
[out]pp_bufferPointer to buffer which application need to update with the address to transfer data with host. The buffer address can be anywhere since the stack will copy its contents to a internal USB-accessible buffer.
[in]p_lengthlength
Return values
non-zeroActual number of block that application can receive and must be less than or equal to block_count.
zeroIndicate error in retrieving data from application. Tinyusb device stack will STALL the corresponding endpoint and return failed status in command status wrapper phase.
Note
Although this callback is called by tinyusb device task (non-isr context), however as all the classes share the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.
void tusbd_msc_unmounted_cb ( uint8_t  coreid)

Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)

Parameters
[in]coreidUSB Controller ID of the interface
Note
This callback should be used by Application to tear-down interface-related data
uint16_t tusbd_msc_write10_cb ( uint8_t  coreid,
uint8_t  lun,
void **  pp_buffer,
uint32_t  lba,
uint16_t  block_count 
)

Callback that is invoked when tinyusb stack received SCSI_CMD_WRITE_10 command from host.

Parameters
[in]coreidUSB Controller ID
[in]lunTargeted Logical Unit
[out]pp_bufferPointer to buffer which application need to update with the address to hold data from host Must be accessible by USB controller (see TUSB_CFG_ATTR_USBRAM)
[in]lbaStarting Logical Block Address to be write
[in]block_countNumber of requested block
Return values
non-zeroActual number of block that application can receive and must be less than or equal to block_count.
zeroIndicate error in retrieving data from application. Tinyusb device stack will STALL the corresponding endpoint and return failed status in command status wrapper phase.
Note
Host can request dozens of Kbytes in one command e.g block_count = 128, it is insufficient to require application to have that much of buffer. Instead, application can return the number of blocks it can processed, the stack after transferred that amount of data will continue to invoke this callback with adjusted lba and block_count.

Although this callback is called by tinyusb device task (non-isr context), however as all the classes share the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.