replace leading spaces with tabs

Change-Id: I86783eba0827b58303b10310e9f6b9625e1a27f1
diff --git a/firmware/libcommon/include/assert.h b/firmware/libcommon/include/assert.h
index a52ffa9..22bb101 100644
--- a/firmware/libcommon/include/assert.h
+++ b/firmware/libcommon/include/assert.h
@@ -65,41 +65,41 @@
 //         Definitions
 //------------------------------------------------------------------------------
 #if defined(NOASSERT)
-    #define ASSERT(...)
-    #define SANITY_CHECK(...)
+	#define ASSERT(...)
+	#define SANITY_CHECK(...)
 #else
 
-    #if (TRACE_LEVEL == 0)
-        /// Checks that the given condition is true, 
-        /// otherwise stops the program execution.
-        /// \param condition  Condition to verify.
-        #define ASSERT(condition)  { \
-            if (!(condition)) { \
-                while (1); \
-            } \
-        }
+	#if (TRACE_LEVEL == 0)
+		/// Checks that the given condition is true, 
+		/// otherwise stops the program execution.
+		/// \param condition  Condition to verify.
+		#define ASSERT(condition)  { \
+			if (!(condition)) { \
+				while (1); \
+			} \
+		}
 
-        /// Performs the same duty as the ASSERT() macro
-        /// \param condition  Condition to verify.
-        #define SANITY_CHECK(condition) ASSERT(condition, ...)
+		/// Performs the same duty as the ASSERT() macro
+		/// \param condition  Condition to verify.
+		#define SANITY_CHECK(condition) ASSERT(condition, ...)
 
-    #else
-        /// Checks that the given condition is true, otherwise displays an error
-        /// message and stops the program execution.
-        /// \param condition  Condition to verify.
-        #define ASSERT(condition)  { \
-            if (!(condition)) { \
-                printf("-F- ASSERT: %s %s:%d\n\r", #condition, __BASE_FILE__, __LINE__); \
-                while (1); \
-            } \
-        }
-        #define SANITY_ERROR            "Sanity check failed at %s:%d\n\r"
-    
-        /// Performs the same duty as the ASSERT() macro, except a default error
-        /// message is output if the condition is false.
-        /// \param condition  Condition to verify.
-        #define SANITY_CHECK(condition) ASSERT(condition, SANITY_ERROR, __FILE__, __LINE__)
-    #endif
+	#else
+		/// Checks that the given condition is true, otherwise displays an error
+		/// message and stops the program execution.
+		/// \param condition  Condition to verify.
+		#define ASSERT(condition)  { \
+			if (!(condition)) { \
+				printf("-F- ASSERT: %s %s:%d\n\r", #condition, __BASE_FILE__, __LINE__); \
+				while (1); \
+			} \
+		}
+		#define SANITY_ERROR            "Sanity check failed at %s:%d\n\r"
+	
+		/// Performs the same duty as the ASSERT() macro, except a default error
+		/// message is output if the condition is false.
+		/// \param condition  Condition to verify.
+		#define SANITY_CHECK(condition) ASSERT(condition, SANITY_ERROR, __FILE__, __LINE__)
+	#endif
 #endif
 
 
diff --git a/firmware/libcommon/include/cciddriver.h b/firmware/libcommon/include/cciddriver.h
index ee5e028..f9be027 100644
--- a/firmware/libcommon/include/cciddriver.h
+++ b/firmware/libcommon/include/cciddriver.h
@@ -145,129 +145,129 @@
 /// 6.1.11.2 PIN Verification Data Structure
 typedef struct
 {
-    /// Number of seconds.
-    unsigned char bTimerOut;
-    /// Several parameters for the PIN format options
-    unsigned char bmFormatString;
-    /// Define the length of the PIN to present in the APDU command
-    unsigned char bmPINBlockString;
-    /// Allows the length PIN insertion in the APDU command
-    unsigned char bmPINLengthFormat;
-    /// Minimum PIN size in digit and Maximum PIN size in digit
-    unsigned char wPINMaxExtraDigit;
-    /// The value is a bit wise OR operation.
-    unsigned char bEntryValidationCondition;
-    /// Number of messages to display for the PIN modify command
-    unsigned char bNumberMessage;
-    /// Language used to display the messages.
-    unsigned char wLangId;
-    /// Message index in the Reader message table
-    unsigned char bMsgIndex;
-    /// T=1 I-block prologue field to use
-    unsigned char bTeoPrologue[3];
-    /// APDU to send to the ICC
-    unsigned char abPINApdu[255];
+	/// Number of seconds.
+	unsigned char bTimerOut;
+	/// Several parameters for the PIN format options
+	unsigned char bmFormatString;
+	/// Define the length of the PIN to present in the APDU command
+	unsigned char bmPINBlockString;
+	/// Allows the length PIN insertion in the APDU command
+	unsigned char bmPINLengthFormat;
+	/// Minimum PIN size in digit and Maximum PIN size in digit
+	unsigned char wPINMaxExtraDigit;
+	/// The value is a bit wise OR operation.
+	unsigned char bEntryValidationCondition;
+	/// Number of messages to display for the PIN modify command
+	unsigned char bNumberMessage;
+	/// Language used to display the messages.
+	unsigned char wLangId;
+	/// Message index in the Reader message table
+	unsigned char bMsgIndex;
+	/// T=1 I-block prologue field to use
+	unsigned char bTeoPrologue[3];
+	/// APDU to send to the ICC
+	unsigned char abPINApdu[255];
 }__attribute__ ((packed)) S_ccid_PIN_Verification;
 
 
 /// 6.1.11.7 PIN Modification Data Structure
 typedef struct
 {
-    /// Number of seconds. If 00h then CCID default value is used.
-    unsigned char bTimeOut;
-    /// Several parameters for the PIN format options (defined in § 6.1.11.4)
-    unsigned char bmFormatString4;
-    /// Define the length of the PIN to present in the APDU command
-    unsigned char bmPINBlockString;
-    /// Allows the length PIN insertion in the APDU command (defined in § 6.1.11.6)
-    unsigned char bmPinLengthFormat;
-    /// Insertion position offset in byte for the current PIN
-    unsigned char bInsertionOffsetOld;
-    /// Insertion position offset in byte for the new PIN
-    unsigned char bInsertionOffsetNew;
-    /// XXYYh
-    /// XX: Minimum PIN size in digit
-    /// YY: Maximum PIN size in digit
-    unsigned char wPINMaxExtraDigit;
-    /// 00h,01h,02h,03h
-    /// Indicates if a confirmation is requested before acceptance of a new PIN (meaning that the user has to enter this new PIN twice before it is accepted)
-    /// Indicates if the current PIN must be entered and set in the same APDU field of not.
-    unsigned char bConfirmPIN;
-    /// The value is a bit wise OR operation.
-    /// 01h Max size reached
-    /// 02h Validation key pressed
-    /// 04h Timeout occurred
-    unsigned char bEntryValidationCondition;
-    /// 00h,01h,02h,03h,or FFh
-    /// Number of messages to display for the PIN modify command.
-    unsigned char bNumberMessage;
-    /// Language used to display the messages. The 16 bit
-    unsigned char wLangId;
-    /// Message index in the Reader message table (should be 00h or 01h).
-    unsigned char bMsgIndex1;
-    /// Message index in the Reader message table (should be 01h or 02h).
-    unsigned char bMsgIndex2;
-    /// Message index in the Reader message table (should be 02h).
-    unsigned char bMsgIndex3;
-    /// T=1 I-block prologue field to use. Significant only if protocol in use is T=1.
-    unsigned char bTeoPrologue[3];
-    /// Byte array APDU to send to the ICC
-    unsigned char abPINApdu[255];
+	/// Number of seconds. If 00h then CCID default value is used.
+	unsigned char bTimeOut;
+	/// Several parameters for the PIN format options (defined in § 6.1.11.4)
+	unsigned char bmFormatString4;
+	/// Define the length of the PIN to present in the APDU command
+	unsigned char bmPINBlockString;
+	/// Allows the length PIN insertion in the APDU command (defined in § 6.1.11.6)
+	unsigned char bmPinLengthFormat;
+	/// Insertion position offset in byte for the current PIN
+	unsigned char bInsertionOffsetOld;
+	/// Insertion position offset in byte for the new PIN
+	unsigned char bInsertionOffsetNew;
+	/// XXYYh
+	/// XX: Minimum PIN size in digit
+	/// YY: Maximum PIN size in digit
+	unsigned char wPINMaxExtraDigit;
+	/// 00h,01h,02h,03h
+	/// Indicates if a confirmation is requested before acceptance of a new PIN (meaning that the user has to enter this new PIN twice before it is accepted)
+	/// Indicates if the current PIN must be entered and set in the same APDU field of not.
+	unsigned char bConfirmPIN;
+	/// The value is a bit wise OR operation.
+	/// 01h Max size reached
+	/// 02h Validation key pressed
+	/// 04h Timeout occurred
+	unsigned char bEntryValidationCondition;
+	/// 00h,01h,02h,03h,or FFh
+	/// Number of messages to display for the PIN modify command.
+	unsigned char bNumberMessage;
+	/// Language used to display the messages. The 16 bit
+	unsigned char wLangId;
+	/// Message index in the Reader message table (should be 00h or 01h).
+	unsigned char bMsgIndex1;
+	/// Message index in the Reader message table (should be 01h or 02h).
+	unsigned char bMsgIndex2;
+	/// Message index in the Reader message table (should be 02h).
+	unsigned char bMsgIndex3;
+	/// T=1 I-block prologue field to use. Significant only if protocol in use is T=1.
+	unsigned char bTeoPrologue[3];
+	/// Byte array APDU to send to the ICC
+	unsigned char abPINApdu[255];
 }__attribute__ ((packed)) S_ccid_PIN_Modification;
 
 /// Protocol Data Structure for Protocol T=0 (bProtocolNum=0, dwLength=00000005h)
 typedef struct
 {
-    /// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a 
-    /// clock rate conversion factor
-    /// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a 
-    /// baud rate conversion factor
-    unsigned char bmFindexDindex;
-    /// For T=0 ,B0 – 0b, B7-2 – 000000b
-    /// B1 – Convention used (b1=0 for direct, b1=1 for inverse)
-    unsigned char bmTCCKST0;         // 0 to 2
-    /// Extra Guardtime between two characters. Add 0 to 254 etu to the normal 
-    /// guardtime of 12etu. FFh is the same as 00h.
-    unsigned char bGuardTimeT0;      // 0 to FF
-    /// WI for T=0 used to define WWT
-    unsigned char bWaitingIntegerT0; // 0 to FF
-    /// ICC Clock Stop Support
-    /// 00 = Stopping the Clock is not allowed
-    /// 01 = Stop with Clock signal Low
-    /// 02 = Stop with Clock signal High
-    /// 03 = Stop with Clock either High or Low
-    unsigned char bClockStop;        // 0 to 3
+	/// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a 
+	/// clock rate conversion factor
+	/// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a 
+	/// baud rate conversion factor
+	unsigned char bmFindexDindex;
+	/// For T=0 ,B0 – 0b, B7-2 – 000000b
+	/// B1 – Convention used (b1=0 for direct, b1=1 for inverse)
+	unsigned char bmTCCKST0;         // 0 to 2
+	/// Extra Guardtime between two characters. Add 0 to 254 etu to the normal 
+	/// guardtime of 12etu. FFh is the same as 00h.
+	unsigned char bGuardTimeT0;      // 0 to FF
+	/// WI for T=0 used to define WWT
+	unsigned char bWaitingIntegerT0; // 0 to FF
+	/// ICC Clock Stop Support
+	/// 00 = Stopping the Clock is not allowed
+	/// 01 = Stop with Clock signal Low
+	/// 02 = Stop with Clock signal High
+	/// 03 = Stop with Clock either High or Low
+	unsigned char bClockStop;        // 0 to 3
 } __attribute__ ((packed)) S_ccid_protocol_t0;
 
 
 /// Protocol Data Structure for Protocol T=1 (bProtocolNum=1, dwLength=00000007h)
 typedef struct
 {
-    /// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a 
-    /// clock rate conversion factor
-    /// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a 
-    /// baud rate conversion factor
-    unsigned char bmFindexDindex;
-    /// For T=1, B7-2 – 000100b
-    /// B0 – Checksum type (b0=0 for LRC, b0=1 for CRC
-    /// B1 – Convention used (b1=0 for direct, b1=1 for inverse)
-    unsigned char bmTCCKST1;           // 10h, 11h, 12h, 13h
-    /// Extra Guardtime (0 to 254 etu between two characters). 
-    /// If value is FFh, then guardtime is reduced by 1.
-    unsigned char bGuardTimeT1;        // 0 to FF
-    /// B7-4 = BWI
-    /// B3-0 = CWI
-    unsigned char bmWaitingIntegersT1; // 0 to 9
-    /// ICC Clock Stop Support
-    /// 00 = Stopping the Clock is not allowed
-    /// 01 = Stop with Clock signal Low
-    /// 02 = Stop with Clock signal High
-    /// 03 = Stop with Clock either High or Low
-    unsigned char bClockStop;          // 0 to 3
-    /// Size of negotiated IFSC
-    unsigned char bIFSC;               // 0 to FE
-    /// Nad value used by CCID
-    unsigned char bNadValue;           // 0 to FF
+	/// B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a 
+	/// clock rate conversion factor
+	/// B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a 
+	/// baud rate conversion factor
+	unsigned char bmFindexDindex;
+	/// For T=1, B7-2 – 000100b
+	/// B0 – Checksum type (b0=0 for LRC, b0=1 for CRC
+	/// B1 – Convention used (b1=0 for direct, b1=1 for inverse)
+	unsigned char bmTCCKST1;           // 10h, 11h, 12h, 13h
+	/// Extra Guardtime (0 to 254 etu between two characters). 
+	/// If value is FFh, then guardtime is reduced by 1.
+	unsigned char bGuardTimeT1;        // 0 to FF
+	/// B7-4 = BWI
+	/// B3-0 = CWI
+	unsigned char bmWaitingIntegersT1; // 0 to 9
+	/// ICC Clock Stop Support
+	/// 00 = Stopping the Clock is not allowed
+	/// 01 = Stop with Clock signal Low
+	/// 02 = Stop with Clock signal High
+	/// 03 = Stop with Clock either High or Low
+	unsigned char bClockStop;          // 0 to 3
+	/// Size of negotiated IFSC
+	unsigned char bIFSC;               // 0 to FE
+	/// Nad value used by CCID
+	unsigned char bNadValue;           // 0 to FF
 } __attribute__ ((packed)) S_ccid_protocol_t1;
 
 
