FreeCalypso > hg > fc-tourmaline
changeset 191:c1205c437943
../drv_app/sim/sim.c: white space fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 30 Jan 2021 07:34:00 +0000 |
parents | 2e4afc93045d |
children | cf882d95c799 |
files | src/cs/drivers/drv_app/sim/sim.c |
diffstat | 1 files changed, 183 insertions(+), 262 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/sim/sim.c Sat Jan 30 06:43:44 2021 +0000 +++ b/src/cs/drivers/drv_app/sim/sim.c Sat Jan 30 07:34:00 2021 +0000 @@ -46,7 +46,6 @@ SYS_UWORD8 SIM_allow_speed_enhancement = 1; - #ifdef SIM_DEBUG_TRACE #ifdef SIM_RETRY @@ -84,10 +83,6 @@ #endif - - - - /* * Low level routines : mapped to hardware * SIM_WriteBuffer @@ -97,7 +92,6 @@ */ - /* * SIM_WriteBuffer * @@ -160,7 +154,7 @@ len = p->rx_index; *lenP = len - offset; if ((*lenP == 0) && (p->apdu_ans_length == 256)) - *lenP = 256; + *lenP = 256; if (p->expected_data == 256) { @@ -187,9 +181,6 @@ } - - - /* * SIM_Command_base * @@ -204,8 +195,8 @@ * 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 - * with wrapper. Created to manage retries on Internals errors of the driver. + * 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. */ SYS_UWORD16 SIM_Command_Base(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP) @@ -314,7 +305,7 @@ res = SIM_Result(p, dP, lP, 0); - if ((SIM_sleep_status == SIM_SLEEP_DESACT) || (SIM_sleep_status == SIM_SLEEP_ACT)) + if ((SIM_sleep_status == SIM_SLEEP_DESACT) || (SIM_sleep_status == SIM_SLEEP_ACT)) { //enable to count 2.5s before entering in sleep mode status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, SIM_SLEEP_WAITING_TIME, @@ -326,44 +317,41 @@ /* Main function to manage the retry mechanism */ -SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP) { - int res; +SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP) +{ + int res; #ifdef SIM_DEBUG_TRACE - memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); - SIM_dbg_tdma_diff = 0; + memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); + SIM_dbg_tdma_diff = 0; #endif - // Issue initial SIM_Command() call + // Issue initial SIM_Command() call res = SIM_Command_Base(p, n, dP, lP); /* Change from to 10 to 15 for specific SIM card (Racal) */ #ifdef SIM_RETRY // While there is an error then retry NUM_SIM_RETRIES times - while ((res & 0xFF00) == 0) { // Reissue command - p->errorSIM = 0; - if(++SimRetries > NUM_SIM_RETRIES) { // return special retry failure - res = SIM_ERR_RETRY_FAILURE; - break; - } - res = SIM_Command_Base(p, n, dP, lP); + while ((res & 0xFF00) == 0) { // Reissue command + p->errorSIM = 0; + if(++SimRetries > NUM_SIM_RETRIES) { // return special retry failure + res = SIM_ERR_RETRY_FAILURE; + break; } + res = SIM_Command_Base(p, n, dP, lP); + } #ifdef SIM_DEBUG_TRACE - SIM_dbg_null[SIM_DBG_NULL-1] = SimRetries; + SIM_dbg_null[SIM_DBG_NULL-1] = SimRetries; #endif - SimRetries = 0; + SimRetries = 0; #endif return(res); } - - - - /* * SIM_ByteReverse * @@ -375,7 +363,7 @@ SYS_UWORD8 bh, bl; int i; const SYS_UWORD8 Reverse[] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, - 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF }; + 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF }; // Up/Down b = ~ b; @@ -386,7 +374,6 @@ b = (Reverse[bl]) << 4 | Reverse[bh]; return(b); - } /* @@ -400,7 +387,7 @@ { SIM_PORT *p; - p= &(Sim[0]); + p = &(Sim[0]); return(p->txParityErr); } @@ -429,11 +416,6 @@ } - - - - - /* * SIM_Restart * @@ -479,9 +461,9 @@ SYS_UWORD8 Result_ATR; #ifdef SIM_DEBUG_TRACE - memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); - SIM_dbg_cmd_cmpt = 0; - memset(SIM_dbg_cmd, 0x00, SIM_DBG_CMD); + memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); + SIM_dbg_cmd_cmpt = 0; + memset(SIM_dbg_cmd, 0x00, SIM_DBG_CMD); #endif // Initialize pointers @@ -567,18 +549,18 @@ // 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) - { + { if (ATR_Attempt >= 3) - { + { SIM_PowerOff (); return ((SYS_UWORD16)BackValue); - } + } ATR_Attempt++; SIM_WARMReset(p); // assert a reset during at least 400 ETU - } + } 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) @@ -715,23 +697,14 @@ status_os_sim = NU_Control_Timer (&SIM_timer, NU_ENABLE_TIMER); //enable starting of the os timer for sleep mode if (ResetFlag) { - if (p->InsertFunc != NULL) - (p->InsertFunc)(cP); - } - - return(0); + if (p->InsertFunc != NULL) + (p->InsertFunc)(cP); + } + + return(0); } - - - - - - - - - /* SIM manual start * * purpose : manage manual start of the SIM interface @@ -758,10 +731,10 @@ 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; @@ -857,7 +830,6 @@ volatile SYS_UWORD16 cmd; - // Initialize pointers p = &(Sim[0]); @@ -1080,7 +1052,7 @@ { SIM_PORT *p; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1120,7 +1092,7 @@ { SIM_PORT *p; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1157,7 +1129,6 @@ #endif return(res); - } @@ -1263,7 +1234,6 @@ if(p->Freq_Algo) p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKDIV; - return(res); } @@ -1279,7 +1249,7 @@ { SIM_PORT *p; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1415,7 +1385,6 @@ #endif return(res); - } @@ -1471,7 +1440,6 @@ } - /* * SIM_UnblockCHV * @@ -1525,6 +1493,7 @@ return(res); } + /* * SIM_Invalidate * @@ -1567,6 +1536,7 @@ return(res); } + /* * SIM_Rehabilitate * @@ -1608,7 +1578,6 @@ #endif return(res); - } @@ -1622,7 +1591,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1658,7 +1627,6 @@ #endif return(res); - } @@ -1671,7 +1639,7 @@ { SIM_PORT *p; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1703,7 +1671,6 @@ #endif return(res); - } #ifdef SIM_APDU_TEST @@ -1730,7 +1697,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; #ifdef SIM_SAT_REFRESH_TEST // do 1000 times the following sequence @@ -1831,13 +1798,9 @@ snd[3] = 0x00; snd[4] = 0x00; rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], 256, &recl); - - } - #endif - p = &(Sim[0]); p->xbuf[0] = GSM_CLASS; @@ -1872,9 +1835,7 @@ SIM_dbg_write_trace(SIM_dbg_tmp, 2); #endif - #ifdef SIM_APDU_TEST - // send CLOSE LOGICAL CHANNEL snd[0] = 0x00; snd[1] = 0x70; @@ -1882,7 +1843,6 @@ snd[3] = logchan; snd[4] = 0x00; resclose = SIM_XchTPDU(&snd[0], 5, &rec[0], 0, &recl); - #endif return(res); @@ -1899,7 +1859,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -1999,7 +1959,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -2045,7 +2005,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -2055,7 +2015,6 @@ p->xbuf[3] = 0; p->xbuf[4] = (SYS_UWORD8)llen; - res = SIM_Command(p, 0, result, rcvSize); #ifdef SIM_DEBUG_TRACE @@ -2090,7 +2049,7 @@ SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -2129,14 +2088,14 @@ /* * SIM_Envelope * - * Used by Network to tansfert data download to the SIM in a transparent way for user + * Used by Network to transfer data download to the SIM in a transparent way for user */ SYS_UWORD16 SIM_Envelope(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize) { SIM_PORT *p; int i; int res; - SYS_UWORD16 llen = len & SIM_UWORD16_MASK; + SYS_UWORD16 llen = len & SIM_UWORD16_MASK; p = &(Sim[0]); @@ -2176,19 +2135,12 @@ } - - - - - - - /* * SIM_XchTPDU * * Used for ME to send generic command to WIM Card */ SYS_UWORD16 SIM_XchTPDU(SYS_UWORD8 *dat, SYS_UWORD16 trxLen, SYS_UWORD8 *result, - SYS_UWORD16 rcvLen, SYS_UWORD16 *rcvSize) + SYS_UWORD16 rcvLen, SYS_UWORD16 *rcvSize) { SIM_PORT *p; int i; @@ -2207,13 +2159,13 @@ p->xbuf[i] = dat[i]; } - // enable the WIM behavior of the sim driver - p->apdu_ans_length = rcvLen; + // enable the WIM behavior of the sim driver + p->apdu_ans_length = rcvLen; res = SIM_Command(p, (trxLen - 5), result, rcvSize); - // disable the WIM behavior of the sim driver - p->apdu_ans_length = 0; + // 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); @@ -2238,12 +2190,6 @@ } - - - - - - /* * Use to detect end of characters reception * input: p pointer on sim structure @@ -2258,7 +2204,6 @@ { SYS_UWORD16 returncode; - //analyse the nature of the command to execute if ( @@ -2300,7 +2245,6 @@ } - /* * Use to read file characteristics information * input: p pointer on sim structure @@ -2352,44 +2296,44 @@ } //interpret Clock stop behavior - // modified by J. Yp-Tcha to integrate all the behaviors required by ETSI. - // 18/11/2002 : TI Chip always allowed low level, high level is hard dependant - - 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 */ + // modified by J. Yp-Tcha to integrate all the behaviors required by ETSI. + // 18/11/2002 : TI Chip always allowed low level, high level is hard dependant + + 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 */ status_os_sim = NU_Delete_Timer (&SIM_timer); + } + else { + if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_ALLWD) { + /* Sim Clock Stop Allowed, no prefered level */ + /* Default value for TI Chip shall always be Low Level */ + SIM_sleep_status = SIM_SLEEP_DESACT; + p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; } else { - if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_ALLWD) { - /* Sim Clock Stop Allowed, no prefered level */ - /* Default value for TI Chip shall always be Low Level */ - SIM_sleep_status = SIM_SLEEP_DESACT; - p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; - } - else { - /* Clock Stop is allowed, the level shall be checked */ - if ((p->FileC & SIM_CLK_STOP_HIGH) == SIM_CLK_STOP_HIGH) { - /* high level is mandatory */ + /* Clock Stop is allowed, the level shall be checked */ + if ((p->FileC & SIM_CLK_STOP_HIGH) == SIM_CLK_STOP_HIGH) { + /* high level is mandatory */ /* OMEGA/NAUSICA can not handle sim stop clock at high level */ #ifndef ANALOG1 - SIM_sleep_status = SIM_SLEEP_DESACT; - p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKLEV; + SIM_sleep_status = SIM_SLEEP_DESACT; + p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKLEV; #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 */ - status_os_sim = NU_Delete_Timer (&SIM_timer); + /* 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 */ + status_os_sim = NU_Delete_Timer (&SIM_timer); #endif - } - else { - /* by default, Low Level is allowed */ - SIM_sleep_status = SIM_SLEEP_DESACT; - p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; - } - } + } + else { + /* by default, Low Level is allowed */ + SIM_sleep_status = SIM_SLEEP_DESACT; + p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; + } } + } if (SIM_sleep_status == SIM_SLEEP_NONE) { status_os_sim = NU_Delete_Timer (&SIM_timer); @@ -2410,19 +2354,18 @@ SYS_UWORD16 SIM_PTSprocedure(SIM_CARD *cP, SIM_PORT *p) { - SYS_UWORD8 TA1; SYS_UWORD8 n; SYS_UWORD8 err; - p->xbuf[0] = 0xFF; //character of PTS proc to send + p->xbuf[0] = 0xFF; //character of PTS proc to send p->xbuf[1] = 0; p->xbuf[2] = 0xFF; p->xbuf[3] = 0x7B; //TA1,TB1,TC1,TD1 present in ATR ? - n = 3; + n = 3; p->PTS_Try++; @@ -2431,13 +2374,13 @@ 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) + else if (p->PTS_Try == 4) { SIM_Calcetu (p); return (0); } - if(cP->AtrData[1] & 0x10) + if (cP->AtrData[1] & 0x10) { TA1 = cP->AtrData[2]; } @@ -2480,12 +2423,11 @@ } //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])) + (p->rbuf[2] != p->xbuf[2])) { return(SIM_ERR_READ); } - if (n == 4) { if (p->rbuf[3] != p->xbuf[3]) @@ -2499,7 +2441,6 @@ SIM_Calcetu (p); return (0); - } /* @@ -2510,12 +2451,10 @@ void SIM_WARMReset (SIM_PORT *p) { - p->c->conf1 = p->conf1 &= ~SIM_CONF1_SRSTLEV; ind_os_sleep (p->etu400); /// wait 400 ETU p->c->conf1 = p->conf1 |= SIM_CONF1_SRSTLEV; p->rx_index = 0; - } @@ -2535,8 +2474,6 @@ } - - /* * procedure use to get out sleepMode * input p pointer of type SIM_PORT @@ -2568,19 +2505,18 @@ SYS_UWORD16 SIM_ATRdynamictreatement (SIM_PORT *p, SIM_CARD *cP) { - - volatile SYS_UWORD8 HistChar; - volatile SYS_UWORD8 InterfChar; + volatile SYS_UWORD8 HistChar; + volatile SYS_UWORD8 InterfChar; SYS_UWORD16 countT; SYS_UWORD16 mask; SYS_UWORD16 returncode; - SYS_UWORD8 i; - 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; + SYS_UWORD8 i; + 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 @@ -2605,7 +2541,7 @@ return returncode; } - ind_os_sleep(220); + ind_os_sleep(220); if (((p->rbuf[0] & 0xF0) == 0x30) && (p->rx_index != 0)) { @@ -2647,7 +2583,7 @@ { position_of_TC1 = InterfChar - 1; } - if ((firstprotocol == 0) && ((Tx & 0x20) == mask)) + if ((firstprotocol == 0) && ((Tx & 0x20) == mask)) { position_of_TB1 = InterfChar - 1; } @@ -2767,7 +2703,6 @@ } - /* * SIM_Waitforchars is used for waiting nbchar characters from SIM * input p sim port @@ -2818,7 +2753,7 @@ { countT = 0; old_nb_char = p->rx_index; - //leave while if moderx == 5 + //leave while if moderx == 5 while((p->rx_index < p->expected_data) && (p->moderx != 5)) { ind_os_sleep(1); @@ -2844,10 +2779,10 @@ countT = 0; } } //end while - if (p->moderx == 0) - { - return (0); - } + if (p->moderx == 0) + { + return (0); + } } if (p->moderx == 5) //use for reception of SW1 SW2 @@ -2855,7 +2790,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); @@ -2883,16 +2818,14 @@ } p->SWcount = 0; //reset SWcount buffer index when SW1 SW2 received return (0); - } - else //treatement of abnormal case of the asynchronous state machine - { - return (SIM_ERR_ABNORMAL_CASE1); - } - + } + else //treatement of abnormal case of the asynchronous state machine + { + return (SIM_ERR_ABNORMAL_CASE1); + } } - /* * SIM_Calcetu is used for calculating 9600 etu and 400 etu depending on sim clock freq * and etu period @@ -2905,16 +2838,16 @@ { if (p->conf1 & SIM_CONF1_ETU) //etu period is 512/8*Tsclk { - p->etu9600 = 319; // old = 88, increase of 363% - p->etu400 = 6; - p->stopclock = 18; + p->etu9600 = 319; // old = 88, increase of 363% + p->etu400 = 6; + p->stopclock = 18; p->startclock = 8; } else //etu period is 372/1*Tsclk { - p->etu9600 = 1815; // old = 500, increase of 363% - p->etu400 = 28; - p->stopclock = 94; + p->etu9600 = 1815; // old = 500, increase of 363% + p->etu400 = 28; + p->stopclock = 94; p->startclock = 38; } } @@ -2922,25 +2855,22 @@ { if (p->conf1 & SIM_CONF1_ETU) //etu period is 512/8*Tsclk { - p->etu9600 = 159; // old = 44, increase of 363% - p->etu400 = 3; - p->stopclock = 9; + p->etu9600 = 159; // old = 44, increase of 363% + p->etu400 = 3; + p->stopclock = 9; 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->etu9600 = 907; // old = 250, increase of 363% + p->etu400 = 14; + p->stopclock = 47; p->startclock = 19; } } } - - - /* * Set the level shifter voltage for start up sequence * @@ -2948,21 +2878,21 @@ SYS_UWORD8 SIM_StartVolt (SYS_UWORD8 ResetFlag) { - SYS_UWORD8 abbmask; + SYS_UWORD8 abbmask; #if(ANLG_FAM == 1) // we assume that in SIM_TYPE_5V there is nothing to do because it is the reset value #if ((SIM_TYPE == SIM_TYPE_3V) || (SIM_TYPE == SIM_TYPE_3_5V)) // { shut down VCC from ABB and prepare to start at 3V mode - if (ResetFlag) { + if (ResetFlag) { + abbmask = MODE_INIT_OMEGA_3V; + CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. + } + else { + if (CurrentVolt == SIM_3V) abbmask = MODE_INIT_OMEGA_3V; - CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. - } - else { - if (CurrentVolt == SIM_3V) - abbmask = MODE_INIT_OMEGA_3V; - else - abbmask = MODE5V_OMEGA; - } + else + abbmask = MODE5V_OMEGA; + } ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & 0xC0) | abbmask); ind_os_sleep(1); //wait for charge pump regulation return(SIM_OK); @@ -2974,20 +2904,20 @@ // code for Iota // reset value for IOTA is for 1.8V, but specific procedure is needed #if ((SIM_TYPE == SIM_TYPE_1_8V) || (SIM_TYPE == SIM_TYPE_1_8_3V)) // shut down VCC from ABB and prepare to start at 1.8V mode - if (ResetFlag) { + if (ResetFlag) { + abbmask = MODE_INIT_IOTA_1_8V; + CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. + } + else { + if (CurrentVolt == SIM_1_8V) abbmask = MODE_INIT_IOTA_1_8V; - CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. - } - else { - if (CurrentVolt == SIM_1_8V) - abbmask = MODE_INIT_IOTA_1_8V; - else - abbmask = MODE_INIT_IOTA_3V; - } + else + abbmask = MODE_INIT_IOTA_3V; + } ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); while(count++ < 5) { - if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU + if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU return(SIM_OK); ind_os_sleep(1); } @@ -2996,12 +2926,12 @@ #endif // 3V only #if (SIM_TYPE == SIM_TYPE_3V) - abbmask = MODE_INIT_IOTA_3V; - CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. + abbmask = MODE_INIT_IOTA_3V; + CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); while(count++ < 5) { - if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU + if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU return(SIM_OK); ind_os_sleep(1); } @@ -3015,20 +2945,20 @@ // code for Syren // reset value for SYREN is for 1.8V, but specific procedure is needed #if ((SIM_TYPE == SIM_TYPE_1_8V) || (SIM_TYPE == SIM_TYPE_1_8_3V)) // { shut down VCC from ABB and prepare to start at 1.8V mode - if (ResetFlag) { + if (ResetFlag) { + abbmask = MODE_INIT_SYREN_1_8V; + CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. + } + else { + if (CurrentVolt == SIM_1_8V) abbmask = MODE_INIT_SYREN_1_8V; - CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. - } - else { - if (CurrentVolt == SIM_1_8V) - abbmask = MODE_INIT_SYREN_1_8V; - else - abbmask = MODE_INIT_SYREN_3V; - } - ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); + else + abbmask = MODE_INIT_SYREN_3V; + } + ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); while(count++ < 5) { - if (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x04) // test RSIMRSU + if (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x04) // test RSIMRSU return(SIM_OK); ind_os_sleep(1); } @@ -3038,8 +2968,8 @@ // 3V only #if (SIM_TYPE == SIM_TYPE_3V) - abbmask = MODE_INIT_SYREN_3V; - CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. + abbmask = MODE_INIT_SYREN_3V; + CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); while(count++ < 5) { @@ -3063,7 +2993,7 @@ SYS_UWORD8 SIM_SwitchVolt (SYS_UWORD8 ResetFlag) { SYS_UWORD8 count = 0; - SYS_UWORD8 abbmask; + SYS_UWORD8 abbmask; SIM_PowerOff(); @@ -3071,7 +3001,7 @@ #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) @@ -3080,13 +3010,13 @@ abbmask = MODE5V_OMEGA; } ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & 0xC0) | abbmask); - return(SIM_OK); + return(SIM_OK); #endif #elif(ANLG_FAM == 2) #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) @@ -3095,20 +3025,20 @@ abbmask = MODE_INIT_IOTA_3V; } ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); - while(count++ < 5) - { - if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) - return(SIM_OK); - ind_os_sleep(1); - } - // IOTA failure activation - return(SIM_ERR_HARDWARE_FAIL); + while(count++ < 5) + { + if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) + return(SIM_OK); + ind_os_sleep(1); + } + // IOTA failure activation + return(SIM_ERR_HARDWARE_FAIL); #endif #elif(ANLG_FAM == 3) #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) @@ -3127,31 +3057,28 @@ return(SIM_ERR_HARDWARE_FAIL); #endif #endif // ANLG_FAM == 1, 2, 3 - } - SYS_UWORD8 SIM_Memcpy(SYS_UWORD8 *Buff_target, SYS_UWORD8 Buff_source[], SYS_UWORD16 len) { SYS_UWORD16 i; //unsigned short type counter chosen for copy of 256 bytes for (i = 0; i < len; i++) - { - if (i == RSIMBUFSIZE) - { - return (SIM_ERR_BUFF_OVERFL); - } - else - { - (*(Buff_target+i)) = Buff_source[i]; - } + { + if (i == RSIMBUFSIZE) + { + return (SIM_ERR_BUFF_OVERFL); + } + else + { + (*(Buff_target+i)) = Buff_source[i]; + } } return (0); } - /* * SIM_SleepStatus * @@ -3167,8 +3094,6 @@ } - - /* * Special lock function to force SIM entity to use adequat SIM Driver */ @@ -3182,11 +3107,7 @@ for(i=0;i<len;i++) { if (SIM_dbg_cmd_cmpt == SIM_DBG_CMD) SIM_dbg_cmd_cmpt = 0; - SIM_dbg_cmd[SIM_dbg_cmd_cmpt++] = ptr[i]; + SIM_dbg_cmd[SIM_dbg_cmd_cmpt++] = ptr[i]; } } #endif - - - -