sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c
/**
  * @brief  MSC_BOT_CBW_Decode
  *         Decode the CBW command and set the BOT state machine accordingly
  * @param  pdev: device instance
  * @retval None
  */
@brief  MSC_BOT_CBW_Decode
Decode the CBW command and set the BOT state machine accordingly
@param  pdev: device instance
@retval None
@brief MSC_BOT_CBW_Decode Decode the CBW command and set the BOT state machine accordingly @param pdev : device instance @retval None
static void  MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
{
  USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
#ifdef USE_USBD_COMPOSITE
  MSCInEpAdd  = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
  MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
#endif 
  if (hmsc == NULL)
  {
    return;
  }
  hmsc->csw.dTag = hmsc->cbw.dTag;
  hmsc->csw.dDataResidue = hmsc->cbw.dDataLength;
  if ((USBD_LL_GetRxDataSize(pdev, MSCOutEpAdd) != USBD_BOT_CBW_LENGTH) ||
      (hmsc->cbw.dSignature != USBD_BOT_CBW_SIGNATURE) ||
      (hmsc->cbw.bLUN > 1U) || (hmsc->cbw.bCBLength < 1U) ||
      (hmsc->cbw.bCBLength > 16U))
  {
    SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
    hmsc->bot_status = USBD_BOT_STATUS_ERROR;
    MSC_BOT_Abort(pdev);
  }
  else
  {
    if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0)
    {
      if (hmsc->bot_state == USBD_BOT_NO_DATA)
      {
        MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
      }
      else
      {
        MSC_BOT_Abort(pdev);
      }
    }
    else if ((hmsc->bot_state != USBD_BOT_DATA_IN) &&
             (hmsc->bot_state != USBD_BOT_DATA_OUT) &&
             (hmsc->bot_state != USBD_BOT_LAST_DATA_IN))
    {
      if (hmsc->bot_data_length > 0U)
      {
        MSC_BOT_SendData(pdev, hmsc->bot_data, hmsc->bot_data_length);
      }
      else if (hmsc->bot_data_length == 0U)
      {
        MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
      }
      else
      {
        MSC_BOT_Abort(pdev);
      }
    }
    else
    {
      return;
    }
  }
}
static void MSC_BOT_CBW_Decode ( USBD_HandleTypeDef * pdev ) { USBD_MSC_BOT_HandleTypeDef * hmsc = ( USBD_MSC_BOT_HandleTypeDef * ) pdev -> pClassDataCmsit [ pdev -> classId ] ; #ifdef USE_USBD_COMPOSITE MSCInEpAdd = USBD_CoreGetEPAdd ( pdev , USBD_EP_IN , USBD_EP_TYPE_BULK ) ; MSCOutEpAdd = USBD_CoreGetEPAdd ( pdev , USBD_EP_OUT , USBD_EP_TYPE_BULK ) ; #endif if ( hmsc == NULL ) { return ; } hmsc -> csw . dTag = hmsc -> cbw . dTag ; hmsc -> csw . dDataResidue = hmsc -> cbw . dDataLength ; if ( ( USBD_LL_GetRxDataSize ( pdev , MSCOutEpAdd ) != USBD_BOT_CBW_LENGTH ) || ( hmsc -> cbw . dSignature != USBD_BOT_CBW_SIGNATURE ) || ( hmsc -> cbw . bLUN > 1U ) || ( hmsc -> cbw . bCBLength < 1U ) || ( hmsc -> cbw . bCBLength > 16U ) ) { SCSI_SenseCode ( pdev , hmsc -> cbw . bLUN , ILLEGAL_REQUEST , INVALID_CDB ) ; hmsc -> bot_status = USBD_BOT_STATUS_ERROR ; MSC_BOT_Abort ( pdev ) ; } else { if ( SCSI_ProcessCmd ( pdev , hmsc -> cbw . bLUN , & hmsc -> cbw . CB [ 0 ] ) < 0 ) { if ( hmsc -> bot_state == USBD_BOT_NO_DATA ) { MSC_BOT_SendCSW ( pdev , USBD_CSW_CMD_FAILED ) ; } else { MSC_BOT_Abort ( pdev ) ; } } else if ( ( hmsc -> bot_state != USBD_BOT_DATA_IN ) && ( hmsc -> bot_state != USBD_BOT_DATA_OUT ) && ( hmsc -> bot_state != USBD_BOT_LAST_DATA_IN ) ) { if ( hmsc -> bot_data_length > 0U ) { MSC_BOT_SendData ( pdev , hmsc -> bot_data , hmsc -> bot_data_length ) ; } else if ( hmsc -> bot_data_length == 0U ) { MSC_BOT_SendCSW ( pdev , USBD_CSW_CMD_PASSED ) ; } else { MSC_BOT_Abort ( pdev ) ; } } else { return ; } } }
@brief  MSC_BOT_CBW_Decode
         Decode the CBW command and set the BOT state machine accordingly
 @param  pdev: device instance
 @retval None
@brief MSC_BOT_CBW_Decode Decode the CBW command and set the BOT state machine accordingly @param pdev : device instance @retval None
/* Get the Endpoints addresses allocated for this class instance */ /* USE_USBD_COMPOSITE */ /* Burst xfer handled internally */