sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c
/**
  * @brief  SCSI_RequestSense
  *         Process Request Sense command
  * @param  lun: Logical unit number
  * @param  params: Command parameters
  * @retval status
  */
@brief  SCSI_RequestSense
Process Request Sense command
@param  lun: Logical unit number
@param  params: Command parameters
@retval status
@brief SCSI_RequestSense Process Request Sense command @param lun : Logical unit number @param params : Command parameters @retval status
static int8_t SCSI_RequestSense(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
{
  UNUSED(lun);
  uint8_t i;
  USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
  if (hmsc == NULL)
  {
    return -1;
  }
  if (hmsc->cbw.dDataLength == 0U)
  {
    SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
    return -1;
  }
  for (i = 0U; i < REQUEST_SENSE_DATA_LEN; i++)
  {
    hmsc->bot_data[i] = 0U;
  }
  hmsc->bot_data[0] = 0x70U;
  hmsc->bot_data[7] = REQUEST_SENSE_DATA_LEN - 6U;
  if ((hmsc->scsi_sense_head != hmsc->scsi_sense_tail))
  {
    hmsc->bot_data[2] = (uint8_t)hmsc->scsi_sense[hmsc->scsi_sense_head].Skey;
    hmsc->bot_data[12] = (uint8_t)hmsc->scsi_sense[hmsc->scsi_sense_head].w.b.ASC;
    hmsc->bot_data[13] = (uint8_t)hmsc->scsi_sense[hmsc->scsi_sense_head].w.b.ASCQ;
    hmsc->scsi_sense_head++;
    if (hmsc->scsi_sense_head == SENSE_LIST_DEEPTH)
    {
      hmsc->scsi_sense_head = 0U;
    }
  }
  hmsc->bot_data_length = REQUEST_SENSE_DATA_LEN;
  if (params[4] <= REQUEST_SENSE_DATA_LEN)
  {
    hmsc->bot_data_length = params[4];
  }
  return 0;
}
static int8_t SCSI_RequestSense ( USBD_HandleTypeDef * pdev , uint8_t lun , uint8_t * params ) { UNUSED ( lun ) ; uint8_t i ; USBD_MSC_BOT_HandleTypeDef * hmsc = ( USBD_MSC_BOT_HandleTypeDef * ) pdev -> pClassDataCmsit [ pdev -> classId ] ; if ( hmsc == NULL ) { return -1 ; } if ( hmsc -> cbw . dDataLength == 0U ) { SCSI_SenseCode ( pdev , hmsc -> cbw . bLUN , ILLEGAL_REQUEST , INVALID_CDB ) ; return -1 ; } for ( i = 0U ; i < REQUEST_SENSE_DATA_LEN ; i ++ ) { hmsc -> bot_data [ i ] = 0U ; } hmsc -> bot_data [ 0 ] = 0x70U ; hmsc -> bot_data [ 7 ] = REQUEST_SENSE_DATA_LEN - 6U ; if ( ( hmsc -> scsi_sense_head != hmsc -> scsi_sense_tail ) ) { hmsc -> bot_data [ 2 ] = ( uint8_t ) hmsc -> scsi_sense [ hmsc -> scsi_sense_head ] . Skey ; hmsc -> bot_data [ 12 ] = ( uint8_t ) hmsc -> scsi_sense [ hmsc -> scsi_sense_head ] . w . b . ASC ; hmsc -> bot_data [ 13 ] = ( uint8_t ) hmsc -> scsi_sense [ hmsc -> scsi_sense_head ] . w . b . ASCQ ; hmsc -> scsi_sense_head ++ ; if ( hmsc -> scsi_sense_head == SENSE_LIST_DEEPTH ) { hmsc -> scsi_sense_head = 0U ; } } hmsc -> bot_data_length = REQUEST_SENSE_DATA_LEN ; if ( params [ 4 ] <= REQUEST_SENSE_DATA_LEN ) { hmsc -> bot_data_length = params [ 4 ] ; } return 0 ; }
@brief  SCSI_RequestSense
         Process Request Sense command
 @param  lun: Logical unit number
 @param  params: Command parameters
 @retval status
@brief SCSI_RequestSense Process Request Sense command @param lun : Logical unit number @param params : Command parameters @retval status