@@ -357,8 +357,8 @@
 //------------------------------------------------------------------------------
 
 extern unsigned char RDRtoPCHardwareError( unsigned char bSlot, 
-                                           unsigned char bSeq, 
-                                           unsigned char bHardwareErrorCode );
+					                       unsigned char bSeq, 
+					                       unsigned char bHardwareErrorCode );
 
 /*
 #if !defined(NOAUTOCALLBACK)
@@ -368,13 +368,13 @@
 extern void CCID_SmartCardRequest( void );
 extern void CCIDDriver_Initialize( void );
 extern unsigned char CCID_Read(void *pBuffer,
-                               unsigned int dLength,
-                               TransferCallback fCallback,
-                               void *pArgument);
+					           unsigned int dLength,
+					           TransferCallback fCallback,
+					           void *pArgument);
 extern unsigned char CCID_Write(void *pBuffer,
-                                unsigned int dLength,
-                                TransferCallback fCallback,
-                                void *pArgument);
+					            unsigned int dLength,
+					            TransferCallback fCallback,
+					            void *pArgument);
 extern unsigned char CCID_Insertion( void );
 extern unsigned char CCID_Removal( void );
 
diff --git a/firmware/libcommon/include/iso7816_4.h b/firmware/libcommon/include/iso7816_4.h
index 7c371b2..e2215c7 100644
--- a/firmware/libcommon/include/iso7816_4.h
+++ b/firmware/libcommon/include/iso7816_4.h
@@ -76,9 +76,9 @@
 
 extern void ISO7816_IccPowerOff(void);
 extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU,
-                                        uint8_t *pMessage,
-                                        uint16_t wLength,
-                                        uint16_t *retlen);
+					                    uint8_t *pMessage,
+					                    uint16_t wLength,
+					                    uint16_t *retlen);
 extern void ISO7816_Escape( void );
 extern void ISO7816_RestartClock(void);
 extern void ISO7816_StopClock( void );
diff --git a/firmware/libcommon/include/simtrace.h b/firmware/libcommon/include/simtrace.h
index 5edea17..0486581 100644
--- a/firmware/libcommon/include/simtrace.h
+++ b/firmware/libcommon/include/simtrace.h
@@ -65,19 +65,19 @@
 /// device using the CCID driver.
 typedef struct {
 
-    /// Configuration descriptor
-    USBConfigurationDescriptor configuration;
-    /// Interface descriptor
-    USBInterfaceDescriptor     interface;
-    /// CCID descriptor
-    CCIDDescriptor             ccid;
-    /// Bulk OUT endpoint descriptor
-    USBEndpointDescriptor      bulkOut;
-    /// Bulk IN endpoint descriptor
-    USBEndpointDescriptor      bulkIn;
-    /// Interrupt OUT endpoint descriptor
-    USBEndpointDescriptor      interruptIn;
-    DFURT_IF_DESCRIPTOR_STRUCT
+	/// Configuration descriptor
+	USBConfigurationDescriptor configuration;
+	/// Interface descriptor
+	USBInterfaceDescriptor     interface;
+	/// CCID descriptor
+	CCIDDescriptor             ccid;
+	/// Bulk OUT endpoint descriptor
+	USBEndpointDescriptor      bulkOut;
+	/// Bulk IN endpoint descriptor
+	USBEndpointDescriptor      bulkIn;
+	/// Interrupt OUT endpoint descriptor
+	USBEndpointDescriptor      interruptIn;
+	DFURT_IF_DESCRIPTOR_STRUCT
 } __attribute__ ((packed)) CCIDDriverConfigurationDescriptors;
 
 extern const USBConfigurationDescriptor *configurationDescriptorsArr[];
diff --git a/firmware/libcommon/source/cciddriver.c b/firmware/libcommon/source/cciddriver.c
index 8cf28ca..1dbdf23 100644
--- a/firmware/libcommon/source/cciddriver.c
+++ b/firmware/libcommon/source/cciddriver.c
@@ -83,24 +83,24 @@
 /// Driver structure for an CCID device
 typedef struct {
 
-    /// CCID message
-    S_ccid_bulk_in_header  sCcidMessage;
-    /// CCID command
-    S_ccid_bulk_out_header sCcidCommand;
-    /// Interrupt message answer
-    unsigned char          BufferINT[4];
-    /// Buffer data of message
-    unsigned char          ProtocolDataStructure[10];
-    /// Protocol used
-    unsigned char          bProtocol;
-    /// SlotStatus
-    /// Bit 0 = Slot 0 current state
-    /// Bit 1 = Slot 0 changed status
-    /// Bit 2 = Slot 1 current state
-    /// Bit 3 = Slot 1 changed status
-    /// Bit 4 = Slot 2 current state
-    /// Bit 5 = Slot 2 changed status
-    unsigned char          SlotStatus;
+	/// CCID message
+	S_ccid_bulk_in_header  sCcidMessage;
+	/// CCID command
+	S_ccid_bulk_out_header sCcidCommand;
+	/// Interrupt message answer
+	unsigned char          BufferINT[4];
+	/// Buffer data of message
+	unsigned char          ProtocolDataStructure[10];
+	/// Protocol used
+	unsigned char          bProtocol;
+	/// SlotStatus
+	/// Bit 0 = Slot 0 current state
+	/// Bit 1 = Slot 0 changed status
+	/// Bit 2 = Slot 1 current state
+	/// Bit 3 = Slot 1 changed status
+	/// Bit 4 = Slot 2 current state
+	/// Bit 5 = Slot 2 changed status
+	unsigned char          SlotStatus;
 
 } CCIDDriver;
 
@@ -121,7 +121,7 @@
 //------------------------------------------------------------------------------
 void CCIDDriver_Initialize( void )
 {
-    configurationDescriptorsFS = (CCIDDriverConfigurationDescriptors *) configurationDescriptorsArr[CFG_NUM_CCID-1];
+	configurationDescriptorsFS = (CCIDDriverConfigurationDescriptors *) configurationDescriptorsArr[CFG_NUM_CCID-1];
 }
 
 //------------------------------------------------------------------------------
@@ -137,25 +137,25 @@
 //------------------------------------------------------------------------------
 static void RDRtoPCSlotStatus( void )
 {
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS;
-    ccidDriver.sCcidMessage.wLength   = 0;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS;
+	ccidDriver.sCcidMessage.wLength   = 0;
 
-    if (ccidDriver.SlotStatus == ICC_INSERTED_EVENT) {
-        ccidDriver.sCcidMessage.bStatus = 0;    /* ICC present and active card */
-    } else if (ccidDriver.SlotStatus == ICC_NOT_PRESENT) {
-        ccidDriver.sCcidMessage.bStatus = 2;    /* No ICC present*/
-    } else{
-        TRACE_ERROR("Strange bStatus");
-        ccidDriver.sCcidMessage.bStatus = 0;
-    }
-    ccidDriver.sCcidMessage.bError    = 0;
-    // 00h Clock running
-    // 01h Clock stopped in state L
-    // 02h Clock stopped in state H
-    // 03h Clock stopped in an unknown state
-    // All other values are Reserved for Future Use.
-    ccidDriver.sCcidMessage.bSpecific = 0;
+	if (ccidDriver.SlotStatus == ICC_INSERTED_EVENT) {
+		ccidDriver.sCcidMessage.bStatus = 0;    /* ICC present and active card */
+	} else if (ccidDriver.SlotStatus == ICC_NOT_PRESENT) {
+		ccidDriver.sCcidMessage.bStatus = 2;    /* No ICC present*/
+	} else{
+		TRACE_ERROR("Strange bStatus");
+		ccidDriver.sCcidMessage.bStatus = 0;
+	}
+	ccidDriver.sCcidMessage.bError    = 0;
+	// 00h Clock running
+	// 01h Clock stopped in state L
+	// 02h Clock stopped in state H
+	// 03h Clock stopped in an unknown state
+	// All other values are Reserved for Future Use.
+	ccidDriver.sCcidMessage.bSpecific = 0;
 }
 
 //------------------------------------------------------------------------------
@@ -164,71 +164,71 @@
 //------------------------------------------------------------------------------
 static void RDRtoPCDatablock_ATR( void )
 {
-    unsigned char i;
-    unsigned char Atr[ATR_SIZE_MAX];
-    unsigned char length;
-    uint32_t status; 
+	unsigned char i;
+	unsigned char Atr[ATR_SIZE_MAX];
+	unsigned char length;
+	uint32_t status; 
 
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    status = ISO7816_Datablock_ATR( Atr, &length );
-    ISO7816_Decode_ATR( Atr );
+	status = ISO7816_Datablock_ATR( Atr, &length );
+	ISO7816_Decode_ATR( Atr );
 
-    if (status == 0) {
-        TRACE_DEBUG("Timeout occured while reading ATR");
+	if (status == 0) {
+		TRACE_DEBUG("Timeout occured while reading ATR");
 // FIXME: react properly to timeout..
 //        return;
-    }
+	}
 
 // FIXME: More tests? Is bProtocol = Atr[3] ?
-    if( length > 5 ) {
-        ccidDriver.ProtocolDataStructure[1] = Atr[3]&0x0F; // TD(1)
-        ccidDriver.bProtocol = Atr[3]&0x0F;           // TD(1)
-        TRACE_INFO("Protocol data structure: 0x%x\n\r",
-                        ccidDriver.ProtocolDataStructure[1]);
-    }
+	if( length > 5 ) {
+		ccidDriver.ProtocolDataStructure[1] = Atr[3]&0x0F; // TD(1)
+		ccidDriver.bProtocol = Atr[3]&0x0F;           // TD(1)
+		TRACE_INFO("Protocol data structure: 0x%x\n\r",
+					    ccidDriver.ProtocolDataStructure[1]);
+	}
 
-    // S_ccid_protocol_t0
-    // bmFindexDindex
-    ccidDriver.ProtocolDataStructure[0] = Atr[2];     // TA(1)
+	// S_ccid_protocol_t0
+	// bmFindexDindex
+	ccidDriver.ProtocolDataStructure[0] = Atr[2];     // TA(1)
 
-    // bmTCCKST0
-    // For T=0 ,B0 – 0b, B7-2 – 000000b
-    // B1 – Convention used (b1=0 for direct, b1=1 for inverse)
+	// bmTCCKST0
+	// For T=0 ,B0 – 0b, B7-2 – 000000b
+	// B1 – Convention used (b1=0 for direct, b1=1 for inverse)
 
-    // bGuardTimeT0
-    // Extra Guardtime between two characters. Add 0 to 254 etu to the normal 
-    // guardtime of 12etu. FFh is the same as 00h.
-    ccidDriver.ProtocolDataStructure[2] = Atr[4];     // TC(1)
-    // AT91C_BASE_US0->US_TTGR = 0;  // TC1
+	// bGuardTimeT0
+	// Extra Guardtime between two characters. Add 0 to 254 etu to the normal 
+	// guardtime of 12etu. FFh is the same as 00h.
+	ccidDriver.ProtocolDataStructure[2] = Atr[4];     // TC(1)
+	// AT91C_BASE_US0->US_TTGR = 0;  // TC1
 
-    // bWaitingIntegerT0
-    // WI for T=0 used to define WWT
-    ccidDriver.ProtocolDataStructure[3] = Atr[7];     // TC(2)
+	// bWaitingIntegerT0
+	// WI for T=0 used to define WWT
+	ccidDriver.ProtocolDataStructure[3] = Atr[7];     // TC(2)
 
-    // bClockStop
-    // ICC Clock Stop Support
-    // 00 = Stopping the Clock is not allowed
-    // 01 = Stop with Clock signal Low
-    // 02 = Stop with Clock signal High
-    // 03 = Stop with Clock either High or Low
-    ccidDriver.ProtocolDataStructure[4] = 0x00;       // 0 to 3
+	// bClockStop
+	// ICC Clock Stop Support
+	// 00 = Stopping the Clock is not allowed
+	// 01 = Stop with Clock signal Low
+	// 02 = Stop with Clock signal High
+	// 03 = Stop with Clock either High or Low
+	ccidDriver.ProtocolDataStructure[4] = 0x00;       // 0 to 3
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATABLOCK;
-    ccidDriver.sCcidMessage.wLength      = length;  // Size of ATR
-    ccidDriver.sCcidMessage.bSizeToSend += length;  // Size of ATR
-    // bChainParameter: 00 the response APDU begins and ends in this command
-    ccidDriver.sCcidMessage.bSpecific    = 0;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATABLOCK;
+	ccidDriver.sCcidMessage.wLength      = length;  // Size of ATR
+	ccidDriver.sCcidMessage.bSizeToSend += length;  // Size of ATR
+	// bChainParameter: 00 the response APDU begins and ends in this command
+	ccidDriver.sCcidMessage.bSpecific    = 0;
 
-    for( i=0; i<length; i++ ) {
+	for( i=0; i<length; i++ ) {
 
-        ccidDriver.sCcidMessage.abData[i]  = Atr[i];
-    }
+		ccidDriver.sCcidMessage.abData[i]  = Atr[i];
+	}
 
-    // Set the slot to an active status
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError = 0;
+	// Set the slot to an active status
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError = 0;
 }
 
 //------------------------------------------------------------------------------
@@ -243,17 +243,17 @@
 //------------------------------------------------------------------------------
 static void RDRtoPCDatablock( void )
 {
-    //TRACE_DEBUG(".");
+	//TRACE_DEBUG(".");
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATABLOCK;
-    ccidDriver.sCcidMessage.bSizeToSend += ccidDriver.sCcidMessage.wLength;
-    // bChainParameter: 00 the response APDU begins and ends in this command
-    ccidDriver.sCcidMessage.bSpecific = 0;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATABLOCK;
+	ccidDriver.sCcidMessage.bSizeToSend += ccidDriver.sCcidMessage.wLength;
+	// bChainParameter: 00 the response APDU begins and ends in this command
+	ccidDriver.sCcidMessage.bSpecific = 0;
 
-    // Set the slot to an active status
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError = 0;
+	// Set the slot to an active status
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError = 0;
 }
 
 //------------------------------------------------------------------------------
@@ -265,34 +265,34 @@
 //------------------------------------------------------------------------------
 static void RDRtoPCParameters( void )
 {
-    unsigned int i;
+	unsigned int i;
 
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_PARAMETERS;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_PARAMETERS;
 
-    //ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError  = 0;
+	//ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError  = 0;
 
-    if( ccidDriver.ProtocolDataStructure[1] == PROTOCOL_TO ) {
+	if( ccidDriver.ProtocolDataStructure[1] == PROTOCOL_TO ) {
 
-        // T=0
-        ccidDriver.sCcidMessage.wLength   = sizeof(S_ccid_protocol_t0);
-        ccidDriver.sCcidMessage.bSpecific = PROTOCOL_TO;
-    }
-    else {
+		// T=0
+		ccidDriver.sCcidMessage.wLength   = sizeof(S_ccid_protocol_t0);
+		ccidDriver.sCcidMessage.bSpecific = PROTOCOL_TO;
+	}
+	else {
 
-        // T=1
-        ccidDriver.sCcidMessage.wLength   = sizeof(S_ccid_protocol_t1);
-        ccidDriver.sCcidMessage.bSpecific = PROTOCOL_T1;
-    }
+		// T=1
+		ccidDriver.sCcidMessage.wLength   = sizeof(S_ccid_protocol_t1);
+		ccidDriver.sCcidMessage.bSpecific = PROTOCOL_T1;
+	}
 
-    ccidDriver.sCcidMessage.bSizeToSend += ccidDriver.sCcidMessage.wLength;
+	ccidDriver.sCcidMessage.bSizeToSend += ccidDriver.sCcidMessage.wLength;
 
-    for( i=0; i<ccidDriver.sCcidMessage.wLength; i++ ) {
-        ccidDriver.sCcidMessage.abData[i] = ccidDriver.ProtocolDataStructure[i];
-    }
+	for( i=0; i<ccidDriver.sCcidMessage.wLength; i++ ) {
+		ccidDriver.sCcidMessage.abData[i] = ccidDriver.ProtocolDataStructure[i];
+	}
 
 }
 
@@ -303,23 +303,23 @@
 //------------------------------------------------------------------------------
 static void RDRtoPCEscape( unsigned char length, unsigned char *data_send_from_CCID )
 {
-    unsigned int i;
+	unsigned int i;
 
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_ESCAPE;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_ESCAPE;
 
-    ccidDriver.sCcidMessage.wLength   = length;
+	ccidDriver.sCcidMessage.wLength   = length;
 
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError  = 0;
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError  = 0;
 
-    ccidDriver.sCcidMessage.bSpecific = 0;  // bRFU
+	ccidDriver.sCcidMessage.bSpecific = 0;  // bRFU
 
-    for( i=0; i<length; i++ ) {
-        ccidDriver.sCcidMessage.abData[i] = data_send_from_CCID[i];
-    }
+	for( i=0; i<length; i++ ) {
+		ccidDriver.sCcidMessage.abData[i] = data_send_from_CCID[i];
+	}
 }
 
 //------------------------------------------------------------------------------
