changeset 189:b37e6c916df1

../drv_app/sim/*: rm trailing white space
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 30 Jan 2021 06:34:22 +0000 (2021-01-30)
parents 92abb46dc1ba
children 2e4afc93045d
files src/cs/drivers/drv_app/sim/sim.c src/cs/drivers/drv_app/sim/sim.h src/cs/drivers/drv_app/sim/sim32.c
diffstat 3 files changed, 349 insertions(+), 349 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/sim/sim.c	Tue Jan 19 06:10:27 2021 +0000
+++ b/src/cs/drivers/drv_app/sim/sim.c	Sat Jan 30 06:34:22 2021 +0000
@@ -2,23 +2,23 @@
  * SIM.C
  *
  * Pole Star SIM
- *                 
+ *
  * Target : ARM
  *
  *
- * SIM card driver. This module contents all functions 
+ * SIM card driver. This module contents all functions
  * included in specifications GSM 11.11 V4.10
  *
  *
  * Copyright (c) Texas Instruments 1995-1997
  *
  */
-                                        
+
 #define SIM_C   1
 
 #ifndef _WINDOWS
-	#include "l1sw.cfg" 
-	#include "chipset.cfg" 
+	#include "l1sw.cfg"
+	#include "chipset.cfg"
 #endif
 
 #include "main/sys_types.h"
@@ -64,7 +64,7 @@
 /* working buffer for chronology calls */
 SYS_UWORD8  SIM_dbg_cmd[SIM_DBG_CMD];
 /* index for positionning in working buffer for chronology calls */
-SYS_UWORD16  SIM_dbg_cmd_cmpt;       
+SYS_UWORD16  SIM_dbg_cmd_cmpt;
 /* working variable to calculate the TDMA ecart */
 SYS_UWORD16 SIM_dbg_tdma_diff;
 /* working variable to store the maximum TDMA frame between two characters */
@@ -93,7 +93,7 @@
  *    SIM_WriteBuffer
  *    SIM_Command
  *    SIM_Reset
- *    
+ *
  */
 
 
@@ -105,7 +105,7 @@
  *   return the line, write first byte and let interrupt handler do the rest
  * return the line, write first byte and let interrupt handler do the rest
  *
- * Parameters : 
+ * Parameters :
  *   SIM_PORT *p : buffer for received chars
  *   offset      : starting point for reading data.
  *   n           : number of chars to read.
@@ -128,23 +128,23 @@
    if ((p->xIn - p->xOut) == 1)        //if only one char is transmitted
    {                                   //need to wait a minimum of 1 ETU
         ind_os_sleep (1);                  //for IO line to stay in TX mode
-   } 
-   // Write first byte 
+   }
+   // Write first byte
    p->c->tx = *(p->xOut);              // transmit
 
    if ((p->xIn - p->xOut) == 1)        //if only one char to transmit
    {                                   // return the direction to rx
         p->conf1 &= ~SIM_CONF1_TXRX;   //to be able to receive ACK char
-        p->c->conf1 = p->conf1;        
+        p->c->conf1 = p->conf1;
 
    }
 }
 
 /*
  * SIM_Result
- *    
+ *
  * Parameters : SIM port, buffer for received chars, pointer to receive size
- * 
+ *
  * Return the result code (SW1/SW2) at the end of the string
  */
 SYS_UWORD16 SIM_Result(SIM_PORT *p, SYS_UWORD8 *rP, SYS_UWORD16 *lenP, SYS_UWORD8 offset)
@@ -152,11 +152,11 @@
    SYS_UWORD8 sw1, sw2;
    SYS_UWORD8 verdict;
    SYS_UWORD16 len;
-   
+
    // Check if all characters were transmitted
    if (p->xIn - 1 != p->xOut)
       return (SIM_ERR_XMIT);
-   
+
    len = p->rx_index;
    *lenP = len - offset;
    if ((*lenP == 0) && (p->apdu_ans_length == 256))
@@ -166,7 +166,7 @@
    {
        verdict = SIM_Memcpy(rP, ((p->rbuf) + offset), 256 - offset);
        if (verdict != 0)
-       { 
+       {
            return (verdict);
        }
    }
@@ -178,8 +178,8 @@
            return (verdict);
        }
    }
-   
-   // change to remove SW1 and SW2 bytes from the receive buffer of data 
+
+   // change to remove SW1 and SW2 bytes from the receive buffer of data
    sw1 = p->rSW12[0];
    sw2 = p->rSW12[1];
 
@@ -204,7 +204,7 @@
  *             SIM_ERR_LEN  : the answer is not corresponding to a
  *                            correct answer of T=0 protocol
  * 06/11/2002	JYT
- *		Modified to be base command function. New SIM_Command() created to call it 
+ *		Modified to be base command function. New SIM_Command() created to call it
  * 		with wrapper. Created to manage retries on Internals errors of the driver.
  */
 
@@ -326,7 +326,7 @@
 
 
 /* Main function to manage the retry mechanism */
-SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP) {   
+SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP) {
 	int res;
 
 #ifdef SIM_DEBUG_TRACE
@@ -363,18 +363,18 @@
 
 
 
-                                
+
 /*
  * SIM_ByteReverse
  *
  * Reverse a byte, both up/down (1 <> 0) and left/right (0001 <> 1000)
- * 
+ *
  */
 SYS_UWORD8 SIM_ByteReverse(SYS_UWORD8 b)
 {
     SYS_UWORD8 bh, bl;
     int i;
-    const SYS_UWORD8 Reverse[] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 
+    const SYS_UWORD8 Reverse[] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE,
                                     0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF };
 
     // Up/Down
@@ -383,10 +383,10 @@
     // left / right (by nibble)
     bh = (b >> 4) & 0xF;
     bl = b & 0xF;
-      
+
     b = (Reverse[bl]) << 4 | Reverse[bh];
     return(b);
-   
+
 }
 
 /*
@@ -409,20 +409,20 @@
 /*
  * SIM_Reset
  *
- * Reset SIM card 
+ * Reset SIM card
  * Call-back SIM insert if successful
  * or SIM remove otherwise
  *
  * Returns 0 for success, or
  *         SIM_ERR_NOCARD : no card
  *         SIM_ERR_NATR   : no answer to reset
- *         SIM_ERR_NOINT  : no 
+ *         SIM_ERR_NOINT  : no
  *         SIM_ERR_READ   : unknown data return by the card
  *         SIM_ERR_CARDREJECT : card not accepted
  *
  * 29/01/02, JYT, adding of low voltage managment for IOTA device
  * 06/10/03, JYT, Split of Reset to handle Restart
- */ 
+ */
 SYS_UWORD16 SIM_Reset(SIM_CARD *cP)
 {
 	return(SIM_Reset_Restart_Internal(cP, 1));
@@ -437,17 +437,17 @@
 /*
  * SIM_Restart
  *
- * Restart SIM card 
+ * Restart SIM card
  *
  * Returns 0 for success, or
  *         SIM_ERR_NOCARD : no card
  *         SIM_ERR_NATR   : no answer to reset
- *         SIM_ERR_NOINT  : no 
+ *         SIM_ERR_NOINT  : no
  *         SIM_ERR_READ   : unknown data return by the card
  *         SIM_ERR_CARDREJECT : card not accepted
  *
  * 06/10/03, JYT, Split of Reset to handle Restart
- */ 
+ */
 SYS_UWORD16 SIM_Restart(SIM_CARD *cP)
 {
 	return(SIM_Reset_Restart_Internal(cP, 0));
@@ -457,20 +457,20 @@
 /*
  * SIM_Reset_Restart_Internal
  *
- * Reset SIM card 
+ * Reset SIM card
  * Call-back SIM insert if successful
  * or SIM remove otherwise
- *							  
+ *
  * Returns 0 for success, or
  *         SIM_ERR_NOCARD : no card
  *         SIM_ERR_NATR   : no answer to reset
- *         SIM_ERR_NOINT  : no 
+ *         SIM_ERR_NOINT  : no
  *         SIM_ERR_READ   : unknown data return by the card
  *         SIM_ERR_CARDREJECT : card not accepted
  *
  * 29/01/02, JYT, adding of low voltage managment for IOTA device
  * 06/10/03, JYT, Split of Reset to handle Restart, ResetFlag added.
- */ 
+ */
 SYS_UWORD16 SIM_Reset_Restart_Internal(SIM_CARD *cP, SYS_UWORD8 ResetFlag)
 {
     SIM_PORT        *p;
@@ -484,7 +484,7 @@
 	memset(SIM_dbg_cmd, 0x00, SIM_DBG_CMD);
 #endif
 
-    // Initialize pointers 
+    // Initialize pointers
     p = &(Sim[0]);
 
 // begin of JYT modifications
@@ -503,8 +503,8 @@
     p->SWcount       = 0;
     p->Freq_Algo     = 0;
     p->PTS_Try       = 0;            //use to calculate how many PTS try were already done
-    
-    // Initialize pointers 
+
+    // Initialize pointers
     p->xIn   = p->xOut = p->xbuf;
     p->rx_index        = 0;
     p->errorSIM        = 0;
@@ -514,14 +514,14 @@
     BackValue = SIM_ManualStart(p);
     if (BackValue != 0)
         return ((SYS_UWORD16)BackValue);
-    
-      
-    p->c->conf1 = p->conf1 &= ~SIM_CONF1_BYPASS;      //switch to automatic mode             
+
+
+    p->c->conf1 = p->conf1 &= ~SIM_CONF1_BYPASS;      //switch to automatic mode
 
 //#else //SW_WRK_AROUND_H_S == 0 // Automatic procedure -> fails with test 27.11.2.1
 //
 //                                  // Mask all interrupts
-//    p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV | 
+//    p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV |
 //                   SIM_MASK_TX | SIM_MASK_RX | SIM_MASK_CD;
 //
 //
@@ -530,7 +530,7 @@
 //
 //    p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_STOP;
 //    ind_os_sleep(1);
-//                      
+//
 //    p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_SWRST;    // Set START bit and wait a while
 //    ind_os_sleep(1);
 //                                  // Unmask all sources of interrupts except WT, OV, and NATR
@@ -548,7 +548,7 @@
 //        #endif
 //    p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_START;
 //
-//#endif 
+//#endif
 
 /*-----------------------------------------------------------*/
 
@@ -566,7 +566,7 @@
             }
             // ATR received but wrong characters value
             // Comply with Test 27.11.2.4.5 and Test 27.11.1.3
-            else if (BackValue == SIM_ERR_CARDREJECT)            
+            else if (BackValue == SIM_ERR_CARDREJECT)
                 {
                 if (ATR_Attempt >= 3)
             {
@@ -577,24 +577,24 @@
                 ATR_Attempt++;
                 SIM_WARMReset(p);    // assert a reset during at least 400 ETU
         }
-            else if (BackValue != 0) //SIM_ERR_WAIT           
+            else if (BackValue != 0) //SIM_ERR_WAIT
         {
                 if (ATR_Attempt == 3)
                 {    // switch to 5V (ANALOG1) or 3V (ANALOG2) if card send wrong ATR 3 consecutive times
                      // Apply 3 consecutive resets at 5V (ANALOG1) or 3V (ANALOG2)
-                     // fix prb for old chinese card not GSM compliant   
-
-                     if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) 
+                     // fix prb for old chinese card not GSM compliant
+
+                     if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK)
                      {
                      	// SIM cannot be supplied at 3V (ANALOG2), because of an Hardware failure
                      	SIM_PowerOff ();
                         return((SYS_UWORD16)BackValue);
-                     }   
-                     
-                     ATR_Attempt++;  
-                     goto COLD_RESET;  
+                     }
+
+                     ATR_Attempt++;
+                     goto COLD_RESET;
                 }
-                if (ATR_Attempt >= 6) 
+                if (ATR_Attempt >= 6)
                 {
                     SIM_PowerOff ();
                     return ((SYS_UWORD16)BackValue);
@@ -603,17 +603,17 @@
                 ATR_Attempt++;
                 SIM_WARMReset(p);    // assert a reset during at least 400 ETU
             }
-            
+
             else
             {
-                ATR_Attempt = 0;    
+                ATR_Attempt = 0;
             }
         }
 /*-----------------------------------------------------------*/
 // PTS procedure
         BackValue = SIM_PTSprocedure(cP,p);      //assert PTS if needed
 //        need upgrade with FIFO use to avoid CPU overloading
-              
+
         if (BackValue)
         {
             if (BackValue == SIM_ERR_CARDREJECT)
@@ -621,10 +621,10 @@
                 SIM_PowerOff ();      //must be done by protocol stack
                 return (SIM_ERR_CARDREJECT);
             }
-            if (p->PTS_Try <= 4)     //else error treatement  
+            if (p->PTS_Try <= 4)     //else error treatement
             {
                 SIM_WARMReset(p);    // assert a reset during at least 400 ETU
-            }            
+            }
         }
         else
         {
@@ -653,59 +653,59 @@
     {
 #if ((SIM_TYPE == SIM_TYPE_3V ) || (SIM_TYPE == SIM_TYPE_1_8_3V) || (SIM_TYPE == SIM_TYPE_1_8V))
         SIM_PowerOff ();                 // required by ETSI if 5V only card is detected and 3V only ME chosen
-        return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2    
-#elif (SIM_TYPE == SIM_TYPE_3_5V)  
+        return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2
+#elif (SIM_TYPE == SIM_TYPE_3_5V)
         if (CurrentVolt == SIM_3V) //if 5V only SIM present -> the ME may switch to 5V operation
         {
             if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) // switch to 5V
             {
                SIM_PowerOff ();
                return ((SYS_UWORD16)BackValue);
-            }	
+            }
             ATR_Attempt      = 1;
-            goto COLD_RESET;            // Test 27.17.1.5.3 
+            goto COLD_RESET;            // Test 27.17.1.5.3
         }
-#endif              
+#endif
     }
-    else 
+    else
     {
        if ((p->FileC & SIM_MASK_INFO_VOLT) == SIM_3V)
        {
 #if (SIM_TYPE == SIM_TYPE_1_8V)
         SIM_PowerOff ();                 // required by ETSI if 3V only card is detected and 1.8V only ME chosen
-        return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2    
-#elif (SIM_TYPE == SIM_TYPE_1_8_3V)  
+        return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2
+#elif (SIM_TYPE == SIM_TYPE_1_8_3V)
         if (CurrentVolt == SIM_1_8V) //if 3V only SIM present -> the ME may switch to 3V operation
         {
             if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) // switch to 3V
             {
                SIM_PowerOff ();
                return ((SYS_UWORD16)BackValue);
-            }	
+            }
             ATR_Attempt      = 1;
-            goto COLD_RESET;            // Test 27.17.1.5.3 
+            goto COLD_RESET;            // Test 27.17.1.5.3
         }
-#endif                     	
+#endif
        }
-       else 
+       else
        {
           if ((p->FileC & SIM_MASK_INFO_VOLT) == SIM_1_8V)
           {
 #if (SIM_TYPE == SIM_TYPE_5V)
               SIM_PowerOff ();                 // required by ETSI if 5V only card is detected and 3V only ME chosen
-              return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2    
-#endif                        	
+              return (SIM_ERR_CARDREJECT);     // Test 27.17.1.5.2
+#endif
           }
-          else 
+          else
           {
        	      // future class of sim card voltage !!!!!! never use it
        	      SIM_PowerOff ();                 // Rec. 11.18
-              return (SIM_ERR_CARDREJECT);     
-          }          
+              return (SIM_ERR_CARDREJECT);
+          }
        }
-    }      
-
-    SIM_Interpret_FileCharacteristics(p);      //find which frequency (13/4 or 13/8 Mhz) 
+    }
+
+    SIM_Interpret_FileCharacteristics(p);      //find which frequency (13/4 or 13/8 Mhz)
 
     if(p->errorSIM)
     {
@@ -716,7 +716,7 @@
     //enable starting of the os timer for sleep mode
     if (ResetFlag) {
     if (p->InsertFunc != NULL)
-       (p->InsertFunc)(cP);   
+       (p->InsertFunc)(cP);
 	}
 
      return(0);
@@ -746,26 +746,26 @@
 //!!
     p->c->conf1 = p->conf1 = 0x8004;   //set conf1 to automatic mode SIO low
     //enable sim interface clock module
-    p->c->cmd = SIM_CMD_CLKEN;    
+    p->c->cmd = SIM_CMD_CLKEN;
 
 //#if (SW_WRK_AROUND_H_S == 1)
 
     // Mask all interrupts
-    p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV | 
+    p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV |
            SIM_MASK_TX | SIM_MASK_RX | SIM_MASK_CD;
 
     // Unmask interrupt controller
     IQ_Unmask (IQ_SIM);
 
     p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_STOP;
-    ind_os_sleep (4);                           //wait 5 TDMA due to SVCC falling down duration 
+    ind_os_sleep (4);                           //wait 5 TDMA due to SVCC falling down duration
 
     p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_SWRST;
-    ind_os_sleep (1);                           //wait 5 TDMA due to SVCC falling down duration 
+    ind_os_sleep (1);                           //wait 5 TDMA due to SVCC falling down duration
 
 
     p->c->conf2  = 0x0940;
-    
+
     i = p->c->it;
     // Unmask all sources of interrupts except WT and OV and NATR
     p->c->maskit = SIM_MASK_WT | SIM_MASK_OV | SIM_MASK_NATR;
@@ -778,14 +778,14 @@
     p->c->conf1 = p->conf1 |= SIM_CONF1_SVCCLEV;
     ind_os_sleep(1);
 
-    #if(ANLG_FAM == 1) 
+    #if(ANLG_FAM == 1)
       //set OMEGA to 3V mode
       //enable VCC
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) | MODE_ENA_SIMLDOEN);
       ind_os_sleep(1);
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) | MODE_ENA_SIMEN);
       ind_os_sleep(1);
