sources/common/libs/STM32Cube_F4/Middlewares/ST/STM32_USB_Device_Library/Class/CCID/Src/usbd_ccid_cmd.c
/**
  * @brief  PC_TO_RDR_Secure
  *         Execute the Secure Command from the host.
  *         Response to this command message is the RDR_to_PC_DataBlock
  * @param  pdev: device instance
  * @retval status of the command execution
  */
@brief  PC_TO_RDR_Secure
Execute the Secure Command from the host.
Response to this command message is the RDR_to_PC_DataBlock
@param  pdev: device instance
@retval status of the command execution
@brief PC_TO_RDR_Secure Execute the Secure Command from the host . Response to this command message is the RDR_to_PC_DataBlock @param pdev : device instance @retval status of the command execution
uint8_t  PC_TO_RDR_Secure(USBD_HandleTypeDef *pdev)
{
  USBD_CCID_HandleTypeDef  *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
  uint8_t error;
  uint8_t bBWI;
  uint16_t wLevelParameter;
  uint32_t responseLen;
  hccid->UsbBlkInData.dwLength = 0;
  error = CCID_CheckCommandParams(pdev, CHK_PARAM_SLOT | CHK_PARAM_CARD_PRESENT |
                                  CHK_PARAM_ABORT);
  if (error != 0U)
  {
    return error;
  }
  bBWI = hccid->UsbBlkOutData.bSpecific_0;
  wLevelParameter = (hccid->UsbBlkOutData.bSpecific_1 + ((uint16_t)hccid->UsbBlkOutData.bSpecific_2 << 8));
  if ((EXCHANGE_LEVEL_FEATURE == TPDU_EXCHANGE) ||
      (EXCHANGE_LEVEL_FEATURE == SHORT_APDU_EXCHANGE))
  {
    if (wLevelParameter != 0U)
    {
      CCID_UpdateCommandStatus(pdev, (BM_COMMAND_STATUS_FAILED), (BM_ICC_PRESENT_ACTIVE));
      error = SLOTERROR_BAD_LEVELPARAMETER;
      return error;
    }
  }
  error = SC_Itf_Secure(hccid->UsbBlkOutData.dwLength, bBWI, wLevelParameter,
                        &(hccid->UsbBlkOutData.abData[0]), &responseLen);
  hccid->UsbBlkInData.dwLength = responseLen;
  if (error != SLOT_NO_ERROR)
  {
    CCID_UpdateCommandStatus(pdev, (BM_COMMAND_STATUS_FAILED), (BM_ICC_PRESENT_ACTIVE));
  }
  else
  {
    CCID_UpdateCommandStatus(pdev, (BM_COMMAND_STATUS_NO_ERROR), (BM_ICC_PRESENT_ACTIVE));
  }
  return error;
}
uint8_t PC_TO_RDR_Secure ( USBD_HandleTypeDef * pdev ) { USBD_CCID_HandleTypeDef * hccid = ( USBD_CCID_HandleTypeDef * ) pdev -> pClassDataCmsit [ pdev -> classId ] ; uint8_t error ; uint8_t bBWI ; uint16_t wLevelParameter ; uint32_t responseLen ; hccid -> UsbBlkInData . dwLength = 0 ; error = CCID_CheckCommandParams ( pdev , CHK_PARAM_SLOT | CHK_PARAM_CARD_PRESENT | CHK_PARAM_ABORT ) ; if ( error != 0U ) { return error ; } bBWI = hccid -> UsbBlkOutData . bSpecific_0 ; wLevelParameter = ( hccid -> UsbBlkOutData . bSpecific_1 + ( ( uint16_t ) hccid -> UsbBlkOutData . bSpecific_2 << 8 ) ) ; if ( ( EXCHANGE_LEVEL_FEATURE == TPDU_EXCHANGE ) || ( EXCHANGE_LEVEL_FEATURE == SHORT_APDU_EXCHANGE ) ) { if ( wLevelParameter != 0U ) { CCID_UpdateCommandStatus ( pdev , ( BM_COMMAND_STATUS_FAILED ) , ( BM_ICC_PRESENT_ACTIVE ) ) ; error = SLOTERROR_BAD_LEVELPARAMETER ; return error ; } } error = SC_Itf_Secure ( hccid -> UsbBlkOutData . dwLength , bBWI , wLevelParameter , & ( hccid -> UsbBlkOutData . abData [ 0 ] ) , & responseLen ) ; hccid -> UsbBlkInData . dwLength = responseLen ; if ( error != SLOT_NO_ERROR ) { CCID_UpdateCommandStatus ( pdev , ( BM_COMMAND_STATUS_FAILED ) , ( BM_ICC_PRESENT_ACTIVE ) ) ; } else { CCID_UpdateCommandStatus ( pdev , ( BM_COMMAND_STATUS_NO_ERROR ) , ( BM_ICC_PRESENT_ACTIVE ) ) ; } return error ; }
@brief  PC_TO_RDR_Secure
         Execute the Secure Command from the host.
@brief PC_TO_RDR_Secure Execute the Secure Command from the host .
/* TPDU level & short APDU level, wLevelParameter is RFU, = 0000h */