@@ -328,23 +328,23 @@
 ///   PC_to_RDR_SetDataRateAndClockFrequency
 //------------------------------------------------------------------------------
 static void RDRtoPCDataRateAndClockFrequency( unsigned int dwClockFrequency, 
-                                       unsigned int dwDataRate )
+					                   unsigned int dwDataRate )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATARATEANDCLOCKFREQUENCY;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_DATARATEANDCLOCKFREQUENCY;
 
-    ccidDriver.sCcidMessage.wLength   = 8;
+	ccidDriver.sCcidMessage.wLength   = 8;
 
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError  = 0;
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError  = 0;
 
-    ccidDriver.sCcidMessage.bSpecific = 0;  // bRFU
+	ccidDriver.sCcidMessage.bSpecific = 0;  // bRFU
 
-    ccidDriver.sCcidMessage.abData[0] = dwClockFrequency;
-    
-    ccidDriver.sCcidMessage.abData[4] = dwDataRate;
+	ccidDriver.sCcidMessage.abData[0] = dwClockFrequency;
+	
+	ccidDriver.sCcidMessage.abData[4] = dwDataRate;
 }
 
 //------------------------------------------------------------------------------
@@ -354,27 +354,27 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRIccPowerOn( void )
 {
-    TRACE_DEBUG(".");
-    if( CCID_FEATURES_AUTO_VOLT == (configurationDescriptorsFS->ccid.dwFeatures & CCID_FEATURES_AUTO_VOLT) ) {
+	TRACE_DEBUG(".");
+	if( CCID_FEATURES_AUTO_VOLT == (configurationDescriptorsFS->ccid.dwFeatures & CCID_FEATURES_AUTO_VOLT) ) {
 
-        //bPowerSelect = ccidDriver.sCcidCommand.bSpecific_0;
-        ccidDriver.sCcidCommand.bSpecific_0 = VOLTS_AUTO;
-    }
+		//bPowerSelect = ccidDriver.sCcidCommand.bSpecific_0;
+		ccidDriver.sCcidCommand.bSpecific_0 = VOLTS_AUTO;
+	}
 
-    ISO7816_warm_reset();
+	ISO7816_warm_reset();
 //    ISO7816_cold_reset();
 
-    // for emulation only //JCB 
-    if ( ccidDriver.sCcidCommand.bSpecific_0 != VOLTS_5_0 ) {
+	// for emulation only //JCB 
+	if ( ccidDriver.sCcidCommand.bSpecific_0 != VOLTS_5_0 ) {
 
-        TRACE_ERROR("POWER_NOT_SUPPORTED\n\r");
-    }
+		TRACE_ERROR("POWER_NOT_SUPPORTED\n\r");
+	}
 
-    else {
+	else {
 
-        RDRtoPCDatablock_ATR();
+		RDRtoPCDatablock_ATR();
 
-    }
+	}
 }
 
 //------------------------------------------------------------------------------
@@ -384,23 +384,23 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRIccPowerOff( void )
 {
-    unsigned char bStatus;
+	unsigned char bStatus;
 
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    ISO7816_IccPowerOff();
+	ISO7816_IccPowerOff();
 
-    //JCB stub
-    bStatus = ICC_BS_PRESENT_NOTACTIVATED;
+	//JCB stub
+	bStatus = ICC_BS_PRESENT_NOTACTIVATED;
 
-    // Set the slot to an inactive status
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError = 0;
+	// Set the slot to an inactive status
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError = 0;
 
-    // if error, see Table 6.1-2 errors
+	// if error, see Table 6.1-2 errors
 
-    // Return the slot status to the host
-    RDRtoPCSlotStatus();
+	// Return the slot status to the host
+	RDRtoPCSlotStatus();
 }
 
 //------------------------------------------------------------------------------
@@ -409,13 +409,13 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRGetSlotStatus( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    ccidDriver.sCcidMessage.bStatus = 0;
-    ccidDriver.sCcidMessage.bError = 0;
+	ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bError = 0;
 
-    // Return the slot status to the host
-    RDRtoPCSlotStatus();
+	// Return the slot status to the host
+	RDRtoPCSlotStatus();
 }
 
 //------------------------------------------------------------------------------
@@ -425,69 +425,69 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRXfrBlock( void )
 {
-    uint16_t msglen = 0;
-    uint32_t ret;
+	uint16_t msglen = 0;
+	uint32_t ret;
 
-    TRACE_DEBUG("PCtoRDRXfrBlock\n");
+	TRACE_DEBUG("PCtoRDRXfrBlock\n");
 
-    // Check the block length
-    if ( ccidDriver.sCcidCommand.wLength > (configurationDescriptorsFS->ccid.dwMaxCCIDMessageLength-10) ) {
-        TRACE_DEBUG("Err block/msg len");
-        ccidDriver.sCcidMessage.bStatus = 1;
-        ccidDriver.sCcidMessage.bError  = 0;
-    }
-    // check bBWI
-    else if ( 0 != ccidDriver.sCcidCommand.bSpecific_0 ) {
+	// Check the block length
+	if ( ccidDriver.sCcidCommand.wLength > (configurationDescriptorsFS->ccid.dwMaxCCIDMessageLength-10) ) {
+		TRACE_DEBUG("Err block/msg len");
+		ccidDriver.sCcidMessage.bStatus = 1;
+		ccidDriver.sCcidMessage.bError  = 0;
+	}
+	// check bBWI
+	else if ( 0 != ccidDriver.sCcidCommand.bSpecific_0 ) {
 
-         TRACE_ERROR("Bad bBWI\n\r");
-    }
-    else {
+		 TRACE_ERROR("Bad bBWI\n\r");
+	}
+	else {
 
-        // APDU or TPDU
-        switch(configurationDescriptorsFS->ccid.dwFeatures 
-              & (CCID_FEATURES_EXC_TPDU|CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU)) {
+		// APDU or TPDU
+		switch(configurationDescriptorsFS->ccid.dwFeatures 
+			  & (CCID_FEATURES_EXC_TPDU|CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU)) {
 
-            case CCID_FEATURES_EXC_TPDU:
-                if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_TO) {
-                    TRACE_DEBUG("APDU cmd: %x %x %x ..", ccidDriver.sCcidCommand.APDU[0], ccidDriver.sCcidCommand.APDU[1],ccidDriver.sCcidCommand.APDU[2] );
+			case CCID_FEATURES_EXC_TPDU:
+				if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_TO) {
+					TRACE_DEBUG("APDU cmd: %x %x %x ..", ccidDriver.sCcidCommand.APDU[0], ccidDriver.sCcidCommand.APDU[1],ccidDriver.sCcidCommand.APDU[2] );
 
-                    // Send commande APDU
-                    ret = ISO7816_XfrBlockTPDU_T0( ccidDriver.sCcidCommand.APDU ,
-                                            ccidDriver.sCcidMessage.abData,
-                                            ccidDriver.sCcidCommand.wLength,
-                                            &msglen );
-                    if (ret != 0) {
-                        TRACE_ERROR("APDU could not be sent: (US_CSR = 0x%x)", ret);
-                        return;
-                    }
-                }
-                else {
-                    if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_T1) {
-                        TRACE_DEBUG("Not supported T=1\n\r");
-                    }
-                    else {
-                        TRACE_DEBUG("Not supported 0x%x\n\r", ccidDriver.ProtocolDataStructure[1]);
-                    }
-                }
-                break;
+					// Send commande APDU
+					ret = ISO7816_XfrBlockTPDU_T0( ccidDriver.sCcidCommand.APDU ,
+					                        ccidDriver.sCcidMessage.abData,
+					                        ccidDriver.sCcidCommand.wLength,
+					                        &msglen );
+					if (ret != 0) {
+					    TRACE_ERROR("APDU could not be sent: (US_CSR = 0x%x)", ret);
+					    return;
+					}
+				}
+				else {
+					if (ccidDriver.ProtocolDataStructure[1] == PROTOCOL_T1) {
+					    TRACE_DEBUG("Not supported T=1\n\r");
+					}
+					else {
+					    TRACE_DEBUG("Not supported 0x%x\n\r", ccidDriver.ProtocolDataStructure[1]);
+					}
+				}
+				break;
 
-            case CCID_FEATURES_EXC_APDU:
-                TRACE_DEBUG("Not supported CCID_FEATURES_EXC_APDU\n\r");
-                break;
+			case CCID_FEATURES_EXC_APDU:
+				TRACE_DEBUG("Not supported CCID_FEATURES_EXC_APDU\n\r");
+				break;
 
-            default:
-                break;
-        }
+			default:
+				break;
+		}
 
-    }
+	}
 
-    ccidDriver.sCcidMessage.wLength = msglen;
-    TRACE_DEBUG("USB: 0x%X, 0x%X, 0x%X, 0x%X, 0x%X\n\r", ccidDriver.sCcidMessage.abData[0], 
-                                                                    ccidDriver.sCcidMessage.abData[1], 
-                                                                    ccidDriver.sCcidMessage.abData[2], 
-                                                                    ccidDriver.sCcidMessage.abData[3],
-                                                                    ccidDriver.sCcidMessage.abData[4] );
-     RDRtoPCDatablock();
+	ccidDriver.sCcidMessage.wLength = msglen;
+	TRACE_DEBUG("USB: 0x%X, 0x%X, 0x%X, 0x%X, 0x%X\n\r", ccidDriver.sCcidMessage.abData[0], 
+					                                                ccidDriver.sCcidMessage.abData[1], 
+					                                                ccidDriver.sCcidMessage.abData[2], 
+					                                                ccidDriver.sCcidMessage.abData[3],
+					                                                ccidDriver.sCcidMessage.abData[4] );
+	 RDRtoPCDatablock();
 
 }
 
@@ -497,21 +497,21 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRGetParameters( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // We support only one slot
+	// We support only one slot
 
-    // bmIccStatus
-    if( ISO7816_StatusReset() ) {
-        // 0: An ICC is present and active (power is on and stable, RST is inactive
-        ccidDriver.sCcidMessage.bStatus = 0;
-    }
-    else {
-        // 1: An ICC is present and inactive (not activated or shut down by hardware error)
-        ccidDriver.sCcidMessage.bStatus = 1;
-    }
+	// bmIccStatus
+	if( ISO7816_StatusReset() ) {
+		// 0: An ICC is present and active (power is on and stable, RST is inactive
+		ccidDriver.sCcidMessage.bStatus = 0;
+	}
+	else {
+		// 1: An ICC is present and inactive (not activated or shut down by hardware error)
+		ccidDriver.sCcidMessage.bStatus = 1;
+	}
 
-    RDRtoPCParameters();
+	RDRtoPCParameters();
 }
 
 //------------------------------------------------------------------------------
@@ -520,12 +520,12 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRResetParameters( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    ccidDriver.SlotStatus = ICC_NOT_PRESENT;
-    ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus;
+	ccidDriver.SlotStatus = ICC_NOT_PRESENT;
+	ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus;
 
-    RDRtoPCParameters();
+	RDRtoPCParameters();
 }
 
 //------------------------------------------------------------------------------
@@ -534,13 +534,13 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRSetParameters( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    ccidDriver.SlotStatus = ccidDriver.sCcidCommand.bSlot;
-    ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus;
-    // Not all feature supported
+	ccidDriver.SlotStatus = ccidDriver.sCcidCommand.bSlot;
+	ccidDriver.sCcidMessage.bStatus = ccidDriver.SlotStatus;
+	// Not all feature supported
 
-    RDRtoPCParameters();
+	RDRtoPCParameters();
 }
 
 //------------------------------------------------------------------------------
@@ -551,13 +551,13 @@
 //------------------------------------------------------------------------------
 static void PCtoRDREscape( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // If needed by the user
-    ISO7816_Escape();
+	// If needed by the user
+	ISO7816_Escape();
 
-    // stub, return all value send
-    RDRtoPCEscape( ccidDriver.sCcidCommand.wLength, ccidDriver.sCcidCommand.APDU);    
+	// stub, return all value send
+	RDRtoPCEscape( ccidDriver.sCcidCommand.wLength, ccidDriver.sCcidCommand.APDU);    
 }
 
 //------------------------------------------------------------------------------
@@ -566,18 +566,18 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRICCClock( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    if( 0 == ccidDriver.sCcidCommand.bSpecific_0 ) {
-        // restarts the clock
-        ISO7816_RestartClock();
-    }
-    else {
-        // stop clock in the state shown in the bClockStop field
-        ISO7816_StopClock();
-    }
+	if( 0 == ccidDriver.sCcidCommand.bSpecific_0 ) {
+		// restarts the clock
+		ISO7816_RestartClock();
+	}
+	else {
+		// stop clock in the state shown in the bClockStop field
+		ISO7816_StopClock();
+	}
 
-    RDRtoPCSlotStatus( );    
+	RDRtoPCSlotStatus( );    
 }
 
 //------------------------------------------------------------------------------
@@ -587,22 +587,22 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRtoAPDU( void )
 {
-    unsigned char bmChanges;
-    unsigned char bClassGetResponse;
-    unsigned char bClassEnvelope;
+	unsigned char bmChanges;
+	unsigned char bClassGetResponse;
+	unsigned char bClassEnvelope;
 
-    TRACE_INFO(".");
+	TRACE_INFO(".");
 
-    if( configurationDescriptorsFS->ccid.dwFeatures == (CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU) ) {
+	if( configurationDescriptorsFS->ccid.dwFeatures == (CCID_FEATURES_EXC_SAPDU|CCID_FEATURES_EXC_APDU) ) {
 
-        bmChanges = ccidDriver.sCcidCommand.bSpecific_0;
-        bClassGetResponse = ccidDriver.sCcidCommand.bSpecific_1;
-        bClassEnvelope = ccidDriver.sCcidCommand.bSpecific_2;
+		bmChanges = ccidDriver.sCcidCommand.bSpecific_0;
+		bClassGetResponse = ccidDriver.sCcidCommand.bSpecific_1;
+		bClassEnvelope = ccidDriver.sCcidCommand.bSpecific_2;
 
-        ISO7816_toAPDU();
-    }
+		ISO7816_toAPDU();
+	}
 
-    RDRtoPCSlotStatus();    
+	RDRtoPCSlotStatus();    
 }
 
 //------------------------------------------------------------------------------
@@ -612,9 +612,9 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRSecure( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    TRACE_DEBUG("For user\n\r");
+	TRACE_DEBUG("For user\n\r");
 }
 
 //------------------------------------------------------------------------------
@@ -627,10 +627,10 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRMechanical( void )
 {
-    TRACE_DEBUG(".");
-    TRACE_DEBUG("Not implemented\n\r");
+	TRACE_DEBUG(".");
+	TRACE_DEBUG("Not implemented\n\r");
 
-    RDRtoPCSlotStatus();
+	RDRtoPCSlotStatus();
 }
 
 //------------------------------------------------------------------------------
@@ -641,9 +641,9 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRAbort( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    RDRtoPCSlotStatus();
+	RDRtoPCSlotStatus();
 }
 
 //------------------------------------------------------------------------------
@@ -653,24 +653,24 @@
 //------------------------------------------------------------------------------
 static void PCtoRDRSetDataRateAndClockFrequency( void )
 {
-    unsigned int dwClockFrequency;
-    unsigned int dwDataRate;
+	unsigned int dwClockFrequency;
+	unsigned int dwDataRate;
 
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    dwClockFrequency = ccidDriver.sCcidCommand.APDU[0]
-                     + (ccidDriver.sCcidCommand.APDU[1]<<8)
-                     + (ccidDriver.sCcidCommand.APDU[2]<<16)
-                     + (ccidDriver.sCcidCommand.APDU[3]<<24);
+	dwClockFrequency = ccidDriver.sCcidCommand.APDU[0]
+					 + (ccidDriver.sCcidCommand.APDU[1]<<8)
+					 + (ccidDriver.sCcidCommand.APDU[2]<<16)
+					 + (ccidDriver.sCcidCommand.APDU[3]<<24);
 
-    dwDataRate = ccidDriver.sCcidCommand.APDU[4]
-               + (ccidDriver.sCcidCommand.APDU[5]<<8)
-               + (ccidDriver.sCcidCommand.APDU[6]<<16)
-               + (ccidDriver.sCcidCommand.APDU[7]<<24);
+	dwDataRate = ccidDriver.sCcidCommand.APDU[4]
+			   + (ccidDriver.sCcidCommand.APDU[5]<<8)
+			   + (ccidDriver.sCcidCommand.APDU[6]<<16)
+			   + (ccidDriver.sCcidCommand.APDU[7]<<24);
 
-    ISO7816_SetDataRateandClockFrequency( dwClockFrequency, dwDataRate );
+	ISO7816_SetDataRateandClockFrequency( dwClockFrequency, dwDataRate );
 
-    RDRtoPCDataRateAndClockFrequency( dwClockFrequency, dwDataRate );
+	RDRtoPCDataRateAndClockFrequency( dwClockFrequency, dwDataRate );
 
 }
 