-    #elif(ANLG_FAM == 2) 
+    #elif(ANLG_FAM == 2)
       //set IOTA to 3V mode
       //enable VCC
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) | MODE_ENA_SIMEN);
@@ -816,8 +816,8 @@
     {
         ind_os_sleep (1);
         i++;
-    }        
-      
+    }
+
     if ((p->rx_index == 0) && (i >= 3))         //external reset card ATR treatement
     {
         i = 0;
@@ -833,7 +833,7 @@
 
     return (0);
 }
- 
+
 /* SIM manual stop
 *
 *  purpose : manage manual start of the SIM interface
@@ -846,7 +846,7 @@
 // to write
 }
 
-/* Power off SIM == SIM_CMD_STOP 
+/* Power off SIM == SIM_CMD_STOP
 *  input  : none
 *  output : none
 */
@@ -858,7 +858,7 @@
 
 
 
-    // Initialize pointers 
+    // Initialize pointers
     p = &(Sim[0]);
 
 
@@ -868,11 +868,11 @@
 
     ind_os_sleep(5);    //wait for falling of SIM signals (RESET/CLK/IO)
 
-    #if(ANLG_FAM == 1) 
+    #if(ANLG_FAM == 1)
       //disable VCC : disable level shifter then SVDD
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & MODE_DIS_SIMEN);
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & MODE_DIS_SIMLDOEN);
-    #elif(ANLG_FAM == 2) 
+    #elif(ANLG_FAM == 2)
       //disable VCC : disable level shifter then SVDD
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & MODE_DIS_SIMEN);
       ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & MODE_DIS_SIMLDOEN);
@@ -922,7 +922,7 @@
     /* FreeCalypso addition */
     ffs_file_read("/etc/SIM_spenh", &SIM_allow_speed_enhancement, 1);
 
-    // Initialize registers 
+    // Initialize registers
     p = &(Sim[0]);
     p->c = (SIM_CONTROLLER *) SIM_CMD;
 
@@ -934,7 +934,7 @@
     //timer start only with NU_Control_Timer function
     //waiting time set to 2.3s
     SIM_sleep_status = SIM_SLEEP_NONE;
-    
+
 #ifdef SIM_RETRY
     SimRetries = 0;
 #endif
