sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c
/**
  * @brief  SCSI_ProcessWrite
  *         Handle Write Process
  * @param  lun: Logical unit number
  * @retval status
  */
@brief  SCSI_ProcessWrite
Handle Write Process
@param  lun: Logical unit number
@retval status
@brief SCSI_ProcessWrite Handle Write Process @param lun : Logical unit number @retval status
static int8_t SCSI_ProcessWrite(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
  MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
#endif 
  len = MIN(len, MSC_MEDIA_PACKET);
  if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Write(lun, hmsc->bot_data,
                                                                     hmsc->scsi_blk_addr,
                                                                     (len / hmsc->scsi_blk_size)) < 0)
  {
    SCSI_SenseCode(pdev, lun, HARDWARE_ERROR, WRITE_FAULT);
    return -1;
  }
  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)
  {
    MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
  }
  else
  {
    len = MIN((hmsc->scsi_blk_len * hmsc->scsi_blk_size), MSC_MEDIA_PACKET);
    (void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, hmsc->bot_data, len);
  }
  return 0;
}
static int8_t SCSI_ProcessWrite ( 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 MSCOutEpAdd = USBD_CoreGetEPAdd ( pdev , USBD_EP_OUT , USBD_EP_TYPE_BULK ) ; #endif len = MIN ( len , MSC_MEDIA_PACKET ) ; if ( ( ( USBD_StorageTypeDef * ) pdev -> pUserData [ pdev -> classId ] ) -> Write ( lun , hmsc -> bot_data , hmsc -> scsi_blk_addr , ( len / hmsc -> scsi_blk_size ) ) < 0 ) { SCSI_SenseCode ( pdev , lun , HARDWARE_ERROR , WRITE_FAULT ) ; return -1 ; } 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 ) { MSC_BOT_SendCSW ( pdev , USBD_CSW_CMD_PASSED ) ; } else { len = MIN ( ( hmsc -> scsi_blk_len * hmsc -> scsi_blk_size ) , MSC_MEDIA_PACKET ) ; ( void ) USBD_LL_PrepareReceive ( pdev , MSCOutEpAdd , hmsc -> bot_data , len ) ; } return 0 ; }
@brief  SCSI_ProcessWrite
         Handle Write Process
 @param  lun: Logical unit number
 @retval status
@brief SCSI_ProcessWrite Handle Write Process @param lun : Logical unit number @retval status
/* Get the Endpoints addresses allocated for this class instance */ /* USE_USBD_COMPOSITE */ /* case 12 : Ho = Do */ /* Prepare EP to Receive next packet */