@@ -679,20 +679,20 @@
 //------------------------------------------------------------------------------
 static void vCCIDCommandNotSupported( void )
 {
-    // Command not supported
-    // vCCIDReportError(CMD_NOT_SUPPORTED);
+	// Command not supported
+	// vCCIDReportError(CMD_NOT_SUPPORTED);
 
-    TRACE_DEBUG("CMD_NOT_SUPPORTED\n\r");
+	TRACE_DEBUG("CMD_NOT_SUPPORTED\n\r");
 
-    // Header fields settings
-    ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS;
-    ccidDriver.sCcidMessage.wLength      = 0;
-    ccidDriver.sCcidMessage.bSpecific    = 0;
+	// Header fields settings
+	ccidDriver.sCcidMessage.bMessageType = RDR_TO_PC_SLOTSTATUS;
+	ccidDriver.sCcidMessage.wLength      = 0;
+	ccidDriver.sCcidMessage.bSpecific    = 0;
 
-    ccidDriver.sCcidMessage.bStatus |= ICC_CS_FAILED;
+	ccidDriver.sCcidMessage.bStatus |= ICC_CS_FAILED;
 
-    // Send the response to the host
-    //vCCIDSendResponse();
+	// Send the response to the host
+	//vCCIDSendResponse();
 }
 
 //------------------------------------------------------------------------------
@@ -700,15 +700,15 @@
 //------------------------------------------------------------------------------
 static void vCCIDSendResponse( void )
 {
-    unsigned char bStatus;
-    TRACE_DEBUG(".");
+	unsigned char bStatus;
+	TRACE_DEBUG(".");
 
-    do {
-        bStatus = CCID_Write((void*)&ccidDriver.sCcidMessage,
-                              ccidDriver.sCcidMessage.bSizeToSend, 0, 0 );
-    } while (bStatus != USBD_STATUS_SUCCESS);
+	do {
+		bStatus = CCID_Write((void*)&ccidDriver.sCcidMessage,
+					          ccidDriver.sCcidMessage.bSizeToSend, 0, 0 );
+	} while (bStatus != USBD_STATUS_SUCCESS);
 
-    TRACE_DEBUG("bStatus: 0x%x\n\r", bStatus);
+	TRACE_DEBUG("bStatus: 0x%x\n\r", bStatus);
 }
 
 
@@ -717,133 +717,133 @@
 //------------------------------------------------------------------------------
 static void CCIDCommandDispatcher( void *pArg, uint8_t status, uint32_t transferred, uint32_t remaining )
 {
-    unsigned char MessageToSend = 0;
+	unsigned char MessageToSend = 0;
 
-    if (status != USBD_STATUS_SUCCESS) {
-        TRACE_ERROR("USB error: %d", status);
-        return;
-    }
-    TRACE_DEBUG("Command: 0x%X 0x%x 0x%X 0x%X 0x%X 0x%X 0x%X\n\r\n\r",
-                   (unsigned int)ccidDriver.sCcidCommand.bMessageType,
-                   (unsigned int)ccidDriver.sCcidCommand.wLength,
-                   (unsigned int)ccidDriver.sCcidCommand.bSlot,
-                   (unsigned int)ccidDriver.sCcidCommand.bSeq,
-                   (unsigned int)ccidDriver.sCcidCommand.bSpecific_0,
-                   (unsigned int)ccidDriver.sCcidCommand.bSpecific_1,
-                   (unsigned int)ccidDriver.sCcidCommand.bSpecific_2);
+	if (status != USBD_STATUS_SUCCESS) {
+		TRACE_ERROR("USB error: %d", status);
+		return;
+	}
+	TRACE_DEBUG("Command: 0x%X 0x%x 0x%X 0x%X 0x%X 0x%X 0x%X\n\r\n\r",
+				   (unsigned int)ccidDriver.sCcidCommand.bMessageType,
+				   (unsigned int)ccidDriver.sCcidCommand.wLength,
+				   (unsigned int)ccidDriver.sCcidCommand.bSlot,
+				   (unsigned int)ccidDriver.sCcidCommand.bSeq,
+				   (unsigned int)ccidDriver.sCcidCommand.bSpecific_0,
+				   (unsigned int)ccidDriver.sCcidCommand.bSpecific_1,
+				   (unsigned int)ccidDriver.sCcidCommand.bSpecific_2);
 
-    // Check the slot number
-    if ( ccidDriver.sCcidCommand.bSlot > 0 ) {
+	// Check the slot number
+	if ( ccidDriver.sCcidCommand.bSlot > 0 ) {
 
-        TRACE_ERROR("BAD_SLOT_NUMBER\n\r");
-    }
+		TRACE_ERROR("BAD_SLOT_NUMBER\n\r");
+	}
 
-    TRACE_INFO("typ=0x%X\n\r", ccidDriver.sCcidCommand.bMessageType);
+	TRACE_INFO("typ=0x%X\n\r", ccidDriver.sCcidCommand.bMessageType);
 
-    ccidDriver.sCcidMessage.bStatus = 0;
+	ccidDriver.sCcidMessage.bStatus = 0;
 
-    ccidDriver.sCcidMessage.bSeq  = ccidDriver.sCcidCommand.bSeq;
-    ccidDriver.sCcidMessage.bSlot = ccidDriver.sCcidCommand.bSlot;
+	ccidDriver.sCcidMessage.bSeq  = ccidDriver.sCcidCommand.bSeq;
+	ccidDriver.sCcidMessage.bSlot = ccidDriver.sCcidCommand.bSlot;
 
-    ccidDriver.sCcidMessage.bSizeToSend = sizeof(S_ccid_bulk_in_header)-(ABDATA_SIZE+1);
+	ccidDriver.sCcidMessage.bSizeToSend = sizeof(S_ccid_bulk_in_header)-(ABDATA_SIZE+1);
 
 
-    // Command dispatcher
-    switch ( ccidDriver.sCcidCommand.bMessageType ) {
+	// Command dispatcher
+	switch ( ccidDriver.sCcidCommand.bMessageType ) {
 
-        case PC_TO_RDR_ICCPOWERON:
-            PCtoRDRIccPowerOn();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_ICCPOWERON:
+			PCtoRDRIccPowerOn();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_ICCPOWEROFF:
-            PCtoRDRIccPowerOff();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_ICCPOWEROFF:
+			PCtoRDRIccPowerOff();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_GETSLOTSTATUS:
-            PCtoRDRGetSlotStatus();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_GETSLOTSTATUS:
+			PCtoRDRGetSlotStatus();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_XFRBLOCK:
-            PCtoRDRXfrBlock();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_XFRBLOCK:
+			PCtoRDRXfrBlock();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_GETPARAMETERS:
-            PCtoRDRGetParameters();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_GETPARAMETERS:
+			PCtoRDRGetParameters();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_RESETPARAMETERS:
-            PCtoRDRResetParameters();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_RESETPARAMETERS:
+			PCtoRDRResetParameters();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_SETPARAMETERS:
-            PCtoRDRSetParameters();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_SETPARAMETERS:
+			PCtoRDRSetParameters();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_ESCAPE:
-            PCtoRDREscape();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_ESCAPE:
+			PCtoRDREscape();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_ICCCLOCK:
-            PCtoRDRICCClock();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_ICCCLOCK:
+			PCtoRDRICCClock();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_T0APDU:
-            // Only CCIDs reporting a short or extended APDU level in the dwFeatures 
-            // field of the CCID class descriptor may take this command into account.
-            if( (CCID_FEATURES_EXC_SAPDU == (CCID_FEATURES_EXC_SAPDU&configurationDescriptorsFS->ccid.dwFeatures))
-            || (CCID_FEATURES_EXC_APDU  == (CCID_FEATURES_EXC_APDU &configurationDescriptorsFS->ccid.dwFeatures)) ) {
+		case PC_TO_RDR_T0APDU:
+			// Only CCIDs reporting a short or extended APDU level in the dwFeatures 
+			// field of the CCID class descriptor may take this command into account.
+			if( (CCID_FEATURES_EXC_SAPDU == (CCID_FEATURES_EXC_SAPDU&configurationDescriptorsFS->ccid.dwFeatures))
+			|| (CCID_FEATURES_EXC_APDU  == (CCID_FEATURES_EXC_APDU &configurationDescriptorsFS->ccid.dwFeatures)) ) {
 
-                // command supported
-                PCtoRDRtoAPDU();
-            }
-            else {
-                // command not supported
-                TRACE_INFO("Not supported: PC_TO_RDR_T0APDU\n\r");
-                vCCIDCommandNotSupported();
-            }
-            MessageToSend = 1;
-            break;
+				// command supported
+				PCtoRDRtoAPDU();
+			}
+			else {
+				// command not supported
+				TRACE_INFO("Not supported: PC_TO_RDR_T0APDU\n\r");
+				vCCIDCommandNotSupported();
+			}
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_SECURE:
-            PCtoRDRSecure();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_SECURE:
+			PCtoRDRSecure();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_MECHANICAL:
-            PCtoRDRMechanical();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_MECHANICAL:
+			PCtoRDRMechanical();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_ABORT:
-            PCtoRDRAbort();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_ABORT:
+			PCtoRDRAbort();
+			MessageToSend = 1;
+			break;
 
-        case PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY:
-            PCtoRDRSetDataRateAndClockFrequency();
-            MessageToSend = 1;
-            break;
+		case PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY:
+			PCtoRDRSetDataRateAndClockFrequency();
+			MessageToSend = 1;
+			break;
 
-        default:
-            TRACE_DEBUG("default: Not supported: 0x%X\n\r", ccidDriver.sCcidCommand.bMessageType);
-            vCCIDCommandNotSupported();
-            MessageToSend = 1;
-            break;
+		default:
+			TRACE_DEBUG("default: Not supported: 0x%X\n\r", ccidDriver.sCcidCommand.bMessageType);
+			vCCIDCommandNotSupported();
+			MessageToSend = 1;
+			break;
 
-    }
+	}
 
-    if( MessageToSend == 1 ) {
-        vCCIDSendResponse();
-    }
+	if( MessageToSend == 1 ) {
+		vCCIDSendResponse();
+	}
 }
 
 
@@ -853,49 +853,49 @@
 //------------------------------------------------------------------------------
 static void CCID_RequestHandler(const USBGenericRequest *pRequest)
 {
-    TRACE_DEBUG("CCID_RHl\n\r");
+	TRACE_DEBUG("CCID_RHl\n\r");
 
-    // Check if this is a class request
-    if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_CLASS) {
+	// Check if this is a class request
+	if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_CLASS) {
 
-        // Check if the request is supported
-        switch (USBGenericRequest_GetRequest(pRequest)) {
+		// Check if the request is supported
+		switch (USBGenericRequest_GetRequest(pRequest)) {
 
-            case CCIDGenericRequest_ABORT:
-                TRACE_DEBUG("CCIDGenericRequest_ABORT\n\r");
-                break;
+			case CCIDGenericRequest_ABORT:
+				TRACE_DEBUG("CCIDGenericRequest_ABORT\n\r");
+				break;
 
-            case CCIDGenericRequest_GET_CLOCK_FREQUENCIES:
-                TRACE_DEBUG("Not supported: CCIDGenericRequest_GET_CLOCK_FREQUENCIES\n\r");
-                // A CCID with bNumClockSupported equal to 00h does not have 
-                // to support this request
-                break;
+			case CCIDGenericRequest_GET_CLOCK_FREQUENCIES:
+				TRACE_DEBUG("Not supported: CCIDGenericRequest_GET_CLOCK_FREQUENCIES\n\r");
+				// A CCID with bNumClockSupported equal to 00h does not have 
+				// to support this request
+				break;
 
-            case CCIDGenericRequest_GET_DATA_RATES:
-                TRACE_DEBUG("Not supported: CCIDGenericRequest_GET_DATA_RATES\n\r");
-                // A CCID with bNumDataRatesSupported equal to 00h does not have 
-                // to support this request.
-                break;
+			case CCIDGenericRequest_GET_DATA_RATES:
+				TRACE_DEBUG("Not supported: CCIDGenericRequest_GET_DATA_RATES\n\r");
+				// A CCID with bNumDataRatesSupported equal to 00h does not have 
+				// to support this request.
+				break;
 
-            default:
-                TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request (%d)\n\r",
-                                                    USBGenericRequest_GetRequest(pRequest));
-                USBD_Stall(0);
-        }
-    }
+			default:
+				TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request (%d)\n\r",
+					                                USBGenericRequest_GetRequest(pRequest));
+				USBD_Stall(0);
+		}
+	}
 
-    else if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_STANDARD) {
+	else if (USBGenericRequest_GetType(pRequest) == USBGenericRequest_STANDARD) {
 
-        // Forward request to the standard handler
-        USBDDriver_RequestHandler(USBD_GetDriver(), pRequest);
-    }
-    else {
+		// Forward request to the standard handler
+		USBDDriver_RequestHandler(USBD_GetDriver(), pRequest);
+	}
+	else {
 
-        // Unsupported request type
-        TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request type (%d)\n\r",
-                                                    USBGenericRequest_GetType(pRequest));
-        USBD_Stall(0);
-    }
+		// Unsupported request type
+		TRACE_WARNING( "CCIDDriver_RequestHandler: Unsupported request type (%d)\n\r",
+					                                USBGenericRequest_GetType(pRequest));
+		USBD_Stall(0);
+	}
 }
 
 
@@ -910,7 +910,7 @@
 // not static function
 void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
 {
-    CCID_RequestHandler(request);
+	CCID_RequestHandler(request);
 }
 #endif
 
@@ -920,17 +920,17 @@
 //------------------------------------------------------------------------------
 void CCID_SmartCardRequest( void )
 {
-    unsigned char bStatus;
-    TRACE_DEBUG("CCID_req\n");
+	unsigned char bStatus;
+	TRACE_DEBUG("CCID_req\n");
 
-    do {
+	do {
 
-        bStatus = CCID_Read( (void*)&ccidDriver.sCcidCommand,
-                             sizeof(S_ccid_bulk_out_header),
-                             (TransferCallback)&CCIDCommandDispatcher,
-                             (void*)0 );
-    }
-    while (0);
+		bStatus = CCID_Read( (void*)&ccidDriver.sCcidCommand,
+					         sizeof(S_ccid_bulk_out_header),
+					         (TransferCallback)&CCIDCommandDispatcher,
+					         (void*)0 );
+	}
+	while (0);
 }
 
 
@@ -943,11 +943,11 @@
 /// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS
 //------------------------------------------------------------------------------
 unsigned char CCID_Read(void *pBuffer,
-                        unsigned int dLength,
-                        TransferCallback fCallback,
-                        void *pArgument)
+					    unsigned int dLength,
+					    TransferCallback fCallback,
+					    void *pArgument)
 {
-    return USBD_Read(CCID_EPT_DATA_OUT, pBuffer, dLength, fCallback, pArgument);
+	return USBD_Read(CCID_EPT_DATA_OUT, pBuffer, dLength, fCallback, pArgument);
 }
 
 //------------------------------------------------------------------------------