@@ -954,7 +954,7 @@
 {
     SIM_PORT *p;
 
-    // Initialize pointers 
+    // Initialize pointers
     p = &(Sim[0]);
 
     p->InsertFunc = Insert;
@@ -968,7 +968,7 @@
  * High level routines : mapped to GSM 11.11 function calls
  *
  * Uses a Nucleus semaphore to ensure no simultaneous access to SIM and buffer
- *    
+ *
  * Each routine does :
  *    write command
  *    sleep long enough for the expected transmission and reception
@@ -977,9 +977,9 @@
  *    SYS_UWORD8 *result :  pointer to the string return by the SIM card
  *    SYS_UWORD8 *rcvSize : size of the string return by the SIM card
  *
- *    other parameters : parameters needed by the SIM card to 
+ *    other parameters : parameters needed by the SIM card to
  *                       execute the function.
- *   
+ *
  */
 //unsigned char SIM_flag = 0;
 
@@ -993,19 +993,19 @@
 {
     SIM_PORT *p;
     int res;
-	
+
     p = &(Sim[0]);
 
     p->xbuf[0] = GSM_CLASS;
-    p->xbuf[1] = SIM_SELECT; 
+    p->xbuf[1] = SIM_SELECT;
     p->xbuf[2] = 0;
     p->xbuf[3] = 0;
-    p->xbuf[4] = 2; 
+    p->xbuf[4] = 2;
     p->xbuf[5] = id >> 8;       // high byte
     p->xbuf[6] = id & 0xFF;     // low byte
 
 
-    res = SIM_Command(p, 2, dat, rcvSize);   
+    res = SIM_Command(p, 2, dat, rcvSize);
     /* Change from to 10 to 15 for specific SIM card (Racal) */
 
 //	if (id == 0x6F07)
@@ -1032,7 +1032,7 @@
 
 /*
  * SIM_Status
- *    
+ *
  *  Returns data received from card and number of bytes received
  */
 SYS_UWORD16 SIM_Status(SYS_UWORD8 *dat, SYS_UWORD16 *rcvSize)
@@ -1048,7 +1048,7 @@
     p->xbuf[1] = SIM_STATUS;
     p->xbuf[2] = 0;
     p->xbuf[3] = 0;
-    p->xbuf[4] = len; 
+    p->xbuf[4] = len;
 
     res = SIM_Command(p, 0, dat, rcvSize);
 
@@ -1072,7 +1072,7 @@
 
 /*
  * SIM_Status_Extended
- *    
+ *
  *  Returns data received from card and number of bytes received
  *  Add extra parameter len : number of returned byte
  */
@@ -1088,7 +1088,7 @@
     p->xbuf[1] = SIM_STATUS;
     p->xbuf[2] = 0;
     p->xbuf[3] = 0;
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     res = SIM_Command(p, 0, dat, rcvSize);
 
@@ -1126,9 +1126,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_READ_BINARY;
-    p->xbuf[2] = offset >> 8; 
-    p->xbuf[3] = offset & 0xFF; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = offset >> 8;
+    p->xbuf[3] = offset & 0xFF;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     res = SIM_Command(p, 0, dat, rcvSize);
 
@@ -1136,7 +1136,7 @@
 //		SIM_flag = 0;
 //		dat[0] = 0x08;
 //	}
-		
+
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"ADCMD", 5);
 	SIM_dbg_write_trace(p->xbuf, 5);
@@ -1178,9 +1178,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_VERIFY_CHV;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = chvType; 
-    p->xbuf[4] = len; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = chvType;
+    p->xbuf[4] = len;
     for (i=0;i<8;i++)
     {
       p->xbuf[5+i] = *(dat+i);
@@ -1231,9 +1231,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_RUN_GSM_ALGO;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = len; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = len;
 
     for (i=0;i<len;i++)
     {
@@ -1285,9 +1285,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_GET_RESPONSE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     res = SIM_Command(p, 0, dat, rcvSize);
 
@@ -1331,9 +1331,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_CHANGE_CHV;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = chvType; 
-    p->xbuf[4] = (SYS_UWORD8)len; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = chvType;
+    p->xbuf[4] = (SYS_UWORD8)len;
 
     // Copy bytes to buffer
     for (i=0;i<8;i++)
@@ -1386,14 +1386,14 @@
     len = 8;
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_DISABLE_CHV;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 1; 
-    p->xbuf[4] = 8; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 1;
+    p->xbuf[4] = 8;
     for (i=0;i<8;i++)
     {
       p->xbuf[5+i] = *(dat+i);
     }
-    res = SIM_Command(p, len, result, lP);        
+    res = SIM_Command(p, len, result, lP);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AICMD", 5);
@@ -1437,9 +1437,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_ENABLE_CHV;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 1; 
-    p->xbuf[4] = (SYS_UWORD8)len; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 1;
+    p->xbuf[4] = (SYS_UWORD8)len;
 
     for (i=0;i<len;i++)
     {
@@ -1478,7 +1478,7 @@
  * Unblock the specified CHV (chvType) and store a new CHV
  */
 SYS_UWORD16 SIM_UnblockCHV(SYS_UWORD8 *result, SYS_UWORD8 *unblockChv, SYS_UWORD8 *newChv,
-                      SYS_UWORD8 chvType, SYS_UWORD16 *lP) 
+                      SYS_UWORD8 chvType, SYS_UWORD16 *lP)
 {
     SIM_PORT *p;
     int len;
@@ -1492,7 +1492,7 @@
     p->xbuf[1] = SIM_UNBLOCK_CHV;
     p->xbuf[2] = 0;
     p->xbuf[3] = chvType;
-    p->xbuf[4] = (SYS_UWORD8)len; 
+    p->xbuf[4] = (SYS_UWORD8)len;
     for (i=0;i<8;i++)
     {
       p->xbuf[5+i] = *(unblockChv+i);
@@ -1540,9 +1540,9 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_INVALIDATE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = 0; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = 0;
 
     res = SIM_Command(p, 0, rP, lP);
 
@@ -1582,11 +1582,11 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_REHABILITATE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
     p->xbuf[4] = 0;
 
-    res = SIM_Command(p, 0, rP, lP);        
+    res = SIM_Command(p, 0, rP, lP);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AMCMD", 5);
@@ -1628,15 +1628,15 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_UPDATE_BINARY;
-    p->xbuf[2] = offset >> 8; 
-    p->xbuf[3] = offset & 0xFF; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = offset >> 8;
+    p->xbuf[3] = offset & 0xFF;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     for (i=0;i<llen;i++)
     {
       p->xbuf[5+i] = *(dat+i);
     }
-    res = SIM_Command(p, llen, result, rcvSize);        
+    res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"ANCMD", 5);
@@ -1677,11 +1677,11 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_READ_RECORD;
-    p->xbuf[2] = recNum; 
-    p->xbuf[3] = mode; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
-
-    res = SIM_Command(p, 0, dat, rcvSize);        
+    p->xbuf[2] = recNum;
+    p->xbuf[3] = mode;
+    p->xbuf[4] = (SYS_UWORD8)llen;
+
+    res = SIM_Command(p, 0, dat, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AOCMD", 5);
@@ -1842,16 +1842,16 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_UPDATE_RECORD;
-    p->xbuf[2] = recNum; 
-    p->xbuf[3] = mode; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = recNum;
+    p->xbuf[3] = mode;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     for (i=0;i<llen;i++)
     {
         p->xbuf[5+i] = *(dat+i);
     }
 
-    res = SIM_Command(p, llen, result, rcvSize);        
+    res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"APCMD", 5);
@@ -1905,16 +1905,16 @@
 
    p->xbuf[0] = GSM_CLASS;
    p->xbuf[1] = SIM_SEEK;
-   p->xbuf[2] = 0; 
-   p->xbuf[3] = mode; 
-   p->xbuf[4] = (SYS_UWORD8)llen; 
+   p->xbuf[2] = 0;
+   p->xbuf[3] = mode;
+   p->xbuf[4] = (SYS_UWORD8)llen;
 
    for (i=0;i<llen;i++)
    {
       p->xbuf[5+i] = *(dat+i);
    }
 
-   res = SIM_Command(p, llen, result, rcvSize);        
+   res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AQCMD", 5);
@@ -1956,16 +1956,16 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_INCREASE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = 3; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = 3;
 
     for (i=0;i<3;i++)
     {
         p->xbuf[5+i] = *(dat+i);
     }
 
-    res = SIM_Command(p, len, result, rcvSize);        
+    res = SIM_Command(p, len, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"ARCMD", 5);
@@ -2005,16 +2005,16 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_TERMINAL_PROFILE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     for (i=0;i<llen;i++)
     {
         p->xbuf[5+i] = *(dat+i);
     }
 
-    res = SIM_Command(p, llen, result, rcvSize);        
+    res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"ASCMD", 5);
@@ -2051,12 +2051,12 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_FETCH;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
-
-
-    res = SIM_Command(p, 0, result, rcvSize);        
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = (SYS_UWORD8)llen;
+
+
+    res = SIM_Command(p, 0, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"ATCMD", 5);
@@ -2096,16 +2096,16 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_TERMINAL_RESPONSE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     for (i=0;i<llen;i++)
     {
         p->xbuf[5+i] = *(dat+i);
     }
 
-    res = SIM_Command(p, llen, result, rcvSize);        
+    res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AUCMD", 5);
@@ -2142,16 +2142,16 @@
 
     p->xbuf[0] = GSM_CLASS;
     p->xbuf[1] = SIM_ENVELOPE;
-    p->xbuf[2] = 0; 
-    p->xbuf[3] = 0; 
-    p->xbuf[4] = (SYS_UWORD8)llen; 
+    p->xbuf[2] = 0;
+    p->xbuf[3] = 0;
+    p->xbuf[4] = (SYS_UWORD8)llen;
 
     for (i=0;i<llen;i++)
     {
         p->xbuf[5+i] = *(dat+i);
     }
 
-    res = SIM_Command(p, llen, result, rcvSize);        
+    res = SIM_Command(p, llen, result, rcvSize);
 
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AVCMD", 5);
@@ -2198,9 +2198,9 @@
 
     p->xbuf[0] = dat[0];
     p->xbuf[1] = dat[1];
-    p->xbuf[2] = dat[2]; 
-    p->xbuf[3] = dat[3]; 
-    p->xbuf[4] = dat[4]; 
+    p->xbuf[2] = dat[2];
+    p->xbuf[3] = dat[3];
+    p->xbuf[4] = dat[4];
 
     for (i=5;i<trxLen;i++)
     {
@@ -2210,11 +2210,11 @@
 	// enable the WIM behavior of the sim driver
    	p->apdu_ans_length = rcvLen;
 
-    res = SIM_Command(p, (trxLen - 5), result, rcvSize);        
+    res = SIM_Command(p, (trxLen - 5), result, rcvSize);
 
 	// disable the WIM behavior of the sim driver
    	p->apdu_ans_length = 0;
-	
+
 #ifdef SIM_DEBUG_TRACE
 	SIM_dbg_write_trace((SYS_UWORD8 *)"AWCMD", 5);
 	SIM_dbg_write_trace(p->xbuf, trxLen);
@@ -2262,18 +2262,18 @@
     //analyse the nature of the command to execute
 
     if (
-    	(p->xbuf[1] == 0x12) || 
-    	(p->xbuf[1] == 0xB2) || 
-    	(p->xbuf[1] == 0xB0) || 
-    	(p->xbuf[1] == 0xF2) || 
-    	(p->xbuf[1] == 0xC0) || 
+    	(p->xbuf[1] == 0x12) ||
+    	(p->xbuf[1] == 0xB2) ||
+    	(p->xbuf[1] == 0xB0) ||
+    	(p->xbuf[1] == 0xF2) ||
+    	(p->xbuf[1] == 0xC0) ||
     	(p->apdu_ans_length != 0)
-       )       
+       )
     //FETCH, READ_RECORD, READ_BINARY, STATUS, GET_RESPONSE commands == receive command
     {
         if (p->xbuf[4] == 0)                    //if P3 == 0 when sending receive command
         {
-            p->expected_data = 256; 
+            p->expected_data = 256;
         }
         else
         {
@@ -2320,8 +2320,8 @@
     res = SIM_Select(DF_GSM, ubuf, &sz);
     if ((res & 0xFF00) != 0x9F00)
     {
-        res = SIM_Select(DF_DCS1800, ubuf, &sz);                                        
-        if ((res & 0xFF00) != 0x9F00)                                
+        res = SIM_Select(DF_DCS1800, ubuf, &sz);
+        if ((res & 0xFF00) != 0x9F00)
         {
             return (1);
         }
@@ -2332,23 +2332,23 @@
 
     p->FileC = ubuf[13];
     return (0);
-}  
-  
+}
+
 /*
 * Use to determine value of b2 in file caracteristics contained in response
 * of SELECT Master File command
 * return    0 if no preferred speed during authentication
-*           1 if 13/4Mhz mandatory 
+*           1 if 13/4Mhz mandatory
 *
 *
 */
- 
+
 void SIM_Interpret_FileCharacteristics(SIM_PORT *p)
 {
     //interpret b2 bit for operating authentication speed
-    if((p->conf1 & 0x0020) && (p->FileC & 0x02))  
+    if((p->conf1 & 0x0020) && (p->FileC & 0x02))
     {
-        p->Freq_Algo = 1;                                 
+        p->Freq_Algo = 1;
     }
 
     //interpret Clock stop behavior
@@ -2358,7 +2358,7 @@
 	if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_NOT_ALLWD) {
 		/* Sim Clock Stop Not Allowed */
 		SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED;
-		/* There is not need to modifiy p->conf1 */ 
+		/* There is not need to modifiy p->conf1 */
         status_os_sim = NU_Delete_Timer (&SIM_timer);
 	}
 	else {
@@ -2379,7 +2379,7 @@
 #else
 				/* Sim Clock Stop Not Allowed because the interface do not support this level */
 				SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED;
-				/* There is not need to modifiy p->conf1 */ 
+				/* There is not need to modifiy p->conf1 */
 		        status_os_sim = NU_Delete_Timer (&SIM_timer);
 #endif
 			}
@@ -2416,7 +2416,7 @@
     SYS_UWORD8            err;
 
     p->xbuf[0]       = 0xFF;                        //character of PTS proc to send
-    p->xbuf[1]       = 0; 
+    p->xbuf[1]       = 0;
     p->xbuf[2]       = 0xFF;
     p->xbuf[3]       = 0x7B;
 
@@ -2428,15 +2428,15 @@
 
     if (p->PTS_Try > 4)
     {
-        return (SIM_ERR_CARDREJECT);  
+        return (SIM_ERR_CARDREJECT);
     }                       // at the fourth attempt, PTS procedure is unusefull. Use default value.
                             //TA1 present?  Test 27.11.2.6
     else if ( p->PTS_Try == 4)
     {
         SIM_Calcetu (p);
-        return (0);    
+        return (0);
     }
-    
+
     if(cP->AtrData[1] & 0x10)
     {
         TA1 = cP->AtrData[2];
@@ -2469,7 +2469,7 @@
         return (0);
     }                       //if TA1 != 0x11 and 0x94, need to send PTS request
                             //transmit request of speed enhancement : PTS
-    SIM_WriteBuffer(p, 0, n);    
+    SIM_WriteBuffer(p, 0, n);
 
     p->moderx = 0;          //mode of normal reception
     p->expected_data = n;
@@ -2479,8 +2479,8 @@
       return (err);
     }
                             //should received same chars as PTS request
-    if ((p->rbuf[0] != p->xbuf[0]) || (p->rbuf[1] != p->xbuf[1]) || 
-    (p->rbuf[2] != p->xbuf[2])) 
+    if ((p->rbuf[0] != p->xbuf[0]) || (p->rbuf[1] != p->xbuf[1]) ||
+    (p->rbuf[2] != p->xbuf[2]))
     {
       return(SIM_ERR_READ);
     }
@@ -2491,8 +2491,8 @@
         if (p->rbuf[3] != p->xbuf[3])
         {
             return(SIM_ERR_READ);
-        }   
-        
+        }
+
         //correct response from SIM : with speed enhanced
         p->c->conf1 = p->conf1 |= SIM_CONF1_ETU; //set F=512 D=8
     }
@@ -2549,12 +2549,12 @@
         p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKEN;
         // WCS patch for NU_Sleep(0) bug
         if (p->startclock > 0)
-		ind_os_sleep (p->startclock);    
+		ind_os_sleep (p->startclock);
         // End WCS patch
         SIM_sleep_status = SIM_SLEEP_DESACT;
-    }    
+    }
 }
