mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
Added MSC read10 and write10 function
This commit is contained in:
parent
b580a0b7f3
commit
bdee6397eb
@ -192,60 +192,59 @@ bool tuh_msc_request_sense(uint8_t dev_addr, uint8_t lun, void *resposne, tuh_ms
|
|||||||
return tuh_msc_scsi_command(dev_addr, &cbw, resposne, complete_cb);
|
return tuh_msc_scsi_command(dev_addr, &cbw, resposne, complete_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
bool tuh_msc_read10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count, tuh_msc_complete_cb_t complete_cb)
|
||||||
|
|
||||||
tusb_error_t tuh_msc_read10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count)
|
|
||||||
{
|
{
|
||||||
msch_interface_t* p_msch = &msch_data[dev_addr-1];
|
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||||
|
if ( !p_msc->mounted ){ return false;};
|
||||||
|
|
||||||
//------------- Command Block Wrapper -------------//
|
msc_cbw_t cbw = { 0 };
|
||||||
msc_cbw_add_signature(&p_msch->cbw, lun);
|
|
||||||
|
//------------- Command Block Wrapper -------------//
|
||||||
p_msch->cbw.total_bytes = p_msch->block_size*block_count; // Number of bytes
|
msc_cbw_add_signature(&cbw, lun);
|
||||||
p_msch->cbw.dir = TUSB_DIR_IN_MASK;
|
|
||||||
p_msch->cbw.cmd_len = sizeof(scsi_read10_t);
|
cbw.total_bytes = 512*block_count; // Number of bytes
|
||||||
|
cbw.dir = TUSB_DIR_IN_MASK;
|
||||||
//------------- SCSI command -------------//
|
cbw.cmd_len = sizeof(scsi_read10_t);
|
||||||
scsi_read10_t cmd_read10 =msch_sem_hdl
|
|
||||||
|
//------------- SCSI command -------------//
|
||||||
|
scsi_read10_t cmd_read10 =
|
||||||
{
|
{
|
||||||
.cmd_code = SCSI_CMD_READ_10,
|
.cmd_code = SCSI_CMD_READ_10,
|
||||||
.lba = tu_htonl(lba),
|
.lba = tu_htonl(lba),
|
||||||
.block_count = tu_htons(block_count)
|
.block_count = tu_htons(block_count)
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(p_msch->cbw.command, &cmd_read10, p_msch->cbw.cmd_len);
|
memcpy(cbw.command, &cmd_read10, cbw.cmd_len);
|
||||||
|
|
||||||
TU_ASSERT_ERR ( send_cbw(dev_addr, p_msch, p_buffer));
|
return tuh_msc_scsi_command(dev_addr, &cbw, p_buffer, complete_cb);
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tusb_error_t tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffer, uint32_t lba, uint16_t block_count)
|
bool tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count, tuh_msc_complete_cb_t complete_cb)
|
||||||
{
|
{
|
||||||
msch_interface_t* p_msch = &msch_data[dev_addr-1];
|
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||||
|
if ( !p_msc->mounted ){ return false;};
|
||||||
|
|
||||||
|
msc_cbw_t cbw = { 0 };
|
||||||
|
|
||||||
|
//------------- Command Block Wrapper -------------//
|
||||||
|
msc_cbw_add_signature(&cbw, lun);
|
||||||
|
|
||||||
|
cbw.total_bytes = 512*block_count; // Number of bytes
|
||||||
|
cbw.dir = TUSB_DIR_OUT;
|
||||||
|
cbw.cmd_len = sizeof(scsi_write10_t);
|
||||||
|
|
||||||
//------------- Command Block Wrapper -------------//
|
//------------- SCSI command -------------//
|
||||||
msc_cbw_add_signature(&p_msch->cbw, lun);
|
scsi_write10_t cmd_write10 =
|
||||||
|
{
|
||||||
p_msch->cbw.total_bytes = p_msch->block_size*block_count; // Number of bytes
|
.cmd_code = SCSI_CMD_WRITE_10,
|
||||||
p_msch->cbw.dir = TUSB_DIR_OUT;
|
.lba = tu_htonl(lba),
|
||||||
p_msch->cbw.cmd_len = sizeof(scsi_write10_t);
|
.block_count = tu_htons(block_count)
|
||||||
|
};
|
||||||
//------------- SCSI command -------------//
|
|
||||||
scsi_write10_t cmd_write10 =
|
memcpy(cbw.command, &cmd_write10, cbw.cmd_len);
|
||||||
{
|
|
||||||
.cmd_code = SCSI_CMD_WRITE_10,
|
return tuh_msc_scsi_command(dev_addr, &cbw, p_buffer, complete_cb);
|
||||||
.lba = tu_htonl(lba),
|
|
||||||
.block_count = tu_htons(block_count)
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(p_msch->cbw.command, &cmd_write10, p_msch->cbw.cmd_len);
|
|
||||||
|
|
||||||
TU_ASSERT_ERR ( send_cbw(dev_addr, p_msch, (void*) p_buffer));
|
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// MSC interface Reset (not used now)
|
// MSC interface Reset (not used now)
|
||||||
|
@ -81,20 +81,16 @@ bool tuh_msc_request_sense(uint8_t dev_addr, uint8_t lun, void *resposne, tuh_ms
|
|||||||
// Carry out SCSI READ CAPACITY (10) command in non-blocking manner.
|
// Carry out SCSI READ CAPACITY (10) command in non-blocking manner.
|
||||||
bool tuh_msc_read_capacity(uint8_t dev_addr, uint8_t lun, scsi_read_capacity10_resp_t* response, tuh_msc_complete_cb_t complete_cb);
|
bool tuh_msc_read_capacity(uint8_t dev_addr, uint8_t lun, scsi_read_capacity10_resp_t* response, tuh_msc_complete_cb_t complete_cb);
|
||||||
|
|
||||||
#if 0
|
|
||||||
/** \brief Perform SCSI READ 10 command to read data from MassStorage device
|
/** \brief Perform SCSI READ 10 command to read data from MassStorage device
|
||||||
* \param[in] dev_addr device address
|
* \param[in] dev_addr device address
|
||||||
* \param[in] lun Targeted Logical Unit
|
* \param[in] lun Targeted Logical Unit
|
||||||
* \param[out] p_buffer Buffer used to store data read from device. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
|
* \param[out] p_buffer Buffer used to store data read from device. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
|
||||||
* \param[in] lba Starting Logical Block Address to be read
|
* \param[in] lba Starting Logical Block Address to be read
|
||||||
* \param[in] block_count Number of Block to be read
|
* \param[in] block_count Number of Block to be read
|
||||||
* \retval TUSB_ERROR_NONE on success
|
* \retval true on success
|
||||||
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
|
* \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by \ref complete_cb callback function
|
||||||
* \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
|
|
||||||
* \retval 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 tuh_msc_read10 (uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count);
|
bool tuh_msc_read10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count, tuh_msc_complete_cb_t complete_cb);
|
||||||
|
|
||||||
/** \brief Perform SCSI WRITE 10 command to write data to MassStorage device
|
/** \brief Perform SCSI WRITE 10 command to write data to MassStorage device
|
||||||
* \param[in] dev_addr device address
|
* \param[in] dev_addr device address
|
||||||
@ -102,14 +98,10 @@ tusb_error_t tuh_msc_read10 (uint8_t dev_addr, uint8_t lun, void * p_buffer, uin
|
|||||||
* \param[in] p_buffer Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
|
* \param[in] p_buffer Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
|
||||||
* \param[in] lba Starting Logical Block Address to be written
|
* \param[in] lba Starting Logical Block Address to be written
|
||||||
* \param[in] block_count Number of Block to be written
|
* \param[in] block_count Number of Block to be written
|
||||||
* \retval TUSB_ERROR_NONE on success
|
* \retval true on success
|
||||||
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
|
* \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by \ref complete_cb callback function
|
||||||
* \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
|
|
||||||
* \retval 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 tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffer, uint32_t lba, uint16_t block_count);
|
bool tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uint32_t lba, uint16_t block_count, tuh_msc_complete_cb_t complete_cb);
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------- Application Callback -------------//
|
//------------- Application Callback -------------//
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user