@@ -959,11 +959,11 @@
 /// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS
 //------------------------------------------------------------------------------
 unsigned char CCID_Write(void *pBuffer,
-                         unsigned int dLength,
-                         TransferCallback fCallback,
-                         void *pArgument)
+					     unsigned int dLength,
+					     TransferCallback fCallback,
+					     void *pArgument)
 {
-    return USBD_Write(CCID_EPT_DATA_IN, pBuffer, dLength, fCallback, pArgument);
+	return USBD_Write(CCID_EPT_DATA_IN, pBuffer, dLength, fCallback, pArgument);
 }
 
 //------------------------------------------------------------------------------
@@ -973,15 +973,15 @@
 //------------------------------------------------------------------------------
 unsigned char CCID_Insertion( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Build the Interrupt-IN message
-    ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE;
-    ccidDriver.BufferINT[1] = ICC_INSERTED_EVENT;
-    ccidDriver.SlotStatus   = ICC_INSERTED_EVENT;
+	// Build the Interrupt-IN message
+	ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE;
+	ccidDriver.BufferINT[1] = ICC_INSERTED_EVENT;
+	ccidDriver.SlotStatus   = ICC_INSERTED_EVENT;
 
-    // Notify the host that a ICC is inserted
-    return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 );
+	// Notify the host that a ICC is inserted
+	return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 );
 }
 
 //------------------------------------------------------------------------------
@@ -991,15 +991,15 @@
 //------------------------------------------------------------------------------
 unsigned char CCID_Removal( void )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Build the Interrupt-IN message
-    ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE;
-    ccidDriver.BufferINT[1] = ICC_NOT_PRESENT;
-    ccidDriver.SlotStatus   = ICC_NOT_PRESENT;
+	// Build the Interrupt-IN message
+	ccidDriver.BufferINT[0] = RDR_TO_PC_NOTIFYSLOTCHANGE;
+	ccidDriver.BufferINT[1] = ICC_NOT_PRESENT;
+	ccidDriver.SlotStatus   = ICC_NOT_PRESENT;
 
-    // Notify the host that a ICC is inserted
-    return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 );
+	// Notify the host that a ICC is inserted
+	return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 2, 0, 0 );
 }
 
 //------------------------------------------------------------------------------
@@ -1014,19 +1014,19 @@
 /// \return USBD_STATUS_LOCKED or USBD_STATUS_SUCCESS
 //------------------------------------------------------------------------------
 unsigned char RDRtoPCHardwareError( unsigned char bSlot, 
-                                    unsigned char bSeq, 
-                                    unsigned char bHardwareErrorCode )
+					                unsigned char bSeq, 
+					                unsigned char bHardwareErrorCode )
 {
-    TRACE_DEBUG(".");
+	TRACE_DEBUG(".");
 
-    // Build the Interrupt-IN message
-    ccidDriver.BufferINT[0] = RDR_TO_PC_HARDWAREERROR;
-    ccidDriver.BufferINT[1] = bSlot;
-    ccidDriver.BufferINT[2] = bSeq;
-    ccidDriver.BufferINT[3] = bHardwareErrorCode;
+	// Build the Interrupt-IN message
+	ccidDriver.BufferINT[0] = RDR_TO_PC_HARDWAREERROR;
+	ccidDriver.BufferINT[1] = bSlot;
+	ccidDriver.BufferINT[2] = bSeq;
+	ccidDriver.BufferINT[3] = bHardwareErrorCode;
 
-    // Notify the host that a ICC is inserted
-    return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 4, 0, 0 );
+	// Notify the host that a ICC is inserted
+	return USBD_Write( CCID_EPT_NOTIFICATION, ccidDriver.BufferINT, 4, 0, 0 );
 }
 
 #endif /* HAVE_CCID */
diff --git a/firmware/libcommon/source/iso7816_4.c b/firmware/libcommon/source/iso7816_4.c
index 7219741..ac15306 100644
--- a/firmware/libcommon/source/iso7816_4.c
+++ b/firmware/libcommon/source/iso7816_4.c
@@ -76,45 +76,45 @@
  */
 uint32_t ISO7816_GetChar( uint8_t *pCharToReceive, Usart_info *usart)
 {
-    uint32_t status;
-    uint32_t timeout=0;
+	uint32_t status;
+	uint32_t timeout=0;
 
-    Usart *us_base = usart->base;
-    uint32_t us_id = usart->id;
+	Usart *us_base = usart->base;
+	uint32_t us_id = usart->id;
 
-    if( usart->state == USART_SEND ) {
-        while((us_base->US_CSR & US_CSR_TXEMPTY) == 0) {}
-        us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
-        usart->state = USART_RCV;
-    }
+	if( usart->state == USART_SEND ) {
+		while((us_base->US_CSR & US_CSR_TXEMPTY) == 0) {}
+		us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
+		usart->state = USART_RCV;
+	}
 
-    /* Wait USART ready for reception */
-    while( ((us_base->US_CSR & US_CSR_RXRDY) == 0) ) {
+	/* Wait USART ready for reception */
+	while( ((us_base->US_CSR & US_CSR_RXRDY) == 0) ) {
 	WDT_Restart(WDT);
-        if(timeout++ > 12000 * (BOARD_MCK/1000000)) {
-            TRACE_WARNING("TimeOut\n\r");
-            return( 0 );
-        }
-    }
+		if(timeout++ > 12000 * (BOARD_MCK/1000000)) {
+			TRACE_WARNING("TimeOut\n\r");
+			return( 0 );
+		}
+	}
 
-    /* At least one complete character has been received and US_RHR has not yet been read. */
+	/* At least one complete character has been received and US_RHR has not yet been read. */
 
-    /* Get a char */
-    *pCharToReceive = ((us_base->US_RHR) & 0xFF);
+	/* Get a char */
+	*pCharToReceive = ((us_base->US_RHR) & 0xFF);
 
-    status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
-                                      US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
-                                      (1<<10)));
+	status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
+					                  US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
+					                  (1<<10)));
 
-    if (status != 0 ) {
-        TRACE_DEBUG("R:0x%" PRIX32 "\n\r", status); 
-        TRACE_DEBUG("R:0x%" PRIX32 "\n\r", us_base->US_CSR);
-        TRACE_DEBUG("Nb:0x%" PRIX32 "\n\r", us_base->US_NER );
-        us_base->US_CR = US_CR_RSTSTA;
-    }
+	if (status != 0 ) {
+		TRACE_DEBUG("R:0x%" PRIX32 "\n\r", status); 
+		TRACE_DEBUG("R:0x%" PRIX32 "\n\r", us_base->US_CSR);
+		TRACE_DEBUG("Nb:0x%" PRIX32 "\n\r", us_base->US_NER );
+		us_base->US_CR = US_CR_RSTSTA;
+	}
 
-    /* Return status */
-    return( status );
+	/* Return status */
+	return( status );
 }
 
 
@@ -125,50 +125,50 @@
  */
 uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
 {
-    uint32_t status;
+	uint32_t status;
 
-    Usart *us_base = usart->base;
-    uint32_t us_id = usart->id;
+	Usart *us_base = usart->base;
+	uint32_t us_id = usart->id;
 
-    if( usart->state == USART_RCV ) {
-        us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
-        usart->state = USART_SEND;
-    }
+	if( usart->state == USART_RCV ) {
+		us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
+		usart->state = USART_SEND;
+	}
 
-    /* Wait USART ready for transmit */
-    int i = 0;
-    while((us_base->US_CSR & (US_CSR_TXRDY)) == 0)  {
-        i++;
-        if (!(i%1000000)) {
-            printf("s: %x ", us_base->US_CSR);
-            printf("s: %x\r\n", us_base->US_RHR & 0xFF);
-            us_base->US_CR = US_CR_RSTTX;
-            us_base->US_CR = US_CR_RSTRX;
-      }
-    }
-    /* There is no character in the US_THR */
+	/* Wait USART ready for transmit */
+	int i = 0;
+	while((us_base->US_CSR & (US_CSR_TXRDY)) == 0)  {
+		i++;
+		if (!(i%1000000)) {
+			printf("s: %x ", us_base->US_CSR);
+			printf("s: %x\r\n", us_base->US_RHR & 0xFF);
+			us_base->US_CR = US_CR_RSTTX;
+			us_base->US_CR = US_CR_RSTRX;
+	  }
+	}
+	/* There is no character in the US_THR */
 
-    /* Transmit a char */
-    us_base->US_THR = CharToSend;
+	/* Transmit a char */
+	us_base->US_THR = CharToSend;
 
-    TRACE_ERROR("Sx%02X\r\n", CharToSend);
+	TRACE_ERROR("Sx%02X\r\n", CharToSend);
 
-    status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
-                                      US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
-                                      (1<<10)));
+	status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
+					                  US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
+					                  (1<<10)));
 
-    if (status != 0 ) {
-        TRACE_INFO("******* status: 0x%" PRIX32 " (Overrun: %" PRIX32
-                    ", NACK: %" PRIX32 ", Timeout: %" PRIX32 ", underrun: %" PRIX32 ")\n\r",
-                    status, ((status & US_CSR_OVRE)>> 5), ((status & US_CSR_NACK) >> 13),
-                    ((status & US_CSR_TIMEOUT) >> 8), ((status & (1 << 10)) >> 10));
-        TRACE_INFO("E (USART CSR reg):0x%" PRIX32 "\n\r", us_base->US_CSR);
-        TRACE_INFO("Nb (Number of errors):0x%" PRIX32 "\n\r", us_base->US_NER );
-        us_base->US_CR = US_CR_RSTSTA;
-    }
+	if (status != 0 ) {
+		TRACE_INFO("******* status: 0x%" PRIX32 " (Overrun: %" PRIX32
+					", NACK: %" PRIX32 ", Timeout: %" PRIX32 ", underrun: %" PRIX32 ")\n\r",
+					status, ((status & US_CSR_OVRE)>> 5), ((status & US_CSR_NACK) >> 13),
+					((status & US_CSR_TIMEOUT) >> 8), ((status & (1 << 10)) >> 10));
+		TRACE_INFO("E (USART CSR reg):0x%" PRIX32 "\n\r", us_base->US_CSR);
+		TRACE_INFO("Nb (Number of errors):0x%" PRIX32 "\n\r", us_base->US_NER );
+		us_base->US_CR = US_CR_RSTSTA;
+	}
 
-    /* Return status */
-    return( status );
+	/* Return status */
+	return( status );
 }
 
 
@@ -177,10 +177,10 @@
  */
 static void ISO7816_IccPowerOn( void )
 {
-    /* Set RESET Master Card */
-    if (st_pinIso7816RstMC) {
-        PIO_Set(st_pinIso7816RstMC);
-    }
+	/* Set RESET Master Card */
+	if (st_pinIso7816RstMC) {
+		PIO_Set(st_pinIso7816RstMC);
+	}
 }
 
 /*----------------------------------------------------------------------------
@@ -192,10 +192,10 @@
  */
 void ISO7816_IccPowerOff( void )
 {
-    /* Clear RESET Master Card */
-    if (st_pinIso7816RstMC) {
-        PIO_Clear(st_pinIso7816RstMC);
-    }
+	/* Clear RESET Master Card */
+	if (st_pinIso7816RstMC) {
+		PIO_Clear(st_pinIso7816RstMC);
+	}
 }
 
 /**
@@ -207,159 +207,159 @@
  * \return              0 on success, content of US_CSR otherwise
  */
 uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU,