-               
+
 /*
 *  procedure to parse ATR dynamically
 *  input     p pointer of type SIM_PORT
@@ -2575,13 +2575,13 @@
     SYS_UWORD16          mask;
     SYS_UWORD16          returncode;
     SYS_UWORD8            i;
-    SYS_UWORD8            firstprotocol;    
+    SYS_UWORD8            firstprotocol;
     SYS_UWORD8            Tx,T;
     SYS_UWORD8            TDi;
     SYS_UWORD8            position_of_TC1, position_of_TB1;
     SYS_UWORD8            another_protocol_present;
     SYS_UWORD16            wait80000clk;
-        
+
     i               = 0;
     //wait for TS and T0
     p->moderx       = 0;
@@ -2597,9 +2597,9 @@
     {
         return returncode;
     }
-    
+
     //wait for T0
-    p->expected_data++; 
+    p->expected_data++;
     if (returncode = SIM_Waitforchars (p, p->etu9600))
     {
         return returncode;
@@ -2613,7 +2613,7 @@
     }
         /*-----------------------------------------------------------*/
         /*              Inverse convention card                      */
-            // If first byte is correct for inverse card, return success 
+            // If first byte is correct for inverse card, return success
     else if (((p->rbuf[0] & 0x0F) == 0x03) && (p->rx_index != 0))
     {
         cP->Inverse = 1;
@@ -2633,7 +2633,7 @@
 
     HistChar        = Tx & 0x0F;        //get K, number of transmitted historical character
 
-    
+
     while (TDi != 0)
     {
         while (mask < 0x100)            //monitors interface chars
@@ -2645,18 +2645,18 @@
                                         //wait for TC1 and save its position
             if ((firstprotocol == 0) && ((Tx & 0x40) == mask))
             {
-                position_of_TC1 = InterfChar - 1;            
+                position_of_TC1 = InterfChar - 1;
             }
 			if ((firstprotocol == 0) && ((Tx & 0x20) == mask))
             {
-                position_of_TB1 = InterfChar - 1;            
+                position_of_TB1 = InterfChar - 1;
             }
 
             mask = mask << 1;
         }
 
         p->expected_data = InterfChar;     //wait for TAi,TBi,TCi,TDi if present
-        
+
         if (returncode = SIM_Waitforchars (p, p->etu9600))
         {
             return returncode;
@@ -2668,8 +2668,8 @@
             T = SIM_Translate_atr_char (p->rbuf[position_of_TC1], cP);
 
             if ((T != 0) && (T != 255)) //test 27.11.1.3
-            {                           //return Error in case of bad TC1 value            
-                return (SIM_ERR_CARDREJECT);            
+            {                           //return Error in case of bad TC1 value
+                return (SIM_ERR_CARDREJECT);
             }
         }
                                         //need to monitor if TB1 present and if differente from 0 on first protocol
@@ -2677,28 +2677,28 @@
         {
             T = SIM_Translate_atr_char (p->rbuf[position_of_TB1], cP);
 
-            if (T != 0) //ITU 
-            {                           //return Error in case of bad TB1 value            
-                return (SIM_ERR_CARDREJECT);            
+            if (T != 0) //ITU
+            {                           //return Error in case of bad TB1 value
+                return (SIM_ERR_CARDREJECT);
             }
         }
 
         if ((Tx & 0x80) == 0x80)        //TDi byte on first protocol must be 0
         {                               //get new TD char
             Tx = SIM_Translate_atr_char (p->rbuf[InterfChar - 1], cP);
-          
+
             if ((Tx & 0x0F) != 0)
             {
-                if (firstprotocol == 0) //if first protocol received is not T=0, card is rejected   
+                if (firstprotocol == 0) //if first protocol received is not T=0, card is rejected
                 {
                     return (SIM_ERR_CARDREJECT);            //protocol other than T=0
-                }    
+                }
                 else
                 {                       //if an another protocol T != 0 present, need to wait for TCK char
-                    another_protocol_present = 1;                
+                    another_protocol_present = 1;
                 }
             }
-            mask = 0x10;    
+            mask = 0x10;
             firstprotocol++;            //indicate another protocol T
         }
         else
@@ -2708,7 +2708,7 @@
     }
                                         //add TCK if necessary
     p->expected_data =  HistChar + InterfChar + another_protocol_present;
- 
+
     if (returncode = SIM_Waitforchars (p, p->etu9600))
     {
         return returncode;
@@ -2718,17 +2718,17 @@
 
     if (cP->Inverse)        //inverse card
     {
-        // Copy ATR data       
+        // Copy ATR data
         for (i=0;i<cP->AtrSize;i++)
         {
-            cP->AtrData[i] = SIM_ByteReverse(p->rbuf[i]);    
+            cP->AtrData[i] = SIM_ByteReverse(p->rbuf[i]);
         }
         p->c->conf1 = p->conf1 |= SIM_CONF1_CONV | SIM_CONF1_CHKPAR;
     }
     else                    //direct card
     {
         p->c->conf1 = p->conf1 |= SIM_CONF1_CHKPAR; //0x0409
-        // Copy ATR data       
+        // Copy ATR data
         for (i=0;i<cP->AtrSize;i++)
         {
             cP->AtrData[i] = p->rbuf[i];
@@ -2739,7 +2739,7 @@
 }
 
 /*
- ** SIM_Translate_atr_char 
+ ** SIM_Translate_atr_char
  *
  *  FILENAME: sim.c
  *
@@ -2757,7 +2757,7 @@
 
     if (cP->Inverse)
     {
-        translated = SIM_ByteReverse(input);    
+        translated = SIM_ByteReverse(input);
     }
     else
     {
@@ -2773,7 +2773,7 @@
 * input p          sim port
 *       max_wait   max number of TDMA to wait between 2 characters
 * output
-*       error code 0 if OK      
+*       error code 0 if OK
 */
 
 
@@ -2787,7 +2787,7 @@
         p->ack = 0;
         countT = 0;
 
-        while((p->ack == 0) && (p->moderx == 6)) 
+        while((p->ack == 0) && (p->moderx == 6))
         {                               //if p->moderx change from 6 to 5, need to wait for SW1 and SW2
 
             ind_os_sleep(1);
@@ -2811,15 +2811,15 @@
         if (p->moderx == 6)             //if transition to moderx = 5 in synchronous part
         {                               //need to quit for SW1/SW2 reception
             return (0);
-        }    
+        }
     }
-    
+
     if ((p->moderx != 6) && (p->moderx != 5))   //treatement of mode 0, 1, 2, 3, 4
-    {        
+    {
         countT = 0;
         old_nb_char = p->rx_index;
 											   //leave while if moderx == 5
-        while((p->rx_index < p->expected_data) && (p->moderx != 5)) 
+        while((p->rx_index < p->expected_data) && (p->moderx != 5))
         {
             ind_os_sleep(1);
             countT++;                   //implementation of software Waiting time overflow
@@ -2855,7 +2855,7 @@
         countT = 0;
         old_nb_char = p->SWcount;
 
-        while(p->SWcount < 2) 
+        while(p->SWcount < 2)
         {                               //if p->moderx change from 6 to 5, need to wait for SW1 and SW2
 
             ind_os_sleep(1);
@@ -2888,7 +2888,7 @@
 	{
 		return (SIM_ERR_ABNORMAL_CASE1);
 	}
-	
+
 }
 
 
@@ -2915,7 +2915,7 @@
             p->etu9600     = 1815;   // old = 500, increase of 363%
             p->etu400      = 28;
             p->stopclock   = 94;
-            p->startclock = 38; 
+            p->startclock = 38;
         }
     }
     else                                //clock input is 13/4 Mhz
@@ -2925,16 +2925,16 @@
             p->etu9600     = 159;   // old = 44, increase of 363%
             p->etu400      = 3;
             p->stopclock   = 9;
-            p->startclock = 4; 
+            p->startclock = 4;
         }
         else                            //etu period is 372/1*Tsclk
         {
             p->etu9600     = 907;  // old = 250, increase of 363%
             p->etu400      = 14;
             p->stopclock   = 47;
-            p->startclock = 19; 
+            p->startclock = 19;
         }
-    }  
+    }
 }
 
 
