diff options
Diffstat (limited to 'LUFA')
| -rw-r--r-- | LUFA/Drivers/USB/Class/Common/CCIDClassCommon.h | 20 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/CCIDClassDevice.c | 64 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/CCIDClassDevice.h | 22 | 
3 files changed, 99 insertions, 7 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/CCIDClassCommon.h b/LUFA/Drivers/USB/Class/Common/CCIDClassCommon.h index 6cedcad36..cf8fdbae0 100644 --- a/LUFA/Drivers/USB/Class/Common/CCIDClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/CCIDClassCommon.h @@ -153,6 +153,26 @@  			CCID_DTYPE_Functional                       = 0x21, /**< CCID class specific Interface functional descriptor. */  		}; +		enum CCID_Features_Auto_t +		{ +			CCID_Features_Auto_None 					= 0x0, +			CCID_Features_Auto_ParameterConfiguration	= 0x2, +			CCID_Features_Auto_ICCActivation			= 0x4, +			CCID_Features_Auto_VoltageSelection			= 0x8, + +			CCID_Features_Auto_ICCClockFrequencyChange	= 0x10, +			CCID_Features_Auto_ICCBaudRateChange		= 0x20, +			CCID_Features_Auto_ParameterNegotiation		= 0x40, +			CCID_Features_Auto_PPS						= 0x80, +		}; + +		enum CCID_Features_ExchangeLevel_t +		{ +			CCID_Features_ExchangeLevel_TPDU  				= 0x00010000, +			CCID_Features_ExchangeLevel_ShortAPDU 			= 0x00020000, +			CCID_Features_ExchangeLevel_ShortExtendedAPDU	= 0x00040000 +		}; +  	/* Type Defines: */  		typedef struct  		{ diff --git a/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.c b/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.c index 0595e0715..450ed9d9c 100644 --- a/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.c @@ -129,7 +129,9 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  {  	Endpoint_SelectEndpoint(CCIDInterfaceInfo->Config.DataOUTEndpoint.Address); -	uint8_t BlockBuffer[0x20]; +	uint8_t RequestBuffer[0x40 - sizeof(USB_CCID_BulkMessage_Header_t)]; +	uint8_t ResponseBuffer[0x40]; +  	CCIDInterfaceInfo->State.Aborted    = false;  	CCIDInterfaceInfo->State.AbortedSeq = -1; @@ -149,7 +151,7 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  			case CCID_PC_to_RDR_IccPowerOn:  			{  				uint8_t AtrLength; -				USB_CCID_RDR_to_PC_DataBlock_t* ResponseATR = (USB_CCID_RDR_to_PC_DataBlock_t*)&BlockBuffer; +				USB_CCID_RDR_to_PC_DataBlock_t* ResponseATR = (USB_CCID_RDR_to_PC_DataBlock_t*)&ResponseBuffer;  				ResponseATR->CCIDHeader.MessageType = CCID_RDR_to_PC_DataBlock;  				ResponseATR->CCIDHeader.Slot        = CCIDHeader.Slot; @@ -186,7 +188,7 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  			case CCID_PC_to_RDR_IccPowerOff:  			{ -				USB_CCID_RDR_to_PC_SlotStatus_t* ResponsePowerOff = (USB_CCID_RDR_to_PC_SlotStatus_t*)&BlockBuffer; +				USB_CCID_RDR_to_PC_SlotStatus_t* ResponsePowerOff = (USB_CCID_RDR_to_PC_SlotStatus_t*)&ResponseBuffer;  				ResponsePowerOff->CCIDHeader.MessageType = CCID_RDR_to_PC_SlotStatus;  				ResponsePowerOff->CCIDHeader.Length      = 0;  				ResponsePowerOff->CCIDHeader.Slot        = CCIDHeader.Slot; @@ -209,7 +211,7 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  			case CCID_PC_to_RDR_GetSlotStatus:  			{ -				USB_CCID_RDR_to_PC_SlotStatus_t* ResponseSlotStatus = (USB_CCID_RDR_to_PC_SlotStatus_t*)&BlockBuffer; +				USB_CCID_RDR_to_PC_SlotStatus_t* ResponseSlotStatus = (USB_CCID_RDR_to_PC_SlotStatus_t*)&ResponseBuffer;  				ResponseSlotStatus->CCIDHeader.MessageType = CCID_RDR_to_PC_SlotStatus;  				ResponseSlotStatus->CCIDHeader.Length      = 0;  				ResponseSlotStatus->CCIDHeader.Slot        = CCIDHeader.Slot; @@ -230,9 +232,57 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  				break;  			} +			case CCID_PC_to_RDR_XfrBlock: +			{ +				uint8_t  Bwi            = Endpoint_Read_8(); +				uint16_t LevelParameter = Endpoint_Read_16_LE(); +				uint8_t  ReceivedBuffer[0x4]; + +				(void)Bwi; +				(void)LevelParameter; + +				Endpoint_Read_Stream_LE(ReceivedBuffer, sizeof(ReceivedBuffer), NULL); + +				uint8_t	ResponseDataLength      = 0; + +				USB_CCID_RDR_to_PC_DataBlock_t* ResponseBlock = (USB_CCID_RDR_to_PC_DataBlock_t*)&ResponseBuffer; +				ResponseBlock->CCIDHeader.MessageType = CCID_RDR_to_PC_DataBlock; +				ResponseBlock->CCIDHeader.Slot        = CCIDHeader.Slot; +				ResponseBlock->CCIDHeader.Seq         = CCIDHeader.Seq; + +				ResponseBlock->ChainParam = 0; + +				Status = CALLBACK_CCID_XfrBlock(CCIDInterfaceInfo, CCIDHeader.Slot, RequestBuffer, CCIDHeader.Length, (uint8_t*) &ResponseBlock->Data, &ResponseDataLength, &Error); + +				if (CCID_CheckStatusNoError(Status) && !CCIDInterfaceInfo->State.Aborted) +				{ +					ResponseBlock->CCIDHeader.Length = ResponseDataLength; +				} +				else if(CCIDInterfaceInfo->State.Aborted) +				{ +					Status = CCID_COMMANDSTATUS_FAILED | CCID_ICCSTATUS_PRESENTANDACTIVE; +					Error  = CCID_ERROR_CMD_ABORTED; +					ResponseDataLength = 0; +				} +				else +				{ +					ResponseDataLength = 0; +				} + +				ResponseBlock->Status = Status; +				ResponseBlock->Error  = Error; + +				Endpoint_ClearOUT(); + +				Endpoint_SelectEndpoint(CCIDInterfaceInfo->Config.DataINEndpoint.Address); +				Endpoint_Write_Stream_LE(ResponseBlock, sizeof(USB_CCID_RDR_to_PC_DataBlock_t) + ResponseDataLength, NULL); +				Endpoint_ClearIN(); +				break; +			} +  			case CCID_PC_to_RDR_Abort:  			{ -				USB_CCID_RDR_to_PC_SlotStatus_t* ResponseAbort = (USB_CCID_RDR_to_PC_SlotStatus_t*)&BlockBuffer; +				USB_CCID_RDR_to_PC_SlotStatus_t* ResponseAbort = (USB_CCID_RDR_to_PC_SlotStatus_t*)&ResponseBuffer;  				ResponseAbort->CCIDHeader.MessageType = CCID_RDR_to_PC_SlotStatus;  				ResponseAbort->CCIDHeader.Length      = 0;  				ResponseAbort->CCIDHeader.Slot        = CCIDHeader.Slot; @@ -255,10 +305,10 @@ void CCID_Device_USBTask(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo)  			default:  			{ -				memset(BlockBuffer, 0x00, sizeof(BlockBuffer)); +				memset(ResponseBuffer, 0x00, sizeof(ResponseBuffer));  				Endpoint_SelectEndpoint(CCIDInterfaceInfo->Config.DataINEndpoint.Address); -				Endpoint_Write_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL); +				Endpoint_Write_Stream_LE(ResponseBuffer, sizeof(ResponseBuffer), NULL);  				Endpoint_ClearIN();  			}  		} diff --git a/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.h b/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.h index 245e12665..d101723c3 100644 --- a/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/CCIDClassDevice.h @@ -155,6 +155,28 @@  			                                    uint8_t slot,  			                                    uint8_t* const error) ATTR_NON_NULL_PTR_ARG(1); +			/** CCID class driver callback for PC_TO_RDR_XfrBlock CCID message +			 *  Send a block of bytes from the host to a slot in the device  +			 *  and also received a block of bytes as a response +			 *  +			 *  \param[in,out] CCIDInterfaceInfo	Pointer to a structure containing a CCID Class configuration and state. +			 *  \param[in]     slot 				The slot ID from which we want to retrieve the status. +			 *  \param[in]     receivedBuffer 		Pointer to an array holding the received block of bytes +			 *  \param[in]     receivedBufferSize 	The size of the received block of bytes +			 *  \param[out]    sendBuffer 			Pointer to a buffer which will hold the bytes being sent back to the host +			 *  \param[out]     sentBufferSize 		The size of the block of bytes being sent back to the host +			 *  \param[out]    error				The result of the operation, or error. +			 * +			 *  \return	The command result code. +			 */ +			uint8_t CALLBACK_CCID_XfrBlock(USB_ClassInfo_CCID_Device_t* const CCIDInterfaceInfo, +										   uint8_t slot,  +										   uint8_t* const receivedBuffer,  +										   uint8_t receivedBufferSize,  +										   uint8_t* const sendBuffer,  +										   uint8_t* const sentBufferSize,  +										   uint8_t* const error); +  			/** CCID class driver callback for CCID_PC_to_RDR_Abort CCID message  			 *  Aborts a BULK out message previously sent to a slot  			 *  | 