-                                        uint8_t *pMessage,
-                                        uint16_t wLength,
-                                        uint16_t *retlen )
+					                    uint8_t *pMessage,
+					                    uint16_t wLength,
+					                    uint16_t *retlen )
 {
-    uint16_t NeNc;
-    uint16_t indexApdu = 4;
-    uint16_t indexMsg = 0;
-    uint8_t SW1 = 0;
-    uint8_t procByte;
-    uint8_t cmdCase;
-    uint32_t status = 0;
+	uint16_t NeNc;
+	uint16_t indexApdu = 4;
+	uint16_t indexMsg = 0;
+	uint8_t SW1 = 0;
+	uint8_t procByte;
+	uint8_t cmdCase;
+	uint32_t status = 0;
 
-    TRACE_INFO("pAPDU[0]=0x%X\n\r",pAPDU[0]);
-    TRACE_INFO("pAPDU[1]=0x%X\n\r",pAPDU[1]);
-    TRACE_INFO("pAPDU[2]=0x%X\n\r",pAPDU[2]);
-    TRACE_INFO("pAPDU[3]=0x%X\n\r",pAPDU[3]);
-    TRACE_INFO("pAPDU[4]=0x%X\n\r",pAPDU[4]);
-    TRACE_INFO("pAPDU[5]=0x%X\n\r",pAPDU[5]);
-    TRACE_INFO("wlength=%d\n\r",wLength);
+	TRACE_INFO("pAPDU[0]=0x%X\n\r",pAPDU[0]);
+	TRACE_INFO("pAPDU[1]=0x%X\n\r",pAPDU[1]);
+	TRACE_INFO("pAPDU[2]=0x%X\n\r",pAPDU[2]);
+	TRACE_INFO("pAPDU[3]=0x%X\n\r",pAPDU[3]);
+	TRACE_INFO("pAPDU[4]=0x%X\n\r",pAPDU[4]);
+	TRACE_INFO("pAPDU[5]=0x%X\n\r",pAPDU[5]);
+	TRACE_INFO("wlength=%d\n\r",wLength);
 
-    ISO7816_SendChar( pAPDU[0], &usart_sim ); /* CLA */
-    ISO7816_SendChar( pAPDU[1], &usart_sim ); /* INS */
-    ISO7816_SendChar( pAPDU[2], &usart_sim ); /* P1 */
-    ISO7816_SendChar( pAPDU[3], &usart_sim ); /* P2 */
-    ISO7816_SendChar( pAPDU[4], &usart_sim ); /* P3 */
+	ISO7816_SendChar( pAPDU[0], &usart_sim ); /* CLA */
+	ISO7816_SendChar( pAPDU[1], &usart_sim ); /* INS */
+	ISO7816_SendChar( pAPDU[2], &usart_sim ); /* P1 */
+	ISO7816_SendChar( pAPDU[3], &usart_sim ); /* P2 */
+	ISO7816_SendChar( pAPDU[4], &usart_sim ); /* P3 */
 
-    /* Handle the four structures of command APDU */
-    indexApdu = 5;
+	/* Handle the four structures of command APDU */
+	indexApdu = 5;
 
-    if( wLength == 4 ) {
-        cmdCase = CASE1;
-        NeNc = 0;
-    }
-    else if( wLength == 5) {
-        cmdCase = CASE2;
-        NeNc = pAPDU[4]; /* C5 */
-        if (NeNc == 0) {
-            NeNc = 256;
-        }
-    }
-    else if( wLength == 6) {
-        NeNc = pAPDU[4]; /* C5 */
-        cmdCase = CASE3;
-    }
-    else if( wLength == 7) {
-        NeNc = pAPDU[4]; /* C5 */
-        if( NeNc == 0 ) {
-            cmdCase = CASE2;
-            NeNc = (pAPDU[5]<<8)+pAPDU[6];
-        }
-        else {
-            cmdCase = CASE3;
-        }
-    }
-    else {
-        NeNc = pAPDU[4]; /* C5 */
-        if( NeNc == 0 ) {
-            cmdCase = CASE3;
-            NeNc = (pAPDU[5]<<8)+pAPDU[6];
-        }
-        else {
-            cmdCase = CASE3;
-        }
-    }
+	if( wLength == 4 ) {
+		cmdCase = CASE1;
+		NeNc = 0;
+	}
+	else if( wLength == 5) {
+		cmdCase = CASE2;
+		NeNc = pAPDU[4]; /* C5 */
+		if (NeNc == 0) {
+			NeNc = 256;
+		}
+	}
+	else if( wLength == 6) {
+		NeNc = pAPDU[4]; /* C5 */
+		cmdCase = CASE3;
+	}
+	else if( wLength == 7) {
+		NeNc = pAPDU[4]; /* C5 */
+		if( NeNc == 0 ) {
+			cmdCase = CASE2;
+			NeNc = (pAPDU[5]<<8)+pAPDU[6];
+		}
+		else {
+			cmdCase = CASE3;
+		}
+	}
+	else {
+		NeNc = pAPDU[4]; /* C5 */
+		if( NeNc == 0 ) {
+			cmdCase = CASE3;
+			NeNc = (pAPDU[5]<<8)+pAPDU[6];
+		}
+		else {
+			cmdCase = CASE3;
+		}
+	}
 
-    TRACE_DEBUG("CASE=0x%X NeNc=0x%X\n\r", cmdCase, NeNc);
+	TRACE_DEBUG("CASE=0x%X NeNc=0x%X\n\r", cmdCase, NeNc);
 
-    /* Handle Procedure Bytes */
-    do {
-        status = ISO7816_GetChar(&procByte, &usart_sim);
-        if (status != 0) {
-            return status;
-        }
-        TRACE_INFO("procByte: 0x%X\n\r", procByte);
-        /* Handle NULL */
-        if ( procByte == ISO_NULL_VAL ) {
-            TRACE_INFO("INS\n\r");
-            continue;
-        }
-        /* Handle SW1 */
-        else if ( ((procByte & 0xF0) ==0x60) || ((procByte & 0xF0) ==0x90) ) {
-            TRACE_INFO("SW1\n\r");
-            SW1 = 1;
-        }
-        /* Handle INS */
-        else if ( pAPDU[1] == procByte) {
-            TRACE_INFO("HdlINS\n\r");
-            if (cmdCase == CASE2) {
-                /* receive data from card */
-                do {
-                    status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim);
-                } while(( 0 != --NeNc) && (status == 0) );
-                if (status != 0) {
-                    return status;
-                }
-            }
-            else {
-                 /* Send data */
-                do {
-                    TRACE_INFO("Send %X", pAPDU[indexApdu]);
-                    ISO7816_SendChar(pAPDU[indexApdu++], &usart_sim);
-                } while( 0 != --NeNc );
-            }
-        }
-        /* Handle INS ^ 0xff */
-        else
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wsign-compare"
-        if ( pAPDU[1] == (procByte ^ 0xff)) {
-        #pragma GCC diagnostic pop
-            TRACE_INFO("HdlINS+\n\r");
-            if (cmdCase == CASE2) {
-                /* receive data from card */
-                status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim);
-                if (status != 0) {
-                    return status;
-                }
-                TRACE_INFO("Rcv: 0x%X\n\r", pMessage[indexMsg-1]);
-            }
-            else {
-                status = ISO7816_SendChar(pAPDU[indexApdu++], &usart_sim);
-                if (status != 0) {
-                    return status;
-                }
-            }
-            NeNc--;
-        }
-        else {
-            /* ?? */
-            TRACE_INFO("procByte=0x%X\n\r", procByte);
-            break;
-        }
-    } while (NeNc != 0);
+	/* Handle Procedure Bytes */
+	do {
+		status = ISO7816_GetChar(&procByte, &usart_sim);
+		if (status != 0) {
+			return status;
+		}
+		TRACE_INFO("procByte: 0x%X\n\r", procByte);
+		/* Handle NULL */
+		if ( procByte == ISO_NULL_VAL ) {
+			TRACE_INFO("INS\n\r");
+			continue;
+		}
+		/* Handle SW1 */
+		else if ( ((procByte & 0xF0) ==0x60) || ((procByte & 0xF0) ==0x90) ) {
+			TRACE_INFO("SW1\n\r");
+			SW1 = 1;
+		}
+		/* Handle INS */
+		else if ( pAPDU[1] == procByte) {
+			TRACE_INFO("HdlINS\n\r");
+			if (cmdCase == CASE2) {
+				/* receive data from card */
+				do {
+					status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim);
+				} while(( 0 != --NeNc) && (status == 0) );
+				if (status != 0) {
+					return status;
+				}
+			}
+			else {
+				 /* Send data */
+				do {
+					TRACE_INFO("Send %X", pAPDU[indexApdu]);
+					ISO7816_SendChar(pAPDU[indexApdu++], &usart_sim);
+				} while( 0 != --NeNc );
+			}
+		}
+		/* Handle INS ^ 0xff */
+		else
+		#pragma GCC diagnostic push
+		#pragma GCC diagnostic ignored "-Wsign-compare"
+		if ( pAPDU[1] == (procByte ^ 0xff)) {
+		#pragma GCC diagnostic pop
+			TRACE_INFO("HdlINS+\n\r");
+			if (cmdCase == CASE2) {
+				/* receive data from card */
+				status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim);
+				if (status != 0) {
+					return status;
+				}
+				TRACE_INFO("Rcv: 0x%X\n\r", pMessage[indexMsg-1]);
+			}
+			else {
+				status = ISO7816_SendChar(pAPDU[indexApdu++], &usart_sim);
+				if (status != 0) {
+					return status;
+				}
+			}
+			NeNc--;
+		}
+		else {
+			/* ?? */
+			TRACE_INFO("procByte=0x%X\n\r", procByte);
+			break;
+		}
+	} while (NeNc != 0);
 
-    /* Status Bytes */
-    if (SW1 == 0) {
-        status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim); /* SW1 */
-        if (status != 0) {
-            return status;
-        }
-    }
-    else {
-        pMessage[indexMsg++] = procByte;
-    }
-    status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim); /* SW2 */
-    if (status != 0) {
-        return status;
-    }
+	/* Status Bytes */
+	if (SW1 == 0) {
+		status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim); /* SW1 */
+		if (status != 0) {
+			return status;
+		}
+	}
+	else {
+		pMessage[indexMsg++] = procByte;
+	}
+	status = ISO7816_GetChar(&pMessage[indexMsg++], &usart_sim); /* SW2 */
+	if (status != 0) {
+		return status;
+	}
 
-    TRACE_WARNING("SW1=0x%X, SW2=0x%X\n\r", pMessage[indexMsg-2], pMessage[indexMsg-1]);
+	TRACE_WARNING("SW1=0x%X, SW2=0x%X\n\r", pMessage[indexMsg-2], pMessage[indexMsg-1]);
 
-    *retlen = indexMsg;
-    return status;
+	*retlen = indexMsg;
+	return status;
 
 }
 
@@ -368,7 +368,7 @@
  */
 void ISO7816_Escape( void )
 {
-    TRACE_DEBUG("For user, if needed\n\r");
+	TRACE_DEBUG("For user, if needed\n\r");
 }
 
 /**
@@ -376,8 +376,8 @@
  */
 void ISO7816_RestartClock( void )
 {
-    TRACE_DEBUG("ISO7816_RestartClock\n\r");
-    USART_SIM->US_BRGR = 13;
+	TRACE_DEBUG("ISO7816_RestartClock\n\r");
+	USART_SIM->US_BRGR = 13;
 }
 
 /**
@@ -385,8 +385,8 @@
  */
 void ISO7816_StopClock( void )
 {
-    TRACE_DEBUG("ISO7816_StopClock\n\r");
-    USART_SIM->US_BRGR = 0;
+	TRACE_DEBUG("ISO7816_StopClock\n\r");
+	USART_SIM->US_BRGR = 0;
 }
 
 /**
@@ -394,8 +394,8 @@
  */
 void ISO7816_toAPDU( void )
 {
-    TRACE_DEBUG("ISO7816_toAPDU\n\r");
-    TRACE_DEBUG("Not supported at this time\n\r");
+	TRACE_DEBUG("ISO7816_toAPDU\n\r");
+	TRACE_DEBUG("Not supported at this time\n\r");
 }
 
 /**
@@ -406,64 +406,64 @@
  */
 uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength )
 {
-    uint32_t i;
-    uint32_t j;
-    uint32_t y;
-    uint32_t status = 0; 
+	uint32_t i;
+	uint32_t j;
+	uint32_t y;
+	uint32_t status = 0; 
 
-    *pLength = 0;
+	*pLength = 0;
 
-    /* Read ATR TS */
-    // FIXME: There should always be a check for the GetChar return value..0 means timeout
-    status = ISO7816_GetChar(&pAtr[0], &usart_sim);
-    if (status != 0) {
-        return status;
-    }
+	/* Read ATR TS */
+	// FIXME: There should always be a check for the GetChar return value..0 means timeout
+	status = ISO7816_GetChar(&pAtr[0], &usart_sim);
+	if (status != 0) {
+		return status;
+	}
 
-    /* Read ATR T0 */
-    status = ISO7816_GetChar(&pAtr[1], &usart_sim);
-    if (status != 0) {
-        return status;
-    }
-    y = pAtr[1] & 0xF0;
-    i = 2;
+	/* Read ATR T0 */
+	status = ISO7816_GetChar(&pAtr[1], &usart_sim);
+	if (status != 0) {
+		return status;
+	}
+	y = pAtr[1] & 0xF0;
+	i = 2;
 
-    /* Read ATR Ti */
-    while (y && (status == 0)) {
+	/* Read ATR Ti */
+	while (y && (status == 0)) {
 
-        if (y & 0x10) {  /* TA[i] */
-            status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
-        }
-        if (y & 0x20) {  /* TB[i] */
-            status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
-        }
-        if (y & 0x40) {  /* TC[i] */
-            status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
-        }
-        if (y & 0x80) {  /* TD[i] */
-            status = ISO7816_GetChar(&pAtr[i], &usart_sim);
-            y =  pAtr[i++] & 0xF0;
-        }
-        else {
-            y = 0;
-        }
-    }
-    if (status != 0) {
-        return status;
-    }
+		if (y & 0x10) {  /* TA[i] */
+			status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
+		}
+		if (y & 0x20) {  /* TB[i] */
+			status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
+		}
+		if (y & 0x40) {  /* TC[i] */
+			status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
+		}
+		if (y & 0x80) {  /* TD[i] */
+			status = ISO7816_GetChar(&pAtr[i], &usart_sim);
+			y =  pAtr[i++] & 0xF0;
+		}
+		else {
+			y = 0;
+		}
+	}
+	if (status != 0) {
+		return status;
+	}
 
-    /* Historical Bytes */
-    y = pAtr[1] & 0x0F;
-    for( j=0; (j < y) && (status == 0); j++ ) {
-        status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
-    }
+	/* Historical Bytes */
+	y = pAtr[1] & 0x0F;
+	for( j=0; (j < y) && (status == 0); j++ ) {
+		status = ISO7816_GetChar(&pAtr[i++], &usart_sim);
+	}
 
-    if (status != 0) {
-        return status;
-    }
+	if (status != 0) {
+		return status;
+	}
 
-    *pLength = i;
-    return status;
+	*pLength = i;
+	return status;
 }
 
 /**
@@ -473,18 +473,18 @@
  */
 void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate )
 {
-    uint8_t ClockFrequency;
+	uint8_t ClockFrequency;
 
-    /* Define the baud rate divisor register */
-    /* CD  = MCK / SCK */
-    /* SCK = FIDI x BAUD = 372 x 9600 */
-    /* BOARD_MCK */
-    /* CD = MCK/(FIDI x BAUD) = 48000000 / (372x9600) = 13 */
-    USART_SIM->US_BRGR = BOARD_MCK / (dwClockFrequency*1000);
+	/* Define the baud rate divisor register */
+	/* CD  = MCK / SCK */
+	/* SCK = FIDI x BAUD = 372 x 9600 */
+	/* BOARD_MCK */
+	/* CD = MCK/(FIDI x BAUD) = 48000000 / (372x9600) = 13 */
+	USART_SIM->US_BRGR = BOARD_MCK / (dwClockFrequency*1000);
 
-    ClockFrequency = BOARD_MCK / USART_SIM->US_BRGR;
+	ClockFrequency = BOARD_MCK / USART_SIM->US_BRGR;
 
-    USART_SIM->US_FIDI = (ClockFrequency)/dwDataRate;
+	USART_SIM->US_FIDI = (ClockFrequency)/dwDataRate;
 
 }
 
