sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c
static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
{
  USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
  uint32_t len;

  if (hmsc == NULL)
  {
    return -1;
  }

  len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;

#ifdef USE_USBD_COMPOSITE
  /* Get the Endpoints addresses allocated for this class instance */
  MSCInEpAdd  = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
#endif /* USE_USBD_COMPOSITE */

  len = MIN(len, MSC_MEDIA_PACKET);

  if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Read(lun, hmsc->bot_data,
                                                                    hmsc->scsi_blk_addr,
                                                                    (len / hmsc->scsi_blk_size)) < 0)
  {
    SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
    return -1;
  }

  (void)USBD_LL_Transmit(pdev, MSCInEpAdd, hmsc->bot_data, len);

  hmsc->scsi_blk_addr += (len / hmsc->scsi_blk_size);
  hmsc->scsi_blk_len -= (len / hmsc->scsi_blk_size);

  /* case 6 : Hi = Di */
  hmsc->csw.dDataResidue -= len;

  if (hmsc->scsi_blk_len == 0U)
  {
    hmsc->bot_state = USBD_BOT_LAST_DATA_IN;
  }

  return 0;
}
/**
  * @brief  SCSI_ProcessRead
  *         Handle Read Process
  * @param  lun: Logical unit number
  * @retval status
  */
@brief  SCSI_ProcessRead
Handle Read Process
@param  lun: Logical unit number
@retval status
@brief SCSI_ProcessRead Handle Read Process @param lun : Logical unit number @retval status
static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
{
  USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
  uint32_t len;
  if (hmsc == NULL)
  {
    return -1;
  }
  len = hmsc->scsi_blk_len * hmsc->scsi_blk_size;
#ifdef USE_USBD_COMPOSITE
  MSCInEpAdd  = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
#endif 
  len = MIN(len, MSC_MEDIA_PACKET);
  if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Read(lun, hmsc->bot_data,
                                                                    hmsc->scsi_blk_addr,
                                                                    (len / hmsc->scsi_blk_size)) < 0)
  {
    SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, UNRECOVERED_READ_ERROR);
    return -1;
  }
  (void)USBD_LL_Transmit(pdev, MSCInEpAdd, hmsc->bot_data, len);
  hmsc->scsi_blk_addr += (len / hmsc->scsi_blk_size);
  hmsc->scsi_blk_len -= (len / hmsc->scsi_blk_size);
  hmsc->csw.dDataResidue -= len;
  if (hmsc->scsi_blk_len == 0U)
  {
    hmsc->bot_state = USBD_BOT_LAST_DATA_IN;
  }
  return 0;
}
static int8_t SCSI_ProcessRead ( USBD_HandleTypeDef * pdev , uint8_t lun ) { USBD_MSC_BOT_HandleTypeDef * hmsc = ( USBD_MSC_BOT_HandleTypeDef * ) pdev -> pClassDataCmsit [ pdev -> classId ] ; uint32_t len ; if ( hmsc == NULL ) { return -1 ; } len = hmsc -> scsi_blk_len * hmsc -> scsi_blk_size ; #ifdef USE_USBD_COMPOSITE MSCInEpAdd = USBD_CoreGetEPAdd ( pdev , USBD_EP_IN , USBD_EP_TYPE_BULK ) ; #endif len = MIN ( len , MSC_MEDIA_PACKET ) ; if ( ( ( USBD_StorageTypeDef * ) pdev -> pUserData [ pdev -> classId ] ) -> Read ( lun , hmsc -> bot_data , hmsc -> scsi_blk_addr , ( len / hmsc -> scsi_blk_size ) ) < 0 ) { SCSI_SenseCode ( pdev , lun , HARDWARE_ERROR , UNRECOVERED_READ_ERROR ) ; return -1 ; } ( void ) USBD_LL_Transmit ( pdev , MSCInEpAdd , hmsc -> bot_data , len ) ; hmsc -> scsi_blk_addr += ( len / hmsc -> scsi_blk_size ) ; hmsc -> scsi_blk_len -= ( len / hmsc -> scsi_blk_size ) ; hmsc -> csw . dDataResidue -= len ; if ( hmsc -> scsi_blk_len == 0U ) { hmsc -> bot_state = USBD_BOT_LAST_DATA_IN ; } return 0 ; }
@brief  SCSI_ProcessRead
         Handle Read Process
 @param  lun: Logical unit number
 @retval status
@brief SCSI_ProcessRead Handle Read Process @param lun : Logical unit number @retval status
/* Get the Endpoints addresses allocated for this class instance */ /* USE_USBD_COMPOSITE */ /* case 6 : Hi = Di */