@@ -2946,7 +2946,7 @@
  *
  */
 
-SYS_UWORD8 SIM_StartVolt (SYS_UWORD8 ResetFlag) 
+SYS_UWORD8 SIM_StartVolt (SYS_UWORD8 ResetFlag)
 {
 	SYS_UWORD8 abbmask;
 
@@ -2989,7 +2989,7 @@
     {
 		if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU
             return(SIM_OK);
-        ind_os_sleep(1);	
+        ind_os_sleep(1);
     }
     // IOTA failure activation
     return(SIM_ERR_HARDWARE_FAIL);
@@ -3003,7 +3003,7 @@
     {
 		if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU
             return(SIM_OK);
-        ind_os_sleep(1);	
+        ind_os_sleep(1);
     }
     // IOTA failure activation
     return(SIM_ERR_HARDWARE_FAIL);
@@ -3064,14 +3064,14 @@
 {
     SYS_UWORD8 count = 0;
    	SYS_UWORD8 abbmask;
-        
+
     SIM_PowerOff();
 
     #if(ANLG_FAM == 1)
       #if (SIM_TYPE == SIM_TYPE_3_5V)    // shut down VCC from ABB and prepare to start at 5V mode
 	if (ResetFlag) {
 		abbmask = MODE5V_OMEGA;
-        CurrentVolt   = SIM_5V;  
+        CurrentVolt   = SIM_5V;
 	}
 	else {
 		if (CurrentVolt == SIM_3V)
@@ -3086,7 +3086,7 @@
       #if (SIM_TYPE == SIM_TYPE_1_8_3V)  // shut down VCC from ABB and prepare to start at 3V mode
 	if (ResetFlag) {
 		abbmask = MODE_INIT_IOTA_3V;
-        CurrentVolt   = SIM_3V; 
+        CurrentVolt   = SIM_3V;
 	}
 	else {
 		if (CurrentVolt == SIM_1_8V)
@@ -3099,7 +3099,7 @@
        {
           if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04)
                return(SIM_OK);
-           ind_os_sleep(1);	
+           ind_os_sleep(1);
        }
        // IOTA failure activation
        return(SIM_ERR_HARDWARE_FAIL);
@@ -3108,7 +3108,7 @@
       #if (SIM_TYPE == SIM_TYPE_1_8_3V)  // shut down VCC from ABB and prepare to start at 3V mode
 	if (ResetFlag) {
 		abbmask = MODE_INIT_SYREN_3V;
-        CurrentVolt   = SIM_3V; 
+        CurrentVolt   = SIM_3V;
 	}
 	else {
 		if (CurrentVolt == SIM_1_8V)
@@ -3138,7 +3138,7 @@
 
     for (i = 0; i < len; i++)
           {
-         if (i == RSIMBUFSIZE) 
+         if (i == RSIMBUFSIZE)
           {
                return (SIM_ERR_BUFF_OVERFL);
           }
@@ -3154,15 +3154,15 @@
 
 /*
  * SIM_SleepStatus
- * 
+ *
  * Return SIM status for sleep manager
- * 
+ *
  */
 SYS_BOOL SIM_SleepStatus(void)
 {
 	if ((SIM_sleep_status == SIM_SLEEP_ACT) ||  (SIM_sleep_status == SIM_SLEEP_NONE))
 		return(1);		 // SIM is ready for deep sleep
-	else 
+	else
 		return(0);
 }
 
--- a/src/cs/drivers/drv_app/sim/sim.h	Tue Jan 19 06:10:27 2021 +0000
+++ b/src/cs/drivers/drv_app/sim/sim.h	Sat Jan 30 06:34:22 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * SIM.H				 
+ * SIM.H
  *
  * Pole Star SIM
  *
@@ -12,14 +12,14 @@
 /*
  * Device addresses - GCS000 (Gemini / Polestar)
  *                    HER207 (Hercules)
- */ 
+ */
 
 #ifndef _WINDOWS
-  #include "l1sw.cfg" 
-  #include "chipset.cfg" 
+  #include "l1sw.cfg"
+  #include "chipset.cfg"
 #endif
 
-#include "nucleus.h" 
+#include "nucleus.h"
 
 /* Flags activation section */
 // #define SIM_RETRY		 /*	by default : NOT ACTIVE */
@@ -41,14 +41,14 @@
 
 
 /*
- * Bit definitions 
- */ 
+ * Bit definitions
+ */
 // control regidter
 #define SIM_CMD_CRST          0x0001
 #define SIM_CMD_SWRST         0x0002
 #define SIM_CMD_STOP          0x0004
 #define SIM_CMD_START         0x0008
-#define SIM_CMD_CLKEN         0x0010	
+#define SIM_CMD_CLKEN         0x0010
 
 // status register
 #define SIM_STAT_CD           0x0001   // card present
@@ -68,12 +68,12 @@
 #define SIM_CONF1_BYPASS      0x0100   // bypass hardware timers
 #define SIM_CONF1_SVCCLEV     0x0200
 #define SIM_CONF1_SRSTLEV     0x0400
-#define SIM_CONF1_SIOLOW      0x8000   //force SIO to low level	 
+#define SIM_CONF1_SIOLOW      0x8000   //force SIO to low level
 
 // interrupt status register
 #define SIM_IT_NATR           0x0001   // No answer to reset
 #define SIM_IT_WT             0x0002
-#define SIM_IT_ITOV           0x0004   
+#define SIM_IT_ITOV           0x0004
 #define SIM_IT_ITTX           0x0008   // Transmit
 #define SIM_IT_ITRX           0x0010   // Receipt
 
@@ -89,7 +89,7 @@
 #define SIM_MASK_OV           0x0004
 #define SIM_MASK_TX           0x0008   // Transmit
 #define SIM_MASK_RX           0x0010   // Receipt
-#define SIM_MASK_CD           0x0020   // Card insertion/extraction	
+#define SIM_MASK_CD           0x0020   // Card insertion/extraction
 
 // receveid byte register
 #define SIM_DRX_STATRXPAR     0x0100   // received byte parity status
@@ -116,7 +116,7 @@
 // end of JYT modifications
 #define SIM_ERR_RETRY_FAILURE  14
 
-#define SIM_SLEEP_NONE         0	// No SIM available 
+#define SIM_SLEEP_NONE         0	// No SIM available
 #define SIM_SLEEP_DESACT       1	// The Driver is NOT currently in sleep mode (clock is off)
 #define SIM_SLEEP_ACT          2	// The Driver is currently in sleep mode (clock is on)
 #define SIM_SLEEP_NOT_ALLOWED  3	// The Driver cannot stop the clock :
@@ -124,7 +124,7 @@
 									// to do it.
 #define SIM_SLEEP_WAITING_TIME 500 //represent 2.3s of period before entering in sleep mode
 
-#define SIM_CLK_STOP_MASK		0x0D	// Clock Stop mask defined by ETSI 11.11 
+#define SIM_CLK_STOP_MASK		0x0D	// Clock Stop mask defined by ETSI 11.11
 #define SIM_CLK_STOP_NOT_ALLWD	0x00	// see ETSI 11.11 : Clock Stop never allowed
 #define SIM_CLK_STOP_ALLWD		0x01	// see ETSI 11.11 : No prefered level
 #define SIM_CLK_STOP_HIGH		0x04	// see ETSI 11.11 : High level only
@@ -142,9 +142,9 @@
   #define MODE_ENA_SIMEN       0x02 // used in SIM_ManualStart
 #elif(ANLG_FAM == 2)
    //IOTA specific definitions
-   #define MODE1_8V_IOTA        0x00 
+   #define MODE1_8V_IOTA        0x00
    #define MODE_INIT_IOTA_3V    0x03
-   #define MODE_INIT_IOTA_1_8V  0x02 
+   #define MODE_INIT_IOTA_1_8V  0x02
    #define MODE3V_IOTA          0x01
    #define MODE_DIS_SIMLDOEN    0xFC // SIMSEL + Regulator RSIMEN
    #define MODE_DIS_SIMEN       0xF7
@@ -152,9 +152,9 @@
    #define MODE_ENA_SIMEN       0x08
 #elif(ANLG_FAM == 3)
    //SYREN specific definitions
-   #define MODE1_8V_SYREN        0x00 
+   #define MODE1_8V_SYREN        0x00
    #define MODE_INIT_SYREN_3V    0x03
-   #define MODE_INIT_SYREN_1_8V  0x02 
+   #define MODE_INIT_SYREN_1_8V  0x02
    #define MODE3V_SYREN          0x01
    #define MODE_DIS_SIMLDOEN     0x1FC // SIMSEL + Regulator RSIMEN
    #define MODE_DIS_SIMEN        0x1F7
@@ -180,24 +180,24 @@
 #if((ANLG_FAM == 2) || (ANLG_FAM == 3))
 // Until now (20/03/2003), it is impossible to test IOTA or SYREN with 1.8V Sim Card,
 // so SIM drv is configured in 3V only with IOTA.and SYREN
-// When 1.8V Sim Card will be delivered and tested on IOTA and SYREN, then Sim driver will pass 
-// to : #define SIM_TYPE       SIM_TYPE_1_8_3V   
-#define SIM_TYPE       SIM_TYPE_1_8_3V // MODIFY BY JENNIFER SIM_TYPE_3V   
+// When 1.8V Sim Card will be delivered and tested on IOTA and SYREN, then Sim driver will pass
+// to : #define SIM_TYPE       SIM_TYPE_1_8_3V
+#define SIM_TYPE       SIM_TYPE_1_8_3V // MODIFY BY JENNIFER SIM_TYPE_3V
 #else
-#define SIM_TYPE       SIM_TYPE_3_5V   
+#define SIM_TYPE       SIM_TYPE_3_5V
 #endif
 #endif
 
 // begin of modifications of JYT
 
 #if((ANLG_FAM == 2) || (ANLG_FAM == 3))
-#define SIM_MASK_INFO_VOLT    0x70  
+#define SIM_MASK_INFO_VOLT    0x70
 #else
 #define SIM_MASK_INFO_VOLT    0x10
 #endif
 
 #define SIM_1_8V              0x30
-#define SIM_3V                0x10  
+#define SIM_3V                0x10
 #define SIM_5V                0x00
 
 // end of modifications of JYT
@@ -209,23 +209,23 @@
 #define GSM_CLASS  0xA0
 
 // SIM Instruction Codes
-#define SIM_SELECT              0xA4    
-#define SIM_STATUS              0xF2    
-#define SIM_READ_BINARY         0xB0    
-#define SIM_UPDATE_BINARY       0xD6    
-#define SIM_READ_RECORD         0xB2    
-#define SIM_UPDATE_RECORD       0xDC    
-#define SIM_SEEK                0xA2    
-#define SIM_INCREASE            0x32    
-#define SIM_VERIFY_CHV          0x20    
-#define SIM_CHANGE_CHV          0x24    
-#define SIM_DISABLE_CHV         0x26    
-#define SIM_ENABLE_CHV          0x28    
-#define SIM_UNBLOCK_CHV         0x2C    
-#define SIM_INVALIDATE          0x04    
-#define SIM_REHABILITATE        0x44    
-#define SIM_RUN_GSM_ALGO        0x88    
-#define SIM_GET_RESPONSE        0xC0 
+#define SIM_SELECT              0xA4
+#define SIM_STATUS              0xF2
+#define SIM_READ_BINARY         0xB0
+#define SIM_UPDATE_BINARY       0xD6
+#define SIM_READ_RECORD         0xB2
+#define SIM_UPDATE_RECORD       0xDC
+#define SIM_SEEK                0xA2
+#define SIM_INCREASE            0x32
+#define SIM_VERIFY_CHV          0x20
+#define SIM_CHANGE_CHV          0x24
+#define SIM_DISABLE_CHV         0x26
+#define SIM_ENABLE_CHV          0x28
+#define SIM_UNBLOCK_CHV         0x2C
+#define SIM_INVALIDATE          0x04
+#define SIM_REHABILITATE        0x44
+#define SIM_RUN_GSM_ALGO        0x88
+#define SIM_GET_RESPONSE        0xC0
 #define SIM_TERMINAL_PROFILE   	0x10
 #define SIM_FETCH   			0x12
 #define SIM_TERMINAL_RESPONSE   0x14
@@ -270,12 +270,12 @@
 
 #define MASK_INS           0xFE
 #define MASK_CMD           0x11
-#define MASK_RST           0x10  
+#define MASK_RST           0x10
 
 
 // Buffer sizes
 #define RSIMBUFSIZE  270
-#define RSIZESW1SW2  2 
+#define RSIZESW1SW2  2
 #define XSIMBUFSIZE  270
 
 
@@ -295,7 +295,7 @@
 #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
    volatile unsigned short it_cd;
 #endif
-} SIM_CONTROLLER;  
+} SIM_CONTROLLER;
 
 
 typedef struct
@@ -312,7 +312,7 @@
     SYS_UWORD8          *xIn;            // xmit input pointer
     SYS_UWORD8          *xOut;           // xmit output pointer
     unsigned            errorSIM;          // code return in case of error detectd
-    unsigned short      conf1; // image of the configuration register - avoids read/mod/write cycles	
+    unsigned short      conf1; // image of the configuration register - avoids read/mod/write cycles
     volatile unsigned short txParityErr;
     unsigned short		rxParityErr;	// if 0 no parity error on receipt, 1 if...
     SYS_UWORD8          Freq_Algo;              //use to determine which sim clk freq to choose for running GSM algo
@@ -327,7 +327,7 @@
                                         // 1 : mode of wait for acknowledge during reception of char
                                         // 2 : mode of reception of data by bloc
                                         // 3 : mode of reception of data char by char (proc char)
-                                        // 4 : mode of reception of data char by char (data)                                       
+                                        // 4 : mode of reception of data char by char (data)
                                         // 5 : mode of reception of procedure char SW1/SW2
                                         // 6 : mode of wait for acknowledge char after transmission of char
     SYS_UWORD16       expected_data;          //number of expected char in receive mode proc char
@@ -360,11 +360,11 @@
 
 /*
  * Prototypes
- */ 
+ */
 // obsolete function
 void SIM_Init(void (Insert(SIM_CARD *cP)), void (Remove(void)));
 
-// initialization 
+// initialization
 void        SIM_Initialize(void);
 SYS_UWORD16 SIM_Register(void (Insert(SIM_CARD *cP)), void (Remove(void)));
 SYS_UWORD16 SIM_Reset(SIM_CARD *cP);
@@ -393,7 +393,7 @@
 SYS_UWORD16 SIM_RunGSMAlgo(SYS_UWORD8 *result, SYS_UWORD8 *rand, SYS_UWORD16 *size);
 SYS_UWORD16 SIM_GetResponse(SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *size);
 
-// STK 
+// STK
 SYS_UWORD16 SIM_TerminalProfile(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize);
 SYS_UWORD16 SIM_Fetch(SYS_UWORD8 *result, SYS_UWORD16 len, SYS_UWORD16 *rcvSize);
 SYS_UWORD16 SIM_TerminalResponse(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize);
@@ -412,7 +412,7 @@
 
 /*
  * Internal Prototypes
- */ 
+ */
 void        SIM_WriteBuffer(SIM_PORT *p, SYS_UWORD16 offset, SYS_UWORD16 n);
 SYS_UWORD16 SIM_Result(SIM_PORT *p, SYS_UWORD8 *rP, SYS_UWORD16 *lenP, SYS_UWORD8 offset);
 SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *rP, SYS_UWORD16 *lP);
@@ -444,16 +444,16 @@
 
 /*
  * Global variables
- */ 
+ */
 #ifdef SIM_C
-#define SI_GLOBAL 
+#define SI_GLOBAL
 #else
 #define SI_GLOBAL extern
 #endif
 
 
-SI_GLOBAL SIM_PORT   Sim[1]; 
-SI_GLOBAL NU_TIMER   SIM_timer;  
+SI_GLOBAL SIM_PORT   Sim[1];
+SI_GLOBAL NU_TIMER   SIM_timer;
 SI_GLOBAL STATUS     status_os_sim;
 SI_GLOBAL SYS_UWORD8 SIM_sleep_status;
 
--- a/src/cs/drivers/drv_app/sim/sim32.c	Tue Jan 19 06:10:27 2021 +0000
+++ b/src/cs/drivers/drv_app/sim/sim32.c	Sat Jan 30 06:34:22 2021 +0000
@@ -15,7 +15,7 @@
 
 #include "main/sys_types.h"
 #include <assert.h>
-#include "inth/iq.h" 
+#include "inth/iq.h"
 #include "sim.h"
 
 
@@ -33,8 +33,8 @@
 /*
  * SIM_IntHandler
  *
- * Read cause of SIM interrupt : 
- * 
+ * Read cause of SIM interrupt :
+ *
  * if receive buffer full, read char
  * if transmitter empty, change direction, transmit a dummy char
  *
@@ -42,17 +42,17 @@
 void SIM_IntHandler(void)
 {
    volatile unsigned short it, i, stat, conf1;
-   volatile SYS_UWORD8 ins; 
+   volatile SYS_UWORD8 ins;
    volatile SYS_UWORD8 rx;
    volatile SYS_UWORD8 nack;
    volatile SYS_UWORD8 nack1;
 
-   
+
    SIM_PORT *p;
 
    p = &(Sim[0]);
 
-   p->rxParityErr = 0;   
+   p->rxParityErr = 0;
    it = p->c->it;
 
    if ((it & SIM_IT_ITRX) && !(p->c->maskit & SIM_MASK_RX)) // int on reception
@@ -74,21 +74,21 @@
           rx    = (SYS_UWORD8) (stat & 0x00FF);
           ins   = p->xbuf[1] & p->hw_mask;
           nack  = (~p->xbuf[1]) & p->hw_mask;
-            
+
           switch (p->moderx)
           {
               case 0:                  //mode of normal reception without proc char (like PTS proc)
                   p->rbuf[p->rx_index++] = rx;
-                  break;      
+                  break;
 
               case 1:                  //mode wait for ACK
                   if ((rx & p->hw_mask) == ins)
                   {
                       p->moderx = 2;
-                  }  
+                  }
                   else if ((rx & p->hw_mask) == nack)
                   {
-                      p->moderx = 4;          
+                      p->moderx = 4;
                   }
                   else if (((rx & 0xF0) == 0x60) || ((rx & 0xF0) == 0x90))
                   {
@@ -108,9 +108,9 @@
                   else
                   {
                     p->errorSIM = SIM_ERR_ABNORMAL_CASE2;
-                  }  
+                  }
                                         //if rx = 0x60 wait for ACK
-                  break;      
+                  break;
 
               case 2:                  //mode reception by block
                   p->rbuf[p->rx_index++] = rx;
@@ -121,38 +121,38 @@
                       {
                           p->moderx = 5;
                       }
-                  }	
+                  }
                   else
-                  {  
+                  {
                   if (p->rx_index == p->expected_data)
                   {
                       p->moderx = 5;
                   }
                   }
-                  break;      
-  
+                  break;
+
               case 3:                  //mode reception char by char. reception of proc char
                   if ((rx & p->hw_mask) == ins)
                   {
                       p->moderx = 2;
-                  }            
+                  }
                   else if ((rx & p->hw_mask) == nack)
                   {
-                      p->moderx = 4;          
-                  }                      //if rx = 0x60 wait for ACK  
+                      p->moderx = 4;
+                  }                      //if rx = 0x60 wait for ACK
                   else if (rx == 0x60)
                   {
                       p->null_received == 1;
 #ifdef SIM_DEBUG_TRACE
 		      SIM_dbg_null[1]++;
 #endif
-                  }  
-                    
+                  }
+
                   break;
 
               case 4:                  //mode reception char by char. reception of data
                   p->rbuf[p->rx_index++] = rx;
-                  p->moderx = 3;        //switch to receive proc char mode      
+                  p->moderx = 3;        //switch to receive proc char mode
 
                   if(p->expected_data == 256)
                   {
@@ -162,14 +162,14 @@
                       }
                   }
                   else
-                  {  
+                  {
                   if (p->rx_index == p->expected_data)
                   {
                       p->moderx = 5;
                   }
                   }
                   break;
-              
+
               case 5:                  //mode wait for procedure character except NULL
                   if ((rx != 0x60) || (p->SWcount != 0))  //treat NULL character only if arriving before SW1 SW2
                   {
@@ -185,7 +185,7 @@
 
 
                   break;
-                  
+
               case 6:                  //give the acknowledge char
                   if (((rx & 0xF0) == 0x60) || ((rx & 0xF0) == 0x90))
                   {
@@ -203,7 +203,7 @@
                       }
                   }
                   else
-                  {                     
+                  {
                      p->ack = rx;
                   }
           }
@@ -235,18 +235,18 @@
                 p->conf1 &= ~SIM_CONF1_TXRX;   // return the direction
                 p->c->conf1 = p->conf1;
              }
-             
+
              if (p->xOut < (p->xIn - 2))
              {
                 p->xOut++;
                 p->c->tx = *(p->xOut);         // transmit
-             }                                 
-         }   
+             }
+         }
       }
       else
       {
          p->c->tx = *(p->xOut);            // transmit same char
-         p->txParityErr++;                 // count number of transmit parity errors 
+         p->txParityErr++;                 // count number of transmit parity errors
       }
 
    }
@@ -255,7 +255,7 @@
    if ((it & SIM_IT_ITOV) && !(p->c->maskit & SIM_MASK_OV))
    {
       p->errorSIM = SIM_ERR_OVF;
-      
+
    }
    if ((it & SIM_IT_WT) && !(p->c->maskit & SIM_MASK_WT))
    {
@@ -287,8 +287,8 @@
   /*
    * SIM_CD_IntHandler
    *
-   * Read cause of SIM interrupt : 
-   * 
+   * Read cause of SIM interrupt :
+   *
    */
   void SIM_CD_IntHandler(void)
   {
@@ -297,7 +297,7 @@
 
     p = &(Sim[0]);
 
-    p->rxParityErr = 0;   
+    p->rxParityErr = 0;
     it_cd = p->c->it_cd;
 
     // SIM card insertion / extraction
@@ -317,5 +317,5 @@
 // to force this module to be linked
 SYS_UWORD16 SIM_Dummy(void)
 {
-   
+
 }