@@ -494,10 +494,10 @@
  */
 uint8_t ISO7816_StatusReset( void )
 {
-    if (st_pinIso7816RstMC) {
-        return PIO_Get(st_pinIso7816RstMC);
-    }
-    return 0;
+	if (st_pinIso7816RstMC) {
+		return PIO_Get(st_pinIso7816RstMC);
+	}
+	return 0;
 }
 
 /**
@@ -505,16 +505,16 @@
  */
 void ISO7816_cold_reset( void )
 {
-    volatile uint32_t i;
+	volatile uint32_t i;
 
-    /* tb: wait ??? cycles*/
-    for( i=0; i<(400*(BOARD_MCK/1000000)); i++ ) {
-    }
+	/* tb: wait ??? cycles*/
+	for( i=0; i<(400*(BOARD_MCK/1000000)); i++ ) {
+	}
 
-    USART_SIM->US_RHR;
-    USART_SIM->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
+	USART_SIM->US_RHR;
+	USART_SIM->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
 
-    ISO7816_IccPowerOn();
+	ISO7816_IccPowerOn();
 }
 
 /**
@@ -522,20 +522,20 @@
  */
 void ISO7816_warm_reset( void )
 {
-    volatile uint32_t i;
+	volatile uint32_t i;
 
 // Clears Reset
-    ISO7816_IccPowerOff();
+	ISO7816_IccPowerOff();
 
-    /* tb: wait ??? cycles */
-    for( i=0; i<(400*(BOARD_MCK/1000000)); i++ ) {
-    }
+	/* tb: wait ??? cycles */
+	for( i=0; i<(400*(BOARD_MCK/1000000)); i++ ) {
+	}
 
-    USART_SIM->US_RHR;
-    USART_SIM->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
+	USART_SIM->US_RHR;
+	USART_SIM->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
 
 // Sets Reset
-    ISO7816_IccPowerOn();
+	ISO7816_IccPowerOn();
 }
 
 /**
@@ -544,99 +544,99 @@
  */
 void ISO7816_Decode_ATR( uint8_t* pAtr )
 {
-    uint32_t i;
-    uint32_t j;
-    uint32_t y;
-    uint8_t offset;
+	uint32_t i;
+	uint32_t j;
+	uint32_t y;
+	uint8_t offset;
 
-    printf("\n\r");
-    printf("ATR: Answer To Reset:\n\r");
-    printf("TS = 0x%X Initial character ",pAtr[0]);
-    if( pAtr[0] == 0x3B ) {
+	printf("\n\r");
+	printf("ATR: Answer To Reset:\n\r");
+	printf("TS = 0x%X Initial character ",pAtr[0]);
+	if( pAtr[0] == 0x3B ) {
 
-        printf("Direct Convention\n\r");
-    }
-    else {
-        if( pAtr[0] == 0x3F ) {
+		printf("Direct Convention\n\r");
+	}
+	else {
+		if( pAtr[0] == 0x3F ) {
 
-            printf("Inverse Convention\n\r");
-        }
-        else {
-            printf("BAD Convention\n\r");
-        }
-    }
+			printf("Inverse Convention\n\r");
+		}
+		else {
+			printf("BAD Convention\n\r");
+		}
+	}
 
-    printf("T0 = 0x%X Format caracter\n\r",pAtr[1]);
-    printf("    Number of historical bytes: K = %d\n\r", pAtr[1]&0x0F);
-    printf("    Presence further interface byte:\n\r");
-    if( pAtr[1]&0x80 ) {
-        printf("TA ");
-    }
-    if( pAtr[1]&0x40 ) {
-        printf("TB ");
-    }
-    if( pAtr[1]&0x20 ) {
-        printf("TC ");
-    }
-    if( pAtr[1]&0x10 ) {
-        printf("TD ");
-    }
-    if( pAtr[1] != 0 ) {
-        printf(" present\n\r");
-    }
+	printf("T0 = 0x%X Format caracter\n\r",pAtr[1]);
+	printf("    Number of historical bytes: K = %d\n\r", pAtr[1]&0x0F);
+	printf("    Presence further interface byte:\n\r");
+	if( pAtr[1]&0x80 ) {
+		printf("TA ");
+	}
+	if( pAtr[1]&0x40 ) {
+		printf("TB ");
+	}
+	if( pAtr[1]&0x20 ) {
+		printf("TC ");
+	}
+	if( pAtr[1]&0x10 ) {
+		printf("TD ");
+	}
+	if( pAtr[1] != 0 ) {
+		printf(" present\n\r");
+	}
 
-    i = 2;
-    y = pAtr[1] & 0xF0;
+	i = 2;
+	y = pAtr[1] & 0xF0;
 
-    /* Read ATR Ti */
-    offset = 1;
-    while (y) {
+	/* Read ATR Ti */
+	offset = 1;
+	while (y) {
 
-        if (y & 0x10) {  /* TA[i] */
-            printf("TA[%d] = 0x%X ", offset, pAtr[i]);
-            if( offset == 1 ) {
-                printf("FI = %d ", (pAtr[i]>>8));
-                printf("DI = %d", (pAtr[i]&0x0F));
-            }
-            printf("\n\r");
-            i++;
-        }
-        if (y & 0x20) {  /* TB[i] */
-            printf("TB[%d] = 0x%X\n\r", offset, pAtr[i]);
-            i++;
-        }
-        if (y & 0x40) {  /* TC[i] */
-            printf("TC[%d] = 0x%X ", offset, pAtr[i]);
-            if( offset == 1 ) {
-                printf("Extra Guard Time: N = %d", pAtr[i]);
-            }
-            printf("\n\r");
-            i++;
-        }
-        if (y & 0x80) {  /* TD[i] */
-            printf("TD[%d] = 0x%X\n\r", offset, pAtr[i]);
-            y =  pAtr[i++] & 0xF0;
-        }
-        else {
-            y = 0;
-        }
-        offset++;
-    }
+		if (y & 0x10) {  /* TA[i] */
+			printf("TA[%d] = 0x%X ", offset, pAtr[i]);
+			if( offset == 1 ) {
+				printf("FI = %d ", (pAtr[i]>>8));
+				printf("DI = %d", (pAtr[i]&0x0F));
+			}
+			printf("\n\r");
+			i++;
+		}
+		if (y & 0x20) {  /* TB[i] */
+			printf("TB[%d] = 0x%X\n\r", offset, pAtr[i]);
+			i++;
+		}
+		if (y & 0x40) {  /* TC[i] */
+			printf("TC[%d] = 0x%X ", offset, pAtr[i]);
+			if( offset == 1 ) {
+				printf("Extra Guard Time: N = %d", pAtr[i]);
+			}
+			printf("\n\r");
+			i++;
+		}
+		if (y & 0x80) {  /* TD[i] */
+			printf("TD[%d] = 0x%X\n\r", offset, pAtr[i]);
+			y =  pAtr[i++] & 0xF0;
+		}
+		else {
+			y = 0;
+		}
+		offset++;
+	}
 
-    /* Historical Bytes */
-    printf("Historical bytes:\n\r");
-    y = pAtr[1] & 0x0F;
-    for( j=0; j < y; j++ ) {
-        printf(" 0x%X", pAtr[i]);
-        i++;
-    }
-    printf("\n\r\n\r");
+	/* Historical Bytes */
+	printf("Historical bytes:\n\r");
+	y = pAtr[1] & 0x0F;
+	for( j=0; j < y; j++ ) {
+		printf(" 0x%X", pAtr[i]);
+		i++;
+	}
+	printf("\n\r\n\r");
 
 }
 
 void ISO7816_Set_Reset_Pin(const Pin *pPinIso7816RstMC) {
-    /* Pin ISO7816 initialize */
-    st_pinIso7816RstMC  = (Pin *)pPinIso7816RstMC;
+	/* Pin ISO7816 initialize */
+	st_pinIso7816RstMC  = (Pin *)pPinIso7816RstMC;
 }
 
 /** Initializes a ISO driver
@@ -644,46 +644,46 @@
  */
 void ISO7816_Init( Usart_info *usart, bool master_clock )
 {
-    uint32_t clk;
-    TRACE_DEBUG("ISO_Init\n\r");
+	uint32_t clk;
+	TRACE_DEBUG("ISO_Init\n\r");
 
-    Usart *us_base = usart->base;
-    uint32_t us_id = usart->id;
+	Usart *us_base = usart->base;
+	uint32_t us_id = usart->id;
 
-    if (master_clock == true) {
-        clk = US_MR_USCLKS_MCK;
-    } else {
-        clk = US_MR_USCLKS_SCK;
-    }
+	if (master_clock == true) {
+		clk = US_MR_USCLKS_MCK;
+	} else {
+		clk = US_MR_USCLKS_SCK;
+	}
 
-    USART_Configure( us_base,
-                     US_MR_USART_MODE_IS07816_T_0
-                     | clk
-                     | US_MR_NBSTOP_1_BIT
-                     | US_MR_PAR_EVEN
-                     | US_MR_CHRL_8_BIT
-                     | US_MR_CLKO
-                     | US_MR_INACK  /* Inhibit errors */
-                     | (3<<24), /* MAX_ITERATION */
-                     1,
-                     0);
+	USART_Configure( us_base,
+					 US_MR_USART_MODE_IS07816_T_0
+					 | clk
+					 | US_MR_NBSTOP_1_BIT
+					 | US_MR_PAR_EVEN
+					 | US_MR_CHRL_8_BIT
+					 | US_MR_CLKO
+					 | US_MR_INACK  /* Inhibit errors */
+					 | (3<<24), /* MAX_ITERATION */
+					 1,
+					 0);
 
-    /* Disable interrupts */
-    us_base->US_IDR = (uint32_t) -1;
+	/* Disable interrupts */
+	us_base->US_IDR = (uint32_t) -1;
 
-    /* Configure USART */
-    PMC_EnablePeripheral(us_id);
+	/* Configure USART */
+	PMC_EnablePeripheral(us_id);
 
-    us_base->US_FIDI = 372;  /* by default */
-    /* Define the baud rate divisor register */
-    /* CD  = MCK / SCK */
-    /* SCK = FIDI x BAUD = 372 x 9600 */
-    /* BOARD_MCK */
-    /* CD = MCK/(FIDI x BAUD) = 48000000 / (372x9600) = 13 */
-    if (master_clock == true) {
-        us_base->US_BRGR = BOARD_MCK / (372*9600);
-    } else {
-        us_base->US_BRGR = US_BRGR_CD(1);
-    }
+	us_base->US_FIDI = 372;  /* by default */
+	/* Define the baud rate divisor register */
+	/* CD  = MCK / SCK */
+	/* SCK = FIDI x BAUD = 372 x 9600 */
+	/* BOARD_MCK */
+	/* CD = MCK/(FIDI x BAUD) = 48000000 / (372x9600) = 13 */
+	if (master_clock == true) {
+		us_base->US_BRGR = BOARD_MCK / (372*9600);
+	} else {
+		us_base->US_BRGR = US_BRGR_CD(1);
+	}
 }
 
diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c
index bc91273..c7362cf 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -202,7 +202,7 @@
 	csr = usart->US_CSR & usart->US_IMR;
 
 	if (csr & US_CSR_RXRDY) {
-        	byte = (usart->US_RHR) & 0xFF;
+			byte = (usart->US_RHR) & 0xFF;
 		if (rbuf_write(&ci->rb, byte) < 0)
 			TRACE_ERROR("rbuf overrun\r\n");
 	}
diff --git a/firmware/libcommon/source/mode_ccid.c b/firmware/libcommon/source/mode_ccid.c
index 77d4158..516826e 100644
--- a/firmware/libcommon/source/mode_ccid.c
+++ b/firmware/libcommon/source/mode_ccid.c
@@ -84,11 +84,11 @@
 static void ISR_PioSmartCard(const Pin * pPin)
 {
 /* FIXME: why is pinSmartCard.pio->PIO_ISR the wrong number?
-    printf("+++++ Trying to check for pending interrupts (PIO ISR: 0x%X)\n\r", pinSmartCard.pio->PIO_ISR);
-    printf("+++++ Mask: 0x%X\n\r", pinSmartCard.mask);
+	printf("+++++ Trying to check for pending interrupts (PIO ISR: 0x%X)\n\r", pinSmartCard.pio->PIO_ISR);
+	printf("+++++ Mask: 0x%X\n\r", pinSmartCard.mask);
 Output:
-    +++++ Trying to check for pending interrupts (PIO ISR: 0x400)) = 1<<10
-    +++++ Mask: 0x100 = 1<<8
+	+++++ Trying to check for pending interrupts (PIO ISR: 0x400)) = 1<<10
+	+++++ Mask: 0x100 = 1<<8
 */
 	// PA10 is DTXD, which is the debug uart transmit pin
 
diff --git a/firmware/libcommon/source/stdio.c b/firmware/libcommon/source/stdio.c
index 32bd617..505c895 100644
--- a/firmware/libcommon/source/stdio.c
+++ b/firmware/libcommon/source/stdio.c
@@ -76,8 +76,8 @@
 //------------------------------------------------------------------------------
 signed int PutChar(char *pStr, char c)
 {
-    *pStr = c;
-    return 1;
+	*pStr = c;
+	return 1;
 }
 
 //------------------------------------------------------------------------------
@@ -89,15 +89,15 @@
 //------------------------------------------------------------------------------
 signed int PutString(char *pStr, const char *pSource)
 {
-    signed int num = 0;
+	signed int num = 0;
 
-    while (*pSource != 0) {
+	while (*pSource != 0) {
 
-        *pStr++ = *pSource++;
-        num++;
-    }
+		*pStr++ = *pSource++;
+		num++;
+	}
 
-    return num;
+	return num;
 }
 
 //------------------------------------------------------------------------------
@@ -110,38 +110,38 @@
 // \param value  Integer value.
 //------------------------------------------------------------------------------
 signed int PutUnsignedInt(
-    char *pStr,
-    char fill,
-    signed int width,
-    unsigned int value)
+	char *pStr,
+	char fill,
+	signed int width,
+	unsigned int value)
 {
-    signed int num = 0;
+	signed int num = 0;
 
-    // Take current digit into account when calculating width
-    width--;
+	// Take current digit into account when calculating width
+	width--;
 
-    // Recursively write upper digits
-    if ((value / 10) > 0) {
+	// Recursively write upper digits
+	if ((value / 10) > 0) {
 
-        num = PutUnsignedInt(pStr, fill, width, value / 10);
-        pStr += num;
-    }
-    // Write filler characters
-    else {
+		num = PutUnsignedInt(pStr, fill, width, value / 10);
+		pStr += num;
+	}
+	// Write filler characters
+	else {
 
-        while (width > 0) {
+		while (width > 0) {
 
-            PutChar(pStr, fill);
-            pStr++;
-            num++;
-            width--;
-        }
-    }
+			PutChar(pStr, fill);
+			pStr++;
+			num++;
+			width--;
+		}
+	}
 
-    // Write lower digit
-    num += PutChar(pStr, (value % 10) + '0');
+	// Write lower digit
+	num += PutChar(pStr, (value % 10) + '0');
 
-    return num;
+	return num;
 }
 
 //------------------------------------------------------------------------------
@@ -154,69 +154,69 @@
 // \param value  Signed integer value.
 //------------------------------------------------------------------------------
 signed int PutSignedInt(
-    char *pStr,
-    char fill,
-    signed int width,
-    signed int value)
+	char *pStr,
+	char fill,
+	signed int width,
+	signed int value)
 {
-    signed int num = 0;
-    unsigned int absolute;
+	signed int num = 0;
+	unsigned int absolute;
 
-    // Compute absolute value
-    if (value < 0) {
+	// Compute absolute value
+	if (value < 0) {
 
-        absolute = -value;
-    }
-    else {
+		absolute = -value;
+	}
+	else {
 
-        absolute = value;
-    }
+		absolute = value;
+	}
 
-    // Take current digit into account when calculating width
-    width--;
+	// Take current digit into account when calculating width
+	width--;
 
-    // Recursively write upper digits
-    if ((absolute / 10) > 0) {
+	// Recursively write upper digits
+	if ((absolute / 10) > 0) {
 
-        if (value < 0) {
-        
-            num = PutSignedInt(pStr, fill, width, -(absolute / 10));
-        }
-        else {
+		if (value < 0) {
+		
+			num = PutSignedInt(pStr, fill, width, -(absolute / 10));
+		}
+		else {
 
-            num = PutSignedInt(pStr, fill, width, absolute / 10);
-        }
-        pStr += num;
-    }
-    else {
+			num = PutSignedInt(pStr, fill, width, absolute / 10);
+		}
+		pStr += num;
+	}
+	else {
 
-        // Reserve space for sign
-        if (value < 0) {
+		// Reserve space for sign
+		if (value < 0) {
 
-            width--;
-        }
+			width--;
+		}
 
-        // Write filler characters
-        while (width > 0) {
+		// Write filler characters
+		while (width > 0) {
 
-            PutChar(pStr, fill);
-            pStr++;
-            num++;
-            width--;
-        }
+			PutChar(pStr, fill);
+			pStr++;
+			num++;
+			width--;
+		}
 
-        // Write sign
-        if (value < 0) {
+		// Write sign
+		if (value < 0) {
 
-            num += PutChar(pStr, '-');
-            pStr++;
-        }
-    }
+			num += PutChar(pStr, '-');
+			pStr++;
+		}
+	}
 
-    // Write lower digit
-    num += PutChar(pStr, (absolute % 10) + '0');
+	// Write lower digit
+	num += PutChar(pStr, (absolute % 10) + '0');
 
-    return num;
+	return num;
 }
 
 //------------------------------------------------------------------------------
@@ -230,51 +230,51 @@
 // \param value  Hexadecimal value.
 //------------------------------------------------------------------------------
 signed int PutHexa(
-    char *pStr,
-    char fill,
-    signed int width,
-    unsigned char maj,
-    unsigned int value)
+	char *pStr,
+	char fill,
+	signed int width,
+	unsigned char maj,
+	unsigned int value)
 {
-    signed int num = 0;
+	signed int num = 0;
 
-    // Decrement width
-    width--;
+	// Decrement width
+	width--;
 
-    // Recursively output upper digits
-    if ((value >> 4) > 0) {
+	// Recursively output upper digits
+	if ((value >> 4) > 0) {
 
-        num += PutHexa(pStr, fill, width, maj, value >> 4);
-        pStr += num;
-    }
-    // Write filler chars
-    else {
+		num += PutHexa(pStr, fill, width, maj, value >> 4);
+		pStr += num;
+	}
+	// Write filler chars
+	else {
 
-        while (width > 0) {
+		while (width > 0) {
 
-            PutChar(pStr, fill);
-            pStr++;
-            num++;
-            width--;
-        }
-    }
+			PutChar(pStr, fill);
+			pStr++;
+			num++;
+			width--;
+		}
+	}
 
-    // Write current digit
-    if ((value & 0xF) < 10) {
+	// Write current digit
+	if ((value & 0xF) < 10) {
 
-        PutChar(pStr, (value & 0xF) + '0');
-    }
-    else if (maj) {
+		PutChar(pStr, (value & 0xF) + '0');
+	}
+	else if (maj) {
 
-        PutChar(pStr, (value & 0xF) - 10 + 'A');
-    }
-    else {
+		PutChar(pStr, (value & 0xF) - 10 + 'A');
+	}
+	else {
 
-        PutChar(pStr, (value & 0xF) - 10 + 'a');
-    }
-    num++;
+		PutChar(pStr, (value & 0xF) - 10 + 'a');
+	}
+	num++;
 
-    return num;
+	return num;
 }
 
 //------------------------------------------------------------------------------
@@ -292,91 +292,91 @@
 //------------------------------------------------------------------------------
 signed int vsnprintf(char *pStr, size_t length, const char *pFormat, va_list ap)
 {
-    char          fill;
-    unsigned char width;
-    signed int    num = 0;
-    size_t        size = 0;
+	char          fill;
+	unsigned char width;
+	signed int    num = 0;
+	size_t        size = 0;
 
-    // Clear the string
-    if (pStr) {
+	// Clear the string
+	if (pStr) {
 
-        *pStr = 0;
-    }
+		*pStr = 0;
+	}
 
-    // Phase string
-    while (*pFormat != 0 && size < length) {
+	// Phase string
+	while (*pFormat != 0 && size < length) {
 
-        // Normal character
-        if (*pFormat != '%') {
+		// Normal character
+		if (*pFormat != '%') {
 
-            *pStr++ = *pFormat++;
-            size++;
-        }
-        // Escaped '%'
-        else if (*(pFormat+1) == '%') {
+			*pStr++ = *pFormat++;
+			size++;
+		}
+		// Escaped '%'
+		else if (*(pFormat+1) == '%') {
 
-            *pStr++ = '%';
-            pFormat += 2;
-            size++;
-        }
-        // Token delimiter
-        else {
+			*pStr++ = '%';
+			pFormat += 2;
+			size++;
+		}
+		// Token delimiter
+		else {
 
-            fill = ' ';
-            width = 0;
-            pFormat++;
+			fill = ' ';
+			width = 0;
+			pFormat++;
 
-            // Parse filler
-            if (*pFormat == '0') {
+			// Parse filler
+			if (*pFormat == '0') {
 
-                fill = '0';
-                pFormat++;
-            }
+				fill = '0';
+				pFormat++;
+			}
 
-            // Parse width
-            while ((*pFormat >= '0') && (*pFormat <= '9')) {
-        
-                width = (width*10) + *pFormat-'0';
-                pFormat++;
-            }
+			// Parse width
+			while ((*pFormat >= '0') && (*pFormat <= '9')) {
+		
+				width = (width*10) + *pFormat-'0';
+				pFormat++;
+			}
 
-            // Check if there is enough space
-            if (size + width > length) {
+			// Check if there is enough space
+			if (size + width > length) {
 
-                width = length - size;
-            }
-        
-            // Parse type
-            switch (*pFormat) {
-            case 'd': 
-            case 'i': num = PutSignedInt(pStr, fill, width, va_arg(ap, signed int)); break;
-            case 'u': num = PutUnsignedInt(pStr, fill, width, va_arg(ap, unsigned int)); break;
-            case 'x': num = PutHexa(pStr, fill, width, 0, va_arg(ap, unsigned int)); break;
-            case 'X': num = PutHexa(pStr, fill, width, 1, va_arg(ap, unsigned int)); break;
-            case 's': num = PutString(pStr, va_arg(ap, char *)); break;
-            case 'c': num = PutChar(pStr, va_arg(ap, unsigned int)); break;
-            default:
-                return EOF;
-            }
+				width = length - size;
+			}
+		
+			// Parse type
+			switch (*pFormat) {
+			case 'd': 
+			case 'i': num = PutSignedInt(pStr, fill, width, va_arg(ap, signed int)); break;
+			case 'u': num = PutUnsignedInt(pStr, fill, width, va_arg(ap, unsigned int)); break;
+			case 'x': num = PutHexa(pStr, fill, width, 0, va_arg(ap, unsigned int)); break;
+			case 'X': num = PutHexa(pStr, fill, width, 1, va_arg(ap, unsigned int)); break;
+			case 's': num = PutString(pStr, va_arg(ap, char *)); break;
+			case 'c': num = PutChar(pStr, va_arg(ap, unsigned int)); break;
+			default:
+				return EOF;
+			}
 
-            pFormat++;
-            pStr += num;
-            size += num;
-        }
-    }
+			pFormat++;
+			pStr += num;
+			size += num;
+		}
+	}
 
-    // NULL-terminated (final \0 is not counted)
-    if (size < length) {
+	// NULL-terminated (final \0 is not counted)
+	if (size < length) {
 
-        *pStr = 0;
-    }
-    else {
+		*pStr = 0;
+	}
+	else {
 
-        *(--pStr) = 0;
-        size--;
-    }
+		*(--pStr) = 0;
+		size--;
+	}
 
-    return size;
+	return size;
 }
 
 //------------------------------------------------------------------------------
@@ -390,14 +390,14 @@
 //------------------------------------------------------------------------------
 signed int snprintf(char *pString, size_t length, const char *pFormat, ...)
 {
-    va_list    ap;
-    signed int rc;
+	va_list    ap;
+	signed int rc;
 
-    va_start(ap, pFormat);
-    rc = vsnprintf(pString, length, pFormat, ap);
-    va_end(ap);
+	va_start(ap, pFormat);
+	rc = vsnprintf(pString, length, pFormat, ap);
+	va_end(ap);
 
-    return rc;
+	return rc;
 }
 
 //------------------------------------------------------------------------------
@@ -410,7 +410,7 @@
 //------------------------------------------------------------------------------
 signed int vsprintf(char *pString, const char *pFormat, va_list ap)
 {
-    return vsnprintf(pString, MAX_STRING_SIZE, pFormat, ap);
+	return vsnprintf(pString, MAX_STRING_SIZE, pFormat, ap);
 }
 
 //------------------------------------------------------------------------------
@@ -422,17 +422,17 @@
 //------------------------------------------------------------------------------
 signed int vfprintf(FILE *pStream, const char *pFormat, va_list ap)
 {
-    char pStr[MAX_STRING_SIZE];
-    char pError[] = "stdio.c: increase MAX_STRING_SIZE\n\r";
+	char pStr[MAX_STRING_SIZE];
+	char pError[] = "stdio.c: increase MAX_STRING_SIZE\n\r";
 
-    // Write formatted string in buffer
-    if (vsprintf(pStr, pFormat, ap) >= MAX_STRING_SIZE) {
+	// Write formatted string in buffer
+	if (vsprintf(pStr, pFormat, ap) >= MAX_STRING_SIZE) {
 
-        fputs(pError, stderr);
-    }
+		fputs(pError, stderr);
+	}
 
-    // Display string
-    return fputs(pStr, pStream);
+	// Display string
+	return fputs(pStr, pStream);
 }
 
 //------------------------------------------------------------------------------
@@ -443,7 +443,7 @@
 //------------------------------------------------------------------------------
 signed int vprintf(const char *pFormat, va_list ap)
 {
-    return vfprintf(stdout, pFormat, ap);
+	return vfprintf(stdout, pFormat, ap);
 }
 
 //------------------------------------------------------------------------------
@@ -454,15 +454,15 @@
 //------------------------------------------------------------------------------
 signed int fprintf(FILE *pStream, const char *pFormat, ...)
 {
-    va_list ap;
-    signed int result;
+	va_list ap;
+	signed int result;
 
-    // Forward call to vfprintf
-    va_start(ap, pFormat);
-    result = vfprintf(pStream, pFormat, ap);
-    va_end(ap);
+	// Forward call to vfprintf
+	va_start(ap, pFormat);
+	result = vfprintf(pStream, pFormat, ap);
+	va_end(ap);
 
-    return result;
+	return result;
 }
 
 //------------------------------------------------------------------------------
@@ -472,15 +472,15 @@
 //------------------------------------------------------------------------------
 signed int printf(const char *pFormat, ...)
 {
-    va_list ap;
-    signed int result;
+	va_list ap;
+	signed int result;
 
-    // Forward call to vprintf
-    va_start(ap, pFormat);
-    result = vprintf(pFormat, ap);
-    va_end(ap);
+	// Forward call to vprintf
+	va_start(ap, pFormat);
+	result = vprintf(pFormat, ap);
+	va_end(ap);
 
-    return result;
+	return result;
 }
 
 //------------------------------------------------------------------------------
@@ -490,15 +490,15 @@
 //------------------------------------------------------------------------------
 signed int sprintf(char *pStr, const char *pFormat, ...)
 {
-    va_list ap;
-    signed int result;
+	va_list ap;
+	signed int result;
 
-    // Forward call to vsprintf
-    va_start(ap, pFormat);
-    result = vsprintf(pStr, pFormat, ap);
-    va_end(ap);
+	// Forward call to vsprintf
+	va_start(ap, pFormat);
+	result = vsprintf(pStr, pFormat, ap);
+	va_end(ap);
 
-    return result;
+	return result;
 }
 
 //------------------------------------------------------------------------------
@@ -507,6 +507,6 @@
 //------------------------------------------------------------------------------
 signed int puts(const char *pStr)
 {
-    return fputs(pStr, stdout);
+	return fputs(pStr, stdout);
 }
 
diff --git a/firmware/libcommon/source/string.c b/firmware/libcommon/source/string.c
index dbbb0e9..0d789a0 100644
--- a/firmware/libcommon/source/string.c
+++ b/firmware/libcommon/source/string.c
@@ -61,33 +61,33 @@
 //------------------------------------------------------------------------------
 void * memcpy(void *pDestination, const void *pSource, size_t num)
 {
-    unsigned char *pByteDestination;
-    unsigned char *pByteSource;
-    unsigned int *pAlignedSource = (unsigned int *) pSource;
-    unsigned int *pAlignedDestination = (unsigned int *) pDestination;
+	unsigned char *pByteDestination;
+	unsigned char *pByteSource;
+	unsigned int *pAlignedSource = (unsigned int *) pSource;
+	unsigned int *pAlignedDestination = (unsigned int *) pDestination;
 
-    // If num is more than 4 bytes, and both dest. and source are aligned,
-    // then copy dwords
-    if ((((unsigned int) pAlignedDestination & 0x3) == 0)
-        && (((unsigned int) pAlignedSource & 0x3) == 0)
-        && (num >= 4)) {
+	// If num is more than 4 bytes, and both dest. and source are aligned,
+	// then copy dwords
+	if ((((unsigned int) pAlignedDestination & 0x3) == 0)
+		&& (((unsigned int) pAlignedSource & 0x3) == 0)
+		&& (num >= 4)) {
 
-        while (num >= 4) {
+		while (num >= 4) {
 
-            *pAlignedDestination++ = *pAlignedSource++;
-            num -= 4;
-        }
-    }
+			*pAlignedDestination++ = *pAlignedSource++;
+			num -= 4;
+		}
+	}
 
-    // Copy remaining bytes
-    pByteDestination = (unsigned char *) pAlignedDestination;
-    pByteSource = (unsigned char *) pAlignedSource;
-    while (num--) {
+	// Copy remaining bytes
+	pByteDestination = (unsigned char *) pAlignedDestination;
+	pByteSource = (unsigned char *) pAlignedSource;
+	while (num--) {
 
-        *pByteDestination++ = *pByteSource++;
-    }
+		*pByteDestination++ = *pByteSource++;
+	}
 
-    return pDestination;
+	return pDestination;
 }
 
 //------------------------------------------------------------------------------
@@ -99,23 +99,23 @@
 //------------------------------------------------------------------------------
 void * memset(void *pBuffer, int value, size_t num)
 {
-    unsigned char *pByteDestination;
-    unsigned int  *pAlignedDestination = (unsigned int *) pBuffer;
-    unsigned int  alignedValue = (value << 24) | (value << 16) | (value << 8) | value;
+	unsigned char *pByteDestination;
+	unsigned int  *pAlignedDestination = (unsigned int *) pBuffer;
+	unsigned int  alignedValue = (value << 24) | (value << 16) | (value << 8) | value;
 
-    // Set words if possible
-    if ((((unsigned int) pAlignedDestination & 0x3) == 0) && (num >= 4)) {
-        while (num >= 4) {
-            *pAlignedDestination++ = alignedValue;
-            num -= 4;
-        }
-    }
-    // Set remaining bytes
-    pByteDestination = (unsigned char *) pAlignedDestination;
-    while (num--) {
-        *pByteDestination++ = value;
-    }
-    return pBuffer;
+	// Set words if possible
+	if ((((unsigned int) pAlignedDestination & 0x3) == 0) && (num >= 4)) {
+		while (num >= 4) {
+			*pAlignedDestination++ = alignedValue;
+			num -= 4;
+		}
+	}
+	// Set remaining bytes
+	pByteDestination = (unsigned char *) pAlignedDestination;
+	while (num--) {
+		*pByteDestination++ = value;
+	}
+	return pBuffer;
 }
 
 //-----------------------------------------------------------------------------
@@ -126,16 +126,16 @@
 //-----------------------------------------------------------------------------
 char * strchr(const char *pString, int character)
 {
-    char * p = (char *)pString;
-    char   c = character & 0xFF;
+	char * p = (char *)pString;
+	char   c = character & 0xFF;
 
-    while(*p != c) {
-        if (*p == 0) {
-            return 0;
-        }
-        p++;
-    }
-    return p;
+	while(*p != c) {
+		if (*p == 0) {
+			return 0;
+		}
+		p++;
+	}
+	return p;
 }
 
 //-----------------------------------------------------------------------------
@@ -144,12 +144,12 @@
 //-----------------------------------------------------------------------------
 size_t strlen(const char *pString)
 {
-    unsigned int length = 0;
+	unsigned int length = 0;
 
-    while(*pString++ != 0) {
-        length++;
-    }
-    return length;
+	while(*pString++ != 0) {
+		length++;
+	}
+	return length;
 }
 
 
@@ -161,14 +161,14 @@
 //-----------------------------------------------------------------------------
 char * strrchr(const char *pString, int character)
 {
-    char *p = 0;
+	char *p = 0;
 
-    while(*pString != 0) {
-        if (*pString++ == character) {
-            p = (char*)pString;
-        }
-    }
-    return p;
+	while(*pString != 0) {
+		if (*pString++ == character) {
+			p = (char*)pString;
+		}
+	}
+	return p;
 }
 
 //-----------------------------------------------------------------------------
@@ -179,10 +179,10 @@
 //-----------------------------------------------------------------------------
 char * strcpy(char *pDestination, const char *pSource)
 {
-    char *pSaveDest = pDestination;
+	char *pSaveDest = pDestination;
 
-    for(; (*pDestination = *pSource) != 0; ++pSource, ++pDestination);
-    return pSaveDest;
+	for(; (*pDestination = *pSource) != 0; ++pSource, ++pDestination);
+	return pSaveDest;
 }
 
 //-----------------------------------------------------------------------------
@@ -196,22 +196,22 @@
 //-----------------------------------------------------------------------------
 int strncmp(const char *pString1, const char *pString2, size_t count)
 {
-    int r;
+	int r;
 
-    while(count) {
-        r = *pString1 - *pString2;
-        if (r == 0) {
-            if (*pString1 == 0) {
-                break;
-            }
-            pString1++;
-            pString2++;
-            count--;
-            continue;
-        }
-        return r;
-    }
-    return 0;
+	while(count) {
+		r = *pString1 - *pString2;
+		if (r == 0) {
+			if (*pString1 == 0) {
+				break;
+			}
+			pString1++;
+			pString2++;
+			count--;
+			continue;
+		}
+		return r;
+	}
+	return 0;
 }
 
 //-----------------------------------------------------------------------------
@@ -223,17 +223,17 @@
 //-----------------------------------------------------------------------------
 char * strncpy(char *pDestination, const char *pSource, size_t count)
 {
-    char *pSaveDest = pDestination;
+	char *pSaveDest = pDestination;
 
-    while (count) {
-        *pDestination = *pSource;
-        if (*pSource == 0) {
-            break;
-        }
-        pDestination++;
-        pSource++;
-        count--;
-    }
-    return pSaveDest;
+	while (count) {
+		*pDestination = *pSource;
+		if (*pSource == 0) {
+			break;
+		}
+		pDestination++;
+		pSource++;
+		count--;
+	}
+	return pSaveDest;
 }