FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/bsp/sim.c @ 923:10b4bed10192
gsm-fw/L1: fix for the DSP patch corruption bug
The L1 code we got from the LoCosto fw contains a feature for DSP CPU load
measurement. This feature is a LoCosto-ism, i.e., not applicable to earlier
DBB chips (Calypso) with their respective earlier DSP ROMs. Most of the
code dealing with that feature is conditionalized as #if (DSP >= 38),
but one spot was missed, and the MCU code was writing into an API word
dealing with this feature. In TCS211 this DSP API word happens to be
used by the DSP code patch, hence that write was corrupting the patched
DSP code.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 19 Oct 2015 17:13:56 +0000 |
parents | 14826aa2db26 |
children |
rev | line source |
---|---|
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * SIM.C |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * Pole Star SIM |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * Target : ARM |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 * SIM card driver. This module contents all functions |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 * included in specifications GSM 11.11 V4.10 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 * Copyright (c) Texas Instruments 1995-1997 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #define SIM_C 1 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
19 #include "../include/config.h" |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
20 #include "../include/sys_types.h" |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
21 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
22 #include "mem.h" |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
23 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 #if (CHIPSET == 12) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
25 #include "sys_inth.h" |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 #else |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
27 #include "iq.h" |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 #include "sim.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 #include <string.h> |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
31 #include "armio.h" |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
32 #include "../L1/cust0/ind_os.h" |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
33 #include "abb+spi/abb.h" //controls level shifter of ABB |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 //current voltage mode 3V or 5V, or 1.8V |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 SYS_UWORD8 CurrentVolt; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 #ifdef SIM_DEBUG_TRACE |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 #ifdef SIM_RETRY |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 /* one byte more to trace the number of retry for each functions */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 #define SIM_DBG_NULL 5 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 #else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 /* size of buffer tracing the reception of NULL byte */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #define SIM_DBG_NULL 4 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 /* working buffer for NULL BYTE and number of RETRY */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 SYS_UWORD8 SIM_dbg_null[SIM_DBG_NULL]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 /* size of buffer tracing the chronology of calls */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 #define SIM_DBG_CMD 7500 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 /* working buffer for chronology calls */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 SYS_UWORD8 SIM_dbg_cmd[SIM_DBG_CMD]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 /* index for positionning in working buffer for chronology calls */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 SYS_UWORD16 SIM_dbg_cmd_cmpt; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 /* working variable to calculate the TDMA ecart */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 SYS_UWORD16 SIM_dbg_tdma_diff; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 /* working variable to store the maximum TDMA frame between two characters */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 SYS_UWORD16 SIM_dbg_max_interchardelay; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 /* working variable used in each L2/L3 access function */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 SYS_UWORD8 SIM_dbg_tmp[10]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 /* internal function due to factorization of use of traces */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 void SIM_dbg_write_trace(SYS_UWORD8 *ptr, SYS_UWORD16 len); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 #ifdef SIM_RETRY |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 /* number of retry */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 #define NUM_SIM_RETRIES 10 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 /* Add variables to support sim retry */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 SYS_UWORD8 SimRetries; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 * Low level routines : mapped to hardware |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 * SIM_WriteBuffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 * SIM_Command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 * SIM_Reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 * SIM_WriteBuffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 * Write n bytes to SIM card in interrupt mode: |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 * return the line, write first byte and let interrupt handler do the rest |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 * return the line, write first byte and let interrupt handler do the rest |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 * Parameters : |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 * SIM_PORT *p : buffer for received chars |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 * offset : starting point for reading data. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 * n : number of chars to read. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 void SIM_WriteBuffer(SIM_PORT *p, SYS_UWORD16 offset, SYS_UWORD16 n) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 unsigned volatile i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 // Set write direction |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 p->conf1 |= SIM_CONF1_TXRX; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 p->c->conf1 = p->conf1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 p->SWcount = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 p->rx_index = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 p->expected_data = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 p->xOut = p->xbuf + offset; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 p->xIn = p->xbuf + offset + n; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 if ((p->xIn - p->xOut) == 1) //if only one char is transmitted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 { //need to wait a minimum of 1 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 ind_os_sleep (1); //for IO line to stay in TX mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 // Write first byte |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 p->c->tx = *(p->xOut); // transmit |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 if ((p->xIn - p->xOut) == 1) //if only one char to transmit |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 { // return the direction to rx |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 p->conf1 &= ~SIM_CONF1_TXRX; //to be able to receive ACK char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 p->c->conf1 = p->conf1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 * SIM_Result |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 * Parameters : SIM port, buffer for received chars, pointer to receive size |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 * Return the result code (SW1/SW2) at the end of the string |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 SYS_UWORD16 SIM_Result(SIM_PORT *p, SYS_UWORD8 *rP, SYS_UWORD16 *lenP, SYS_UWORD8 offset) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 SYS_UWORD8 sw1, sw2; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 SYS_UWORD8 verdict; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 SYS_UWORD16 len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 // Check if all characters were transmitted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 if (p->xIn - 1 != p->xOut) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 return (SIM_ERR_XMIT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 len = p->rx_index; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 *lenP = len - offset; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 if ((*lenP == 0) && (p->apdu_ans_length == 256)) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
148 *lenP = 256; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 if (p->expected_data == 256) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 verdict = SIM_Memcpy(rP, ((p->rbuf) + offset), 256 - offset); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 if (verdict != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 return (verdict); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 else if ((len != 0) && (len >= offset)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 verdict = SIM_Memcpy(rP, ((p->rbuf) + offset), len - offset); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 if (verdict != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 return (verdict); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 // change to remove SW1 and SW2 bytes from the receive buffer of data |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 sw1 = p->rSW12[0]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 sw2 = p->rSW12[1]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 return((sw1 << 8) | sw2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 * SIM_Command_base |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 * Perform a command with the SIM T=0 protocol |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 * Arguments : pointer to SIM port structure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 * number of characters above 5 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 * expected command time in TDMA |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 * Returns an error code : |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 * SIM_ERR_READ : no answer from the card to a command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 * SIM_ERR_LEN : the answer is not corresponding to a |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 * correct answer of T=0 protocol |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 * 06/11/2002 JYT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 * Modified to be base command function. New SIM_Command() created to call it |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 * with wrapper. Created to manage retries on Internals errors of the driver. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
192 SYS_UWORD16 SIM_Command_Base(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
193 SYS_UWORD16 *lP) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 SYS_UWORD16 res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 SYS_UWORD8 err; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 SYS_UWORD8 ins; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 SYS_UWORD8 nack; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 SYS_UWORD8 nack1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 SYS_UWORD16 offset; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 if (SIM_sleep_status == SIM_SLEEP_DESACT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 { //freeze the timer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 status_os_sim = NU_Control_Timer (&SIM_timer, NU_DISABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 else if (SIM_sleep_status == SIM_SLEEP_ACT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 { //get out sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 status_os_sim = NU_Control_Timer (&SIM_timer, NU_DISABLE_TIMER); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
209 SIM_SleepMode_Out (p); //get up SIM card of sleep mode |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
210 // before executing the command |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 SIM_WriteBuffer(p, 0, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 //adaptative driver |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 if (n > 0) //need to send data to the card, TX mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 offset = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 // protocol T=0 returns a acknowledge char which is |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 // ins or (ins+1) : transmit the rest of the command in one time |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 // ~ins or ~(ins+1) : transmit the rest of the command char by char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 ins = p->xbuf[1] & p->hw_mask; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 nack = (~p->xbuf[1]) & p->hw_mask;; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 p->moderx = 6; //mode of wait for ACK char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 NEXT_CHAR_PROC: |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 if (err = SIM_Waitforchars(p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
232 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
233 (SIM_sleep_status == SIM_SLEEP_ACT)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 { //enable to count 2.5s before entering in sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 SIM_SLEEP_WAITING_TIME, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 0, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 if (p->moderx == 5) //return SW1/SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 res = SIM_Result(p, dP, lP, 0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
246 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
247 (SIM_sleep_status == SIM_SLEEP_ACT)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 { //enable to count 2.5s before entering in sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 SIM_SLEEP_WAITING_TIME, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 0, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 else if ((p->ack & p->hw_mask) == ins) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 // Write the rest of the command if needed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 // if more than 5 characters, the ack character will disappear |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 SIM_WriteBuffer(p, 5 + offset, n - offset); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 // special transmission mode if ACK = ~INS or ~(INS + 1). |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 // refer to ISO/CEI 7816-3 [8.2.2] |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 // need to send char by char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 else if ((p->ack & p->hw_mask) == nack) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 SIM_WriteBuffer(p, 5 + offset, 1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 offset++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 goto NEXT_CHAR_PROC; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 p->moderx = 5; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 if (err = SIM_Waitforchars (p, p->etu9600)) //wait SW1 / SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
276 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
277 (SIM_sleep_status == SIM_SLEEP_ACT)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 { //enable to count 2.5s before entering in sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 SIM_SLEEP_WAITING_TIME, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 0, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 else //receive mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
288 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 if (err = SIM_WaitReception(p)) //wait for next procedure character |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
290 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
291 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
292 (SIM_sleep_status == SIM_SLEEP_ACT)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 { //enable to count 2.5s before entering in sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 SIM_SLEEP_WAITING_TIME, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 0, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
298 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 res = SIM_Result(p, dP, lP, 0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
304 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
305 (SIM_sleep_status == SIM_SLEEP_ACT)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
306 { //enable to count 2.5s before entering in sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 status_os_sim = NU_Reset_Timer (&SIM_timer, SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 SIM_SLEEP_WAITING_TIME, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 0, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
312 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
314 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
315 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 /* Main function to manage the retry mechanism */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
317 SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
318 SYS_UWORD16 *lP) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
319 { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
320 int res; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
323 memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
324 SIM_dbg_tdma_diff = 0; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
327 // Issue initial SIM_Command() call |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 res = SIM_Command_Base(p, n, dP, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 /* Change from to 10 to 15 for specific SIM card (Racal) */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 #ifdef SIM_RETRY |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 // While there is an error then retry NUM_SIM_RETRIES times |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
333 while ((res & 0xFF00) == 0) { // Reissue command |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
334 p->errorSIM = 0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
335 if(++SimRetries > NUM_SIM_RETRIES) { // return special retry failure |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
336 res = SIM_ERR_RETRY_FAILURE; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
337 break; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
339 res = SIM_Command_Base(p, n, dP, lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
340 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
343 SIM_dbg_null[SIM_DBG_NULL-1] = SimRetries; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
346 SimRetries = 0; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 * SIM_ByteReverse |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 * Reverse a byte, both up/down (1 <> 0) and left/right (0001 <> 1000) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 SYS_UWORD8 SIM_ByteReverse(SYS_UWORD8 b) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 SYS_UWORD8 bh, bl; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 const SYS_UWORD8 Reverse[] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF }; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 // Up/Down |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 b = ~ b; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 // left / right (by nibble) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 bh = (b >> 4) & 0xF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 bl = b & 0xF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 b = (Reverse[bl]) << 4 | Reverse[bh]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 return(b); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 * SIM_TxParityErrors |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
379 * return number of transmit parity errors occured since the last reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 * of the SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 SYS_UWORD16 SIM_TxParityErrors(void) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 p= &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 return(p->txParityErr); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
392 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 * SIM_Reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
396 * Reset SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 * Call-back SIM insert if successful |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 * or SIM remove otherwise |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 * Returns 0 for success, or |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 * SIM_ERR_NOCARD : no card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 * SIM_ERR_NATR : no answer to reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 * SIM_ERR_NOINT : no |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 * SIM_ERR_READ : unknown data return by the card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 * SIM_ERR_CARDREJECT : card not accepted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 * 29/01/02, JYT, adding of low voltage managment for IOTA device |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 * 06/10/03, JYT, Split of Reset to handle Restart |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 SYS_UWORD16 SIM_Reset(SIM_CARD *cP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
412 return(SIM_Reset_Restart_Internal(cP, 1)); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
413 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
416 * SIM_Restart |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 * Restart SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
420 * Returns 0 for success, or |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 * SIM_ERR_NOCARD : no card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 * SIM_ERR_NATR : no answer to reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 * SIM_ERR_NOINT : no |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
424 * SIM_ERR_READ : unknown data return by the card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
425 * SIM_ERR_CARDREJECT : card not accepted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
426 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
427 * 06/10/03, JYT, Split of Reset to handle Restart |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
428 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
429 SYS_UWORD16 SIM_Restart(SIM_CARD *cP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
430 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
431 return(SIM_Reset_Restart_Internal(cP, 0)); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
433 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
436 * SIM_Reset_Restart_Internal |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 * Reset SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
439 * Call-back SIM insert if successful |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
440 * or SIM remove otherwise |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
441 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
442 * Returns 0 for success, or |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
443 * SIM_ERR_NOCARD : no card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
444 * SIM_ERR_NATR : no answer to reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 * SIM_ERR_NOINT : no |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
446 * SIM_ERR_READ : unknown data return by the card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 * SIM_ERR_CARDREJECT : card not accepted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
448 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 * 29/01/02, JYT, adding of low voltage managment for IOTA device |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
450 * 06/10/03, JYT, Split of Reset to handle Restart, ResetFlag added. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
451 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
452 SYS_UWORD16 SIM_Reset_Restart_Internal(SIM_CARD *cP, SYS_UWORD8 ResetFlag) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
453 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
454 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
455 unsigned int ATR_Attempt; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 SYS_UWORD8 BackValue; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
457 SYS_UWORD8 Result_ATR; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
458 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
459 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
460 memset(SIM_dbg_null, 0x00, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
461 SIM_dbg_cmd_cmpt = 0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
462 memset(SIM_dbg_cmd, 0x00, SIM_DBG_CMD); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
463 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
464 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
465 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 // begin of JYT modifications |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 if ( (BackValue = SIM_StartVolt(ResetFlag)) != SIM_OK) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 return((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 // end of JYT modifications |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
473 p->etu9600 = 867; // old = 239, increase of 363% |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
474 p->etu400 = 20; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
475 p->hw_mask = MASK_INS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
476 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 ATR_Attempt = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
478 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
479 COLD_RESET: |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
480 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
481 p->SWcount = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 p->Freq_Algo = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 p->PTS_Try = 0; //use to calculate how many PTS try were already done |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
485 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
486 p->xIn = p->xOut = p->xbuf; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
487 p->rx_index = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
488 p->errorSIM = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
489 p->moderx = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
490 p->null_received = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
492 BackValue = SIM_ManualStart(p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
493 if (BackValue != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
494 return ((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
495 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
496 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
497 p->c->conf1 = p->conf1 &= ~SIM_CONF1_BYPASS; //switch to automatic mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
498 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
499 //#else //SW_WRK_AROUND_H_S == 0 // Automatic procedure -> fails with test 27.11.2.1 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
500 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
501 // // Mask all interrupts |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
502 // p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV | |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
503 // SIM_MASK_TX | SIM_MASK_RX | SIM_MASK_CD; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
505 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
506 // IQ_Unmask (IQ_SIM); // Unmask interrupt controller |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
507 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
508 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
509 // p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_STOP; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 // ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
511 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
512 // p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_SWRST; // Set START bit and wait a while |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
513 // ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
514 // // Unmask all sources of interrupts except WT, OV, and NATR |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
515 // p->c->maskit = SIM_MASK_OV | SIM_MASK_WT | SIM_MASK_NATR; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
516 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
517 // // Set Configuration bits |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
518 // p->c->conf1 = p->conf1 = SIM_CONF1_SRSTLEV | SIM_CONF1_SCLKEN; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
519 // p->c->conf2 = 0x0940; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
520 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
521 // //enable VCC |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
522 // #if(ANALOG == 1) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 // SPIABB_wa_VRPC (SPIRead_ABB_Register (PAGE1,VRPCCTRL1) | MODE_ENA_VCC); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
524 // #elif(ANALOG == 2) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
525 // SPIABB_wa_VRPC (SPIRead_ABB_Register (PAGE1,VRPCSIM) | MODE_ENA_VCC); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 // #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
527 // p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_START; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
529 //#endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
530 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
531 /*-----------------------------------------------------------*/ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
532 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
533 while (p->PTS_Try != 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
534 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 while (ATR_Attempt != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
536 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
537 // Treat ATR response |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
538 BackValue = SIM_ATRdynamictreatement (p, cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
539 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
540 if (BackValue == SIM_ERR_NOCARD) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
542 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
543 return (SIM_ERR_NOCARD); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
544 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
545 // ATR received but wrong characters value |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
546 // Comply with Test 27.11.2.4.5 and Test 27.11.1.3 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 else if (BackValue == SIM_ERR_CARDREJECT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
548 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
549 if (ATR_Attempt >= 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
550 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
551 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
552 return ((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
553 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
554 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
556 SIM_WARMReset(p); // assert a reset during at least 400 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
557 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
558 else if (BackValue != 0) //SIM_ERR_WAIT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
559 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 if (ATR_Attempt == 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 { // switch to 5V (ANALOG1) or 3V (ANALOG2) if card send wrong ATR 3 consecutive times |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
562 // Apply 3 consecutive resets at 5V (ANALOG1) or 3V (ANALOG2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 // fix prb for old chinese card not GSM compliant |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
564 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
565 if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
566 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
567 // SIM cannot be supplied at 3V (ANALOG2), because of an Hardware failure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
568 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
569 return((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
570 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
571 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
572 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 goto COLD_RESET; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
574 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
575 if (ATR_Attempt >= 6) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
576 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
577 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 return ((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
579 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
580 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
581 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
582 SIM_WARMReset(p); // assert a reset during at least 400 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
583 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
584 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
585 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
586 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 ATR_Attempt = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
588 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
589 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
590 /*-----------------------------------------------------------*/ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
591 // PTS procedure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
592 BackValue = SIM_PTSprocedure(cP,p); //assert PTS if needed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 // need upgrade with FIFO use to avoid CPU overloading |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
594 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
595 if (BackValue) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
597 if (BackValue == SIM_ERR_CARDREJECT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
598 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
599 SIM_PowerOff (); //must be done by protocol stack |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
600 return (SIM_ERR_CARDREJECT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
601 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 if (p->PTS_Try <= 4) //else error treatement |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 SIM_WARMReset(p); // assert a reset during at least 400 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
606 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
608 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
609 p->PTS_Try = 5; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
611 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
612 /*-----------------------------------------------------------*/ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
614 //interpret SIM coding concerning SIM supply voltage |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
616 if (SIM_GetFileCharacteristics(p)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
617 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
618 #if ((SIM_TYPE == SIM_TYPE_3V) || (SIM_TYPE == SIM_TYPE_1_8V)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
619 SIM_PowerOff(); // Needed for tests 27.17.1.5.1 and 27.17.1.5.5 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
621 return (SIM_ERR_READ); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
622 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
623 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 // JYT, certainly unused because of previous test |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 if(p->errorSIM) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
626 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
627 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
628 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
629 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
630 if ((p->FileC & SIM_MASK_INFO_VOLT) == SIM_5V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
631 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
632 #if ((SIM_TYPE == SIM_TYPE_3V ) || (SIM_TYPE == SIM_TYPE_1_8_3V) || (SIM_TYPE == SIM_TYPE_1_8V)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
633 SIM_PowerOff (); // required by ETSI if 5V only card is detected and 3V only ME chosen |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 return (SIM_ERR_CARDREJECT); // Test 27.17.1.5.2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
635 #elif (SIM_TYPE == SIM_TYPE_3_5V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 if (CurrentVolt == SIM_3V) //if 5V only SIM present -> the ME may switch to 5V operation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
637 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
638 if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) // switch to 5V |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
639 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
640 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 return ((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
642 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
643 ATR_Attempt = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
644 goto COLD_RESET; // Test 27.17.1.5.3 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
646 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
647 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
648 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
649 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
650 if ((p->FileC & SIM_MASK_INFO_VOLT) == SIM_3V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
651 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
652 #if (SIM_TYPE == SIM_TYPE_1_8V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
653 SIM_PowerOff (); // required by ETSI if 3V only card is detected and 1.8V only ME chosen |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
654 return (SIM_ERR_CARDREJECT); // Test 27.17.1.5.2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
655 #elif (SIM_TYPE == SIM_TYPE_1_8_3V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 if (CurrentVolt == SIM_1_8V) //if 3V only SIM present -> the ME may switch to 3V operation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
657 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 if ((BackValue = SIM_SwitchVolt(ResetFlag)) != SIM_OK) // switch to 3V |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
659 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
660 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 return ((SYS_UWORD16)BackValue); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
662 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
663 ATR_Attempt = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
664 goto COLD_RESET; // Test 27.17.1.5.3 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
665 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
666 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
667 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
668 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
669 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
670 if ((p->FileC & SIM_MASK_INFO_VOLT) == SIM_1_8V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
671 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
672 #if (SIM_TYPE == SIM_TYPE_5V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
673 SIM_PowerOff (); // required by ETSI if 5V only card is detected and 3V only ME chosen |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
674 return (SIM_ERR_CARDREJECT); // Test 27.17.1.5.2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
675 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
677 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
678 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
679 // future class of sim card voltage !!!!!! never use it |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
680 SIM_PowerOff (); // Rec. 11.18 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
681 return (SIM_ERR_CARDREJECT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
682 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
683 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
685 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
686 SIM_Interpret_FileCharacteristics(p); //find which frequency (13/4 or 13/8 Mhz) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
687 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
688 if(p->errorSIM) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
689 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
690 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
691 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
692 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
693 status_os_sim = NU_Control_Timer (&SIM_timer, NU_ENABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
694 //enable starting of the os timer for sleep mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 if (p->InsertFunc != NULL) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 (p->InsertFunc)(cP); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
698 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
699 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
700 return(0); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
701 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
702 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
703 /* SIM manual start |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
704 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
705 * purpose : manage manual start of the SIM interface |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 * input : pointer on sim structure SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
707 * output : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
709 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 SYS_UWORD16 SIM_ManualStart (SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
711 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
712 volatile int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
713 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 //!! |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
715 p->c->conf1 = p->conf1 = 0x8004; //set conf1 to automatic mode SIO low |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 //enable sim interface clock module |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 p->c->cmd = SIM_CMD_CLKEN; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 //#if (SW_WRK_AROUND_H_S == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
720 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
721 // Mask all interrupts |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 p->c->maskit = SIM_MASK_NATR | SIM_MASK_WT | SIM_MASK_OV | |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 SIM_MASK_TX | SIM_MASK_RX | SIM_MASK_CD; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
724 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
725 // Unmask interrupt controller |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 IQ_Unmask (IQ_SIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
727 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
728 p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_STOP; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
729 ind_os_sleep (4); //wait 5 TDMA due to SVCC falling down duration |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
730 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
731 p->c->cmd = (p->c->cmd & MASK_CMD) | SIM_CMD_SWRST; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
732 ind_os_sleep (1); //wait 5 TDMA due to SVCC falling down duration |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
734 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
735 p->c->conf2 = 0x0940; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
736 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
737 i = p->c->it; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
738 // Unmask all sources of interrupts except WT and OV and NATR |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
739 p->c->maskit = SIM_MASK_WT | SIM_MASK_OV | SIM_MASK_NATR; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
741 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 //enter in manual mode to start the ATR sequence |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
743 p->c->conf1 = p->conf1 |= SIM_CONF1_BYPASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
744 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
745 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
746 p->c->conf1 = p->conf1 |= SIM_CONF1_SVCCLEV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
747 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
748 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
749 #if(ANALOG == 1) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
750 //set OMEGA to 3V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
751 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
752 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) | MODE_ENA_SIMLDOEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
754 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) | MODE_ENA_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
755 ind_os_sleep(1); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
756 #elif(ANALOG == 2) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
757 //set IOTA to 3V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
758 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
759 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) | MODE_ENA_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
760 ind_os_sleep(1); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
761 #elif(ANALOG == 3) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 //set SYREN to 3V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
764 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) | MODE_ENA_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
765 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
766 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
767 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
768 p->c->conf1 = p->conf1 &= ~SIM_CONF1_SIOLOW; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
769 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
770 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
771 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
772 p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKEN; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
773 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
774 p->c->conf1 = p->conf1 &= ~SIM_CONF1_TXRX; //set to receive mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
776 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
777 if(p->errorSIM) //check for card detection |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
778 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
779 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
780 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
781 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
782 i = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
783 while ((p->rx_index == 0) && (i < 3)) //wait 40000*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
784 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
785 ind_os_sleep (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
786 i++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
788 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
789 if ((p->rx_index == 0) && (i >= 3)) //external reset card ATR treatement |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
790 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
791 i = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
792 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
793 p->c->conf1 = p->conf1 |= SIM_CONF1_SRSTLEV;//set reset level to high level |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
794 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 while ((p->rx_index == 0) && (i < 3)) //wait 40000*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
796 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
797 ind_os_sleep (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
798 i++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
799 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
800 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
801 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
802 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
803 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
804 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
805 /* SIM manual stop |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
806 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
807 * purpose : manage manual start of the SIM interface |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
808 * input : pointer on sim structure SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
809 * output : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
811 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
812 void SIM_ManualStop (SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
813 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
814 // to write |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
815 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
816 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
817 /* Power off SIM == SIM_CMD_STOP |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
818 * input : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
819 * output : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
820 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
821 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
822 void SIM_PowerOff(void) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
824 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
825 volatile SYS_UWORD16 cmd; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
826 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
829 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
830 // Reset and wait a while |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
831 cmd = p->c->cmd; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
832 p->c->cmd = (cmd & MASK_CMD) | SIM_CMD_STOP; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
834 ind_os_sleep(5); //wait for falling of SIM signals (RESET/CLK/IO) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
835 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
836 #if(ANALOG == 1) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
837 //disable VCC : disable level shifter then SVDD |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
838 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & MODE_DIS_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
839 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & MODE_DIS_SIMLDOEN); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
840 #elif(ANALOG == 2) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
841 //disable VCC : disable level shifter then SVDD |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
842 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & MODE_DIS_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
843 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & MODE_DIS_SIMLDOEN); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
844 #elif(ANALOG == 3) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 //disable VCC : disable level shifter then SVDD |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
846 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & MODE_DIS_SIMEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
847 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & MODE_DIS_SIMLDOEN); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
848 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
849 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
850 ind_os_sleep(10); //wait for falling of VCC commanf by ABB |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
851 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
852 p->c->cmd = 0x0000; //disable clock of sim module |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
853 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
854 if ((SIM_sleep_status == SIM_SLEEP_DESACT) || (SIM_sleep_status == SIM_SLEEP_ACT)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
855 { //SIM sleep timer is not more needed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
856 status_os_sim = NU_Delete_Timer (&SIM_timer); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
857 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
858 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
859 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
860 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
861 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
862 * SIM_Init |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
863 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
864 * Function for backward compatibility only |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
865 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
866 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
867 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
868 void SIM_Init(void (Insert(SIM_CARD *cP)), void (Remove(void))) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
869 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
870 // Call SIM Registration function. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
871 (void) SIM_Register (Insert, Remove); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
872 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
873 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
874 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
875 * SIM_Initialize |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
876 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
877 * Initialize data structures. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
878 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
879 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
880 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
881 void SIM_Initialize(void) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
882 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 int n; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
884 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
885 volatile SYS_UWORD32 dum; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
886 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
887 // Initialize registers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
888 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 p->c = (SIM_CONTROLLER *) SIM_CMD; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
890 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
891 p->errorSIM = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
892 dum = (volatile SYS_UWORD32) SIM_Dummy; // to force linking SIM32 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 status_os_sim = NU_Create_Timer (&SIM_timer, "SIM_sleep_timer", &SIM_SleepMode_In, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
895 0, SIM_SLEEP_WAITING_TIME, 0, NU_DISABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
896 //timer start only with NU_Control_Timer function |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
897 //waiting time set to 2.3s |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
898 SIM_sleep_status = SIM_SLEEP_NONE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
899 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
900 #ifdef SIM_RETRY |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
901 SimRetries = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
902 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
903 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
904 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
905 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
906 * SIM_Register |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
907 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
908 * SIM Registration function: Initialize callback functions |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
909 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 * Insert(void) : pointer to the function called when a card is inserted |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 * Remove(void) : pointer to the function called when the card is removed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
912 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
913 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
914 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
915 SYS_UWORD16 SIM_Register(void (Insert(SIM_CARD *cP)), void (Remove(void))) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
916 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
917 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
920 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
921 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
922 p->InsertFunc = Insert; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
923 p->RemoveFunc = Remove; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
924 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
925 return (SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
926 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
927 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
928 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
929 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
930 * High level routines : mapped to GSM 11.11 function calls |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
931 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
932 * Uses a Nucleus semaphore to ensure no simultaneous access to SIM and buffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
934 * Each routine does : |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 * write command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
936 * sleep long enough for the expected transmission and reception |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
937 * return rest code |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
938 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
939 * SYS_UWORD8 *result : pointer to the string return by the SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
940 * SYS_UWORD8 *rcvSize : size of the string return by the SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
942 * other parameters : parameters needed by the SIM card to |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
943 * execute the function. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
944 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
945 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
946 //unsigned char SIM_flag = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
947 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
948 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
949 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
950 * SIM_Select |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
952 * Select a DF or a EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
954 SYS_UWORD16 SIM_Select(SYS_UWORD16 id, SYS_UWORD8 *dat, SYS_UWORD16 *rcvSize) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
955 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
957 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
958 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
959 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
960 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
961 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
962 p->xbuf[1] = SIM_SELECT; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
963 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
964 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 p->xbuf[4] = 2; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
966 p->xbuf[5] = id >> 8; // high byte |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
967 p->xbuf[6] = id & 0xFF; // low byte |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
968 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
969 res = SIM_Command(p, 2, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 /* Change from to 10 to 15 for specific SIM card (Racal) */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
971 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
972 // if (id == 0x6F07) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
973 // SIM_flag = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
974 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
975 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
976 SIM_dbg_write_trace((SYS_UWORD8 *)"AACMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
977 SIM_dbg_write_trace(p->xbuf, 7); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
978 SIM_dbg_write_trace((SYS_UWORD8 *)"AAANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
979 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
980 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
981 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
982 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
983 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
984 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
985 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
986 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
987 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
988 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
989 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
990 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
991 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
993 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
994 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
995 * SIM_Status |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
996 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
997 * Returns data received from card and number of bytes received |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
998 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
999 SYS_UWORD16 SIM_Status(SYS_UWORD8 *dat, SYS_UWORD16 *rcvSize) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1000 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1001 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1002 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1003 short len = 0x16; // length specified in GSM 11.11 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1005 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1006 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1007 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1008 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1009 p->xbuf[1] = SIM_STATUS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1012 p->xbuf[4] = len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1013 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 res = SIM_Command(p, 0, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1015 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1016 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1017 SIM_dbg_write_trace((SYS_UWORD8 *)"ABCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1018 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1019 SIM_dbg_write_trace((SYS_UWORD8 *)"ABANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1020 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1021 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1022 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1023 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1024 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1025 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1026 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1027 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1028 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1029 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1030 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1032 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1034 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1035 * SIM_Status_Extended |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1036 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1037 * Returns data received from card and number of bytes received |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 * Add extra parameter len : number of returned byte |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1039 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1040 SYS_UWORD16 SIM_Status_Extended(SYS_UWORD8 *dat, SYS_UWORD16 len, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1041 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1042 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1043 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1044 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1045 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1046 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1047 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1048 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1049 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1050 p->xbuf[1] = SIM_STATUS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1052 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1054 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1055 res = SIM_Command(p, 0, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1056 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1057 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1058 SIM_dbg_write_trace((SYS_UWORD8 *)"ACCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1059 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1060 SIM_dbg_write_trace((SYS_UWORD8 *)"ACANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1061 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1062 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1063 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1064 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1065 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1066 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1067 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1068 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1069 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1070 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1071 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1072 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1073 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1075 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1076 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1077 * SIM_ReadBinary |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1078 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1079 * Read data from the current EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1080 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1081 SYS_UWORD16 SIM_ReadBinary(SYS_UWORD8 *dat, SYS_UWORD16 offset, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1082 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1083 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1084 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1085 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1086 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1087 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1088 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1089 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1091 p->xbuf[1] = SIM_READ_BINARY; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1092 p->xbuf[2] = offset >> 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1093 p->xbuf[3] = offset & 0xFF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1096 res = SIM_Command(p, 0, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1097 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1098 // if (SIM_flag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 // SIM_flag = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1100 // dat[0] = 0x08; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 // } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1102 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1103 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1104 SIM_dbg_write_trace((SYS_UWORD8 *)"ADCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1105 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1106 SIM_dbg_write_trace((SYS_UWORD8 *)"ADANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1107 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1108 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1109 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1110 SIM_dbg_write_trace(dat, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1111 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1112 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1113 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1114 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1115 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1116 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1117 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1118 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1119 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1120 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1121 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1122 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1123 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1124 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1125 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1126 * SIM_VerifyChv |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1127 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 * Verify the specified CHV (chvType) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1129 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1130 SYS_UWORD16 SIM_VerifyCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1131 SYS_UWORD8 chvType, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1132 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1133 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1134 SYS_UWORD8 len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1135 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1137 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1138 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1139 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1140 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1142 p->xbuf[1] = SIM_VERIFY_CHV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1144 p->xbuf[3] = chvType; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1145 p->xbuf[4] = len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1146 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1147 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1148 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1149 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 res = SIM_Command(p, 8, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1151 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1152 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1153 SIM_dbg_write_trace((SYS_UWORD8 *)"AECMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1154 SIM_dbg_write_trace(p->xbuf, len+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1155 SIM_dbg_write_trace((SYS_UWORD8 *)"AEANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1156 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1157 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1158 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1159 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1160 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1161 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1162 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1163 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1164 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1165 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1166 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1167 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1168 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1169 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1170 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1173 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1174 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1175 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1176 * SIM_RunGSMAlgo |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1177 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1178 * Authentication procedure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1179 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1180 SYS_UWORD16 SIM_RunGSMAlgo(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1181 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1182 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1184 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1185 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1187 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 if(p->Freq_Algo) //13/4 Mhz mandatory ?? |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKDIV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1193 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1194 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1195 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1196 p->xbuf[1] = SIM_RUN_GSM_ALGO; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1197 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1199 p->xbuf[4] = len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1200 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 for (i=0;i<len;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1202 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1204 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1205 res = SIM_Command(p, len, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1206 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1207 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1208 SIM_dbg_write_trace((SYS_UWORD8 *)"AFCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1209 SIM_dbg_write_trace(p->xbuf, len+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1210 SIM_dbg_write_trace((SYS_UWORD8 *)"AFANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1211 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1212 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1213 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1214 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1215 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1216 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1217 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1218 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1219 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1220 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1221 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1222 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1223 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1224 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1226 if(p->Freq_Algo) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1227 p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKDIV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1228 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1229 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1230 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1232 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1234 * SIM_GetResponse |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1235 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1236 * Get data from the card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1237 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1238 * SYS_UWORD8 len : length of the data to get |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1239 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1240 SYS_UWORD16 SIM_GetResponse(SYS_UWORD8 *dat, SYS_UWORD16 len, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1241 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1243 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1245 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1246 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1248 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1249 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1250 p->xbuf[1] = SIM_GET_RESPONSE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1251 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1252 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1253 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1254 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 res = SIM_Command(p, 0, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1256 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1257 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1258 SIM_dbg_write_trace((SYS_UWORD8 *)"AGCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1259 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1260 SIM_dbg_write_trace((SYS_UWORD8 *)"AGANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1261 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1262 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1263 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1264 SIM_dbg_write_trace(dat, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1265 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1266 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1267 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1268 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1269 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1270 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1271 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1272 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1273 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1274 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1275 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1277 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1278 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1280 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1281 * SIM_ChangeCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1282 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1283 * Change the specified CHV (chvType) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1284 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1285 SYS_UWORD16 SIM_ChangeCHV(SYS_UWORD8 *result,SYS_UWORD8 *oldChv, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1286 SYS_UWORD8 *newChv, SYS_UWORD8 chvType, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1287 SYS_UWORD16 *lP) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1288 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1290 SYS_UWORD16 len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 SYS_UWORD16 res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1295 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1297 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1298 p->xbuf[1] = SIM_CHANGE_CHV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1299 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1300 p->xbuf[3] = chvType; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1301 p->xbuf[4] = (SYS_UWORD8)len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1302 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1303 // Copy bytes to buffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1304 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1305 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1306 p->xbuf[5+i] = *(oldChv+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1307 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1308 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1309 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1310 p->xbuf[13+i] = *(newChv+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1311 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1312 res = SIM_Command(p, len, result, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1313 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1314 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1315 SIM_dbg_write_trace((SYS_UWORD8 *)"AHCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1316 SIM_dbg_write_trace(p->xbuf, len+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1317 SIM_dbg_write_trace((SYS_UWORD8 *)"AHANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1318 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1319 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1320 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1321 SIM_dbg_write_trace(result, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1322 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1323 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1324 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1325 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1326 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1327 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1328 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1329 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1330 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1331 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1332 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1333 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1334 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1335 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1336 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1337 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1338 * SIM_DisableCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1339 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1340 * Disable CHV 1 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1341 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1342 SYS_UWORD16 SIM_DisableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 *lP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1343 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1344 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1345 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1346 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1347 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1348 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1349 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1350 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1351 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1352 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1353 p->xbuf[1] = SIM_DISABLE_CHV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1354 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1355 p->xbuf[3] = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1356 p->xbuf[4] = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1357 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1358 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1359 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1360 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1361 res = SIM_Command(p, len, result, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1362 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1363 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1364 SIM_dbg_write_trace((SYS_UWORD8 *)"AICMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1365 SIM_dbg_write_trace(p->xbuf, 8+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1366 SIM_dbg_write_trace((SYS_UWORD8 *)"AIANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1367 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1368 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1369 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1370 SIM_dbg_write_trace(result, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1371 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1372 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1373 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1374 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1375 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1376 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1377 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1378 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1379 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1380 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1381 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1382 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1383 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1384 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1385 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1386 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1387 * SIM_EnableCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1388 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1389 * Enable CHV 1 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1390 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1391 SYS_UWORD16 SIM_EnableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 *lP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1392 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1393 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1394 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1395 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1396 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1397 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1398 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1399 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1400 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1401 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1402 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1403 p->xbuf[1] = SIM_ENABLE_CHV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1404 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1405 p->xbuf[3] = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1406 p->xbuf[4] = (SYS_UWORD8)len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1407 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1408 for (i=0;i<len;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1409 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1410 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1411 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1412 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1413 res = SIM_Command(p, len, result, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1414 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1415 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1416 SIM_dbg_write_trace((SYS_UWORD8 *)"AJCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1417 SIM_dbg_write_trace(p->xbuf, len+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1418 SIM_dbg_write_trace((SYS_UWORD8 *)"AJANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1419 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1420 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1421 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1422 SIM_dbg_write_trace(result, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1423 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1424 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1425 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1426 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1427 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1428 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1429 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1430 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1431 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1432 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1433 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1434 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1435 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1436 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1437 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1438 * SIM_UnblockCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1439 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1440 * Unblock the specified CHV (chvType) and store a new CHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1441 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1442 SYS_UWORD16 SIM_UnblockCHV(SYS_UWORD8 *result, SYS_UWORD8 *unblockChv, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1443 SYS_UWORD8 *newChv, SYS_UWORD8 chvType, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1444 SYS_UWORD16 *lP) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1445 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1446 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1447 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1448 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1449 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1450 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1451 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1452 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1453 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1454 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1455 p->xbuf[1] = SIM_UNBLOCK_CHV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1456 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1457 p->xbuf[3] = chvType; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1458 p->xbuf[4] = (SYS_UWORD8)len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1459 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1460 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1461 p->xbuf[5+i] = *(unblockChv+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1462 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1463 for (i=0;i<8;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1464 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1465 p->xbuf[13+i] = *(newChv+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1466 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1467 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1468 res = SIM_Command(p, len, result, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1469 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1470 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1471 SIM_dbg_write_trace((SYS_UWORD8 *)"AKCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1472 SIM_dbg_write_trace(p->xbuf, len+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1473 SIM_dbg_write_trace((SYS_UWORD8 *)"AKANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1474 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1475 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1476 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1477 SIM_dbg_write_trace(result, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1478 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1479 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1480 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1481 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1482 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1483 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1484 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1485 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1486 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1487 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1488 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1489 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1490 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1491 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1492 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1493 * SIM_Invalidate |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1494 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1495 * Invalidate the current EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1496 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1497 SYS_UWORD16 SIM_Invalidate(SYS_UWORD8 *rP, SYS_UWORD16 *lP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1498 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1499 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1500 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1501 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1502 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1503 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1504 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1505 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1506 p->xbuf[1] = SIM_INVALIDATE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1507 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1508 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1509 p->xbuf[4] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1510 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1511 res = SIM_Command(p, 0, rP, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1512 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1513 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1514 SIM_dbg_write_trace((SYS_UWORD8 *)"ALCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1515 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1516 SIM_dbg_write_trace((SYS_UWORD8 *)"ALANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1517 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1518 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1519 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1520 SIM_dbg_write_trace(rP, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1521 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1522 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1523 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1524 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1525 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1526 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1527 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1528 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1529 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1530 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1531 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1532 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1533 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1534 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1535 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1536 * SIM_Rehabilitate |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1537 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1538 * Rehabilitate the current EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1539 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1540 SYS_UWORD16 SIM_Rehabilitate(SYS_UWORD8 *rP, SYS_UWORD16 *lP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1541 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1542 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1543 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1544 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1545 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1546 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1547 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1548 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1549 p->xbuf[1] = SIM_REHABILITATE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1550 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1551 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1552 p->xbuf[4] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1553 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1554 res = SIM_Command(p, 0, rP, lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1555 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1556 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1557 SIM_dbg_write_trace((SYS_UWORD8 *)"AMCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1558 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1559 SIM_dbg_write_trace((SYS_UWORD8 *)"AMANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1560 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1561 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1562 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1563 SIM_dbg_write_trace(rP, *lP); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1564 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1565 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1566 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1567 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1568 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1569 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1570 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1571 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1572 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1573 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1574 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1575 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1576 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1577 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1578 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1579 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1580 * SIM_UpdateBinary |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1581 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1582 * Store data in the current transparent EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1583 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1584 SYS_UWORD16 SIM_UpdateBinary(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1585 SYS_UWORD16 offset, SYS_UWORD16 len, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1586 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1587 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1588 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1589 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1590 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1591 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1592 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1593 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1594 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1595 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1596 p->xbuf[1] = SIM_UPDATE_BINARY; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1597 p->xbuf[2] = offset >> 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1598 p->xbuf[3] = offset & 0xFF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1599 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1600 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1601 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1602 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1603 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1604 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1605 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1606 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1607 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1608 SIM_dbg_write_trace((SYS_UWORD8 *)"ANCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1609 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1610 SIM_dbg_write_trace((SYS_UWORD8 *)"ANANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1611 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1612 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1613 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1614 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1615 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1616 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1617 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1618 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1619 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1620 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1621 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1622 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1623 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1624 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1625 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1626 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1627 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1628 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1629 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1630 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1631 * SIM_ReadRecord |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1632 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1633 * Read a record (recNum) from the current linear fixed or cyclic EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1634 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1635 SYS_UWORD16 SIM_ReadRecord(SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1636 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1637 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1638 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1639 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1640 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1641 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1642 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1643 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1644 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1645 p->xbuf[1] = SIM_READ_RECORD; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1646 p->xbuf[2] = recNum; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1647 p->xbuf[3] = mode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1648 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1649 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1650 res = SIM_Command(p, 0, dat, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1651 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1652 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1653 SIM_dbg_write_trace((SYS_UWORD8 *)"AOCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1654 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1655 SIM_dbg_write_trace((SYS_UWORD8 *)"AOANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1656 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1657 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1658 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1659 SIM_dbg_write_trace(dat, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1660 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1661 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1662 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1663 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1664 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1665 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1666 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1667 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1668 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1669 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1670 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1671 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1672 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1673 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1674 #ifdef SIM_APDU_TEST |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1675 SYS_UWORD8 snd[270]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1676 SYS_UWORD8 rec[270]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1677 SYS_UWORD8 logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1678 SYS_UWORD16 recl; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1679 unsigned short resopen, resclose, rescmd; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1680 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1681 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1682 #ifdef SIM_SAT_REFRESH_TEST |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1683 SIM_CARD ptr; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1684 SYS_UWORD16 lrcvSize; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1685 SYS_UWORD8 ldat[20]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1686 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1687 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1688 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1689 * SIM_UpdateRecord |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1690 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1691 * Store a record (recNum) in the current linear fixed or cyclic EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1692 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1693 SYS_UWORD16 SIM_UpdateRecord(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1694 SYS_UWORD8 mode, SYS_UWORD8 recNum, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1695 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1696 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1697 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1698 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1699 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1700 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1701 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1702 #ifdef SIM_SAT_REFRESH_TEST |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1703 // do 1000 times the following sequence |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1704 for (i=0;i<1000;i++) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1705 SIM_PowerOff(); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1706 SIM_Restart(&ptr); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1707 SIM_Select((SYS_UWORD16)0x7f10, ldat, &lrcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1708 SIM_Select((SYS_UWORD16)0x6f3a, ldat, &lrcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1709 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1710 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1711 #ifdef SIM_APDU_TEST |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1712 // send OPEN LOGICAL CHANNEL |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1713 snd[0] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1714 snd[1] = 0x70; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1715 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1716 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1717 snd[4] = 0x01; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1718 resopen = SIM_XchTPDU(&snd[0], 5, &rec[0], 1, &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1719 if (resopen == 0x9000) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1720 logchan = rec[0]; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1721 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1722 // Select AID PKCS |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1723 snd[0] = logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1724 snd[1] = 0xA4; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1725 snd[2] = 0x04; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1726 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1727 snd[4] = 0x0C; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1728 snd[5] = 0xA0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1729 snd[6] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1730 snd[7] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1731 snd[8] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1732 snd[9] = 0x63; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1733 snd[10] = 0x50; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1734 snd[11] = 0x4B; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1735 snd[12] = 0x43; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1736 snd[13] = 0x53; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1737 snd[14] = 0x2D; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1738 snd[15] = 0x31; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1739 snd[16] = 0x35; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1740 rescmd = SIM_XchTPDU(&snd[0], 17, &rec[0], 0, &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1741 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1742 // Select file EF odf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1743 snd[0] = 0x80 | logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1744 snd[1] = 0xA4; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1745 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1746 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1747 snd[4] = 0x02; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1748 snd[5] = 0x50; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1749 snd[6] = 0x31; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1750 rescmd = SIM_XchTPDU(&snd[0], 7, &rec[0], 0, &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1751 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1752 // get response EF odf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1753 snd[0] = logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1754 snd[1] = 0xC0; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1755 snd[2] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1756 snd[3] = 0x00; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1757 snd[4] = rescmd; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1758 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1759 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1760 // read binary EF odf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1761 snd[0] = 0x80 | logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1762 snd[1] = 0xB0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1763 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1764 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1765 snd[4] = rec[3]-16; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1766 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1767 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1768 // Select file EF cdf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1769 snd[0] = 0x80 | logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1770 snd[1] = 0xA4; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1771 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1772 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1773 snd[4] = 0x02; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1774 snd[5] = 0x51; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1775 snd[6] = 0x03; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1776 rescmd = SIM_XchTPDU(&snd[0], 7, &rec[0], 0, &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1777 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1778 // get response EF odf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1779 snd[0] = logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1780 snd[1] = 0xC0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1781 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1782 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1783 snd[4] = rescmd; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1784 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1785 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1786 // read binary EF cdf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1787 snd[0] = 0x80 | logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1788 snd[1] = 0xB0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1789 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1790 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1791 snd[4] = 0xff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1792 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1793 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1794 // read binary EF cdf |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1795 snd[0] = 0x80 | logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1796 snd[1] = 0xB0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1797 snd[2] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1798 snd[3] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1799 snd[4] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1800 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], 256, &recl); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1801 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1802 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1803 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1804 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1805 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1806 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1807 p->xbuf[1] = SIM_UPDATE_RECORD; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1808 p->xbuf[2] = recNum; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1809 p->xbuf[3] = mode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1810 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1811 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1812 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1813 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1814 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1815 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1816 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1817 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1818 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1819 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1820 SIM_dbg_write_trace((SYS_UWORD8 *)"APCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1821 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1822 SIM_dbg_write_trace((SYS_UWORD8 *)"APANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1823 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1824 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1825 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1826 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1827 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1828 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1829 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1830 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1831 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1832 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1833 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1834 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1835 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1836 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1837 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1838 #ifdef SIM_APDU_TEST |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1839 // send CLOSE LOGICAL CHANNEL |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1840 snd[0] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1841 snd[1] = 0x70; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1842 snd[2] = 0x80; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1843 snd[3] = logchan; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1844 snd[4] = 0x00; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1845 resclose = SIM_XchTPDU(&snd[0], 5, &rec[0], 0, &recl); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1846 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1847 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1848 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1849 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1850 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1851 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1852 * SIM_Seek |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1853 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1854 * Search data in a linear fixed or cyclic EF. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1855 * return the first record number in which it found the data. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1856 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1857 SYS_UWORD16 SIM_Seek(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1858 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1859 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1860 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1861 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1862 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1863 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1864 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1865 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1866 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1867 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1868 p->xbuf[1] = SIM_SEEK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1869 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1870 p->xbuf[3] = mode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1871 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1872 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1873 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1874 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1875 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1876 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1877 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1878 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1879 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1880 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1881 SIM_dbg_write_trace((SYS_UWORD8 *)"AQCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1882 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1883 SIM_dbg_write_trace((SYS_UWORD8 *)"AQANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1884 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1885 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1886 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1887 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1888 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1889 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1890 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1891 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1892 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1893 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1894 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1895 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1896 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1897 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1898 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1899 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1900 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1901 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1902 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1903 * SIM_Increase |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1904 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1905 * Add value to a record of a cyclic EF |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1906 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1907 SYS_UWORD16 SIM_Increase(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1908 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1909 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1910 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1911 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1912 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1913 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1914 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1915 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1916 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1917 len = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1918 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1919 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1920 p->xbuf[1] = SIM_INCREASE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1921 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1922 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1923 p->xbuf[4] = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1924 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1925 for (i=0;i<3;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1926 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1927 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1928 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1929 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1930 res = SIM_Command(p, len, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1931 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1932 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1933 SIM_dbg_write_trace((SYS_UWORD8 *)"ARCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1934 SIM_dbg_write_trace(p->xbuf, 3+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1935 SIM_dbg_write_trace((SYS_UWORD8 *)"ARANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1936 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1937 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1938 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1939 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1940 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1941 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1942 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1943 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1944 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1945 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1946 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1947 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1948 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1949 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1950 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1951 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1952 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1953 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1954 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1955 * SIM_TerminalProfile |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1956 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1957 * Used by ME to send its toolkit capabilities to SIM |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1958 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1959 SYS_UWORD16 SIM_TerminalProfile(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1960 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1961 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1962 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1963 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1964 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1965 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1966 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1967 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1968 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1969 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1970 p->xbuf[1] = SIM_TERMINAL_PROFILE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1971 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1972 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1973 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1974 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1975 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1976 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1977 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1978 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1979 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1980 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1981 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1982 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1983 SIM_dbg_write_trace((SYS_UWORD8 *)"ASCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1984 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1985 SIM_dbg_write_trace((SYS_UWORD8 *)"ASANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1986 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1987 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1988 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1989 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1990 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1991 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1992 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1993 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
1994 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1995 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1996 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1997 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1998 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1999 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2000 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2001 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2002 * SIM_FETCH |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2003 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2004 * Used by ME to inquiry of what SIM toolkit need to do |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2005 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2006 SYS_UWORD16 SIM_Fetch(SYS_UWORD8 *result, SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2007 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2008 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2009 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2010 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2011 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2012 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2013 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2014 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2015 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2016 p->xbuf[1] = SIM_FETCH; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2017 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2018 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2019 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2020 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2021 res = SIM_Command(p, 0, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2022 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2023 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2024 SIM_dbg_write_trace((SYS_UWORD8 *)"ATCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2025 SIM_dbg_write_trace(p->xbuf, 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2026 SIM_dbg_write_trace((SYS_UWORD8 *)"ATANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2027 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2028 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2029 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2030 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2031 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2032 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2033 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2034 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2035 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2036 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2037 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2038 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2039 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2040 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2041 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2042 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2043 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2044 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2045 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2046 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2047 * SIM_TerminalResponse * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2048 * Used for ME to respond at a SIM toolkit command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2049 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2050 SYS_UWORD16 SIM_TerminalResponse(SYS_UWORD8 *result, SYS_UWORD8 *dat, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2051 SYS_UWORD16 len, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2052 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2053 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2054 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2055 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2056 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2057 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2058 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2059 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2060 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2061 p->xbuf[1] = SIM_TERMINAL_RESPONSE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2062 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2063 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2064 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2065 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2066 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2067 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2068 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2069 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2070 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2071 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2072 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2073 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2074 SIM_dbg_write_trace((SYS_UWORD8 *)"AUCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2075 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2076 SIM_dbg_write_trace((SYS_UWORD8 *)"AUANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2077 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2078 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2079 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2080 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2081 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2082 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2083 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2084 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2085 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2086 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2087 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2088 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2089 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2090 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2091 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2092 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2093 * SIM_Envelope |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2094 * |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2095 * Used by Network to tansfert data download to the SIM |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2096 * in a transparent way for user |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2097 */ |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2098 SYS_UWORD16 SIM_Envelope(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2099 SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2100 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2101 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2102 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2103 int res; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2104 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2105 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2106 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2107 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2108 p->xbuf[0] = GSM_CLASS; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2109 p->xbuf[1] = SIM_ENVELOPE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2110 p->xbuf[2] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2111 p->xbuf[3] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2112 p->xbuf[4] = (SYS_UWORD8)llen; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2113 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2114 for (i=0;i<llen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2115 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2116 p->xbuf[5+i] = *(dat+i); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2117 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2118 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2119 res = SIM_Command(p, llen, result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2120 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2121 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2122 SIM_dbg_write_trace((SYS_UWORD8 *)"AVCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2123 SIM_dbg_write_trace(p->xbuf, llen+5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2124 SIM_dbg_write_trace((SYS_UWORD8 *)"AVANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2125 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2126 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2127 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2128 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2129 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2130 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2131 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2132 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2133 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2134 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2135 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2136 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2137 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2138 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2139 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2140 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2141 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2142 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2143 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2144 * SIM_XchTPDU * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2145 * Used for ME to send generic command to WIM Card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2146 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2147 SYS_UWORD16 SIM_XchTPDU(SYS_UWORD8 *dat, SYS_UWORD16 trxLen, SYS_UWORD8 *result, |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2148 SYS_UWORD16 rcvLen, SYS_UWORD16 *rcvSize) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2149 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2150 SIM_PORT *p; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2151 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2152 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2153 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2154 p = &(Sim[0]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2155 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2156 p->xbuf[0] = dat[0]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2157 p->xbuf[1] = dat[1]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2158 p->xbuf[2] = dat[2]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2159 p->xbuf[3] = dat[3]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2160 p->xbuf[4] = dat[4]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2161 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2162 for (i=5;i<trxLen;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2163 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2164 p->xbuf[i] = dat[i]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2165 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2166 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2167 // enable the WIM behavior of the sim driver |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2168 p->apdu_ans_length = rcvLen; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2169 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2170 res = SIM_Command(p, (trxLen - 5), result, rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2171 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2172 // disable the WIM behavior of the sim driver |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2173 p->apdu_ans_length = 0; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2174 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2175 #ifdef SIM_DEBUG_TRACE |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2176 SIM_dbg_write_trace((SYS_UWORD8 *)"AWCMD", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2177 SIM_dbg_write_trace(p->xbuf, trxLen); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2178 SIM_dbg_write_trace((SYS_UWORD8 *)"AWANS", 5); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2179 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2180 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2181 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2182 SIM_dbg_write_trace(result, *rcvSize); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2183 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2184 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2185 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2186 SIM_dbg_write_trace(SIM_dbg_null, SIM_DBG_NULL); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2187 if (SIM_dbg_tdma_diff > SIM_dbg_max_interchardelay) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2188 SIM_dbg_max_interchardelay = SIM_dbg_tdma_diff; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2189 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2190 SIM_dbg_tmp[1] = (SYS_UWORD8)(SIM_dbg_tdma_diff); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2191 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2192 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2193 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2194 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2195 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2196 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2197 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2198 * Use to detect end of characters reception |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2199 * input: p pointer on sim structure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2200 * n number of extra character to send |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2201 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2202 * output: return 0 if sucess |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2203 * SIM_ERR_x in case of error |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2204 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2205 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2206 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2207 SYS_UWORD16 SIM_WaitReception(SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2208 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2209 SYS_UWORD16 returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2210 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2211 //analyse the nature of the command to execute |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2212 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2213 if ( |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2214 (p->xbuf[1] == 0x12) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2215 (p->xbuf[1] == 0xB2) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2216 (p->xbuf[1] == 0xB0) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2217 (p->xbuf[1] == 0xF2) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2218 (p->xbuf[1] == 0xC0) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2219 (p->apdu_ans_length != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2220 ) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2221 //FETCH, READ_RECORD, READ_BINARY, STATUS, GET_RESPONSE commands == receive command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2222 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2223 if (p->xbuf[4] == 0) //if P3 == 0 when sending receive command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2224 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2225 p->expected_data = 256; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2226 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2227 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2228 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2229 p->expected_data = p->xbuf[4]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2230 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2231 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2232 p->moderx = 1; //wait for procedure byte |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2233 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2234 if (returncode = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2235 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2236 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2237 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2238 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2239 else //direct command : INVALIDATE, REHABILITATE, SLEEP |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2240 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2241 p->moderx = 5; //mode reception of SW1/SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2242 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2243 if (returncode = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2244 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2245 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2246 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2247 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2248 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2249 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2250 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2251 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2252 * Use to read file characteristics information |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2253 * input: p pointer on sim structure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2254 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2255 * output: return 0 if sucess |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2256 * 1 in case of error |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2257 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2258 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2259 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2260 SYS_UWORD8 SIM_GetFileCharacteristics(SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2261 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2262 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2263 SYS_UWORD8 ubuf[40]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2264 SYS_UWORD16 sz; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2265 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2266 res = SIM_Select(DF_GSM, ubuf, &sz); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2267 if ((res & 0xFF00) != 0x9F00) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2268 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2269 res = SIM_Select(DF_DCS1800, ubuf, &sz); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2270 if ((res & 0xFF00) != 0x9F00) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2271 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2272 return (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2273 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2274 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2275 res = SIM_GetResponse( ubuf, res & 0x00FF , &sz); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2276 if (res != 0x9000) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2277 return (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2278 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2279 p->FileC = ubuf[13]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2280 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2281 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2282 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2283 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2284 * Use to determine value of b2 in file caracteristics contained in response |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2285 * of SELECT Master File command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2286 * return 0 if no preferred speed during authentication |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2287 * 1 if 13/4Mhz mandatory |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2288 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2289 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2290 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2291 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2292 void SIM_Interpret_FileCharacteristics(SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2293 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2294 //interpret b2 bit for operating authentication speed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2295 if((p->conf1 & 0x0020) && (p->FileC & 0x02)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2296 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2297 p->Freq_Algo = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2298 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2299 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2300 //interpret Clock stop behavior |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2301 // modified by J. Yp-Tcha to integrate all the behaviors required by ETSI. |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2302 // 18/11/2002 : TI Chip always allowed low level, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2303 // high level is hard dependant |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2304 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2305 if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_NOT_ALLWD) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2306 /* Sim Clock Stop Not Allowed */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2307 SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2308 /* There is not need to modifiy p->conf1 */ |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2309 status_os_sim = NU_Delete_Timer (&SIM_timer); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2310 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2311 else { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2312 if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_ALLWD) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2313 /* Sim Clock Stop Allowed, no prefered level */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2314 /* Default value for TI Chip shall always be Low Level */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2315 SIM_sleep_status = SIM_SLEEP_DESACT; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2316 p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2317 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2318 else { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2319 /* Clock Stop is allowed, the level shall be checked */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2320 if ((p->FileC & SIM_CLK_STOP_HIGH) == SIM_CLK_STOP_HIGH) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2321 /* high level is mandatory */ |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2322 /* OMEGA/NAUSICA can not handle sim stop clock at high level */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2323 #ifndef ANALOG1 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2324 SIM_sleep_status = SIM_SLEEP_DESACT; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2325 p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKLEV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2326 #else |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2327 /* |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2328 * Sim Clock Stop Not Allowed because the interface |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2329 * do not support this level |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2330 */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2331 SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2332 /* There is not need to modifiy p->conf1 */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2333 status_os_sim = NU_Delete_Timer (&SIM_timer); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2334 #endif |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2335 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2336 else { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2337 /* by default, Low Level is allowed */ |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2338 SIM_sleep_status = SIM_SLEEP_DESACT; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2339 p->c->conf1 = p->conf1 &= ~SIM_CONF1_SCLKLEV; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2340 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2341 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2342 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2343 if (SIM_sleep_status == SIM_SLEEP_NONE) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2344 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2345 status_os_sim = NU_Delete_Timer (&SIM_timer); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2346 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2347 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2348 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2349 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2350 * Use to evaluate need of sending PTS procedure regarding |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2351 * the ATR. If default not used, PTS initiates F and D adequate values |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2352 * for speed enhancement. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2353 * In case of 2 wrong PTS answer (speed enhanced), a third PTS with default value |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2354 * is used. If the third PTS attempt failed, the ME reset the SIM and use default |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2355 * value. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2356 * Return Value : SIM_ERR_READ, SIM_ERRCARDREJECT, SIM_ERR_WAIT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2357 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2358 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2359 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2360 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2361 SYS_UWORD16 SIM_PTSprocedure(SIM_CARD *cP, SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2362 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2363 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2364 SYS_UWORD8 TA1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2365 SYS_UWORD8 n; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2366 SYS_UWORD8 err; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2367 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2368 p->xbuf[0] = 0xFF; //character of PTS proc to send |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2369 p->xbuf[1] = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2370 p->xbuf[2] = 0xFF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2371 p->xbuf[3] = 0x7B; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2372 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2373 //TA1,TB1,TC1,TD1 present in ATR ? |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2374 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2375 n = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2376 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2377 p->PTS_Try++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2378 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2379 if (p->PTS_Try > 4) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2380 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2381 return (SIM_ERR_CARDREJECT); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2382 } // at the fourth attempt, |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2383 // PTS procedure is unusefull. Use default value. |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2384 //TA1 present? Test 27.11.2.6 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2385 else if ( p->PTS_Try == 4) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2386 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2387 SIM_Calcetu (p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2388 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2389 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2390 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2391 if(cP->AtrData[1] & 0x10) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2392 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2393 TA1 = cP->AtrData[2]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2394 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2395 else //if TA1 not present, return |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2396 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2397 SIM_Calcetu (p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2398 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2399 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2400 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2401 #if 0 // Dmitriy: removed by TI patch |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2402 if (TA1 >= 0x94) //speed enhancement |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2403 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2404 // JYT 26/9/2003 to check correct behavior of the SIM Driver vs the PPS. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2405 //#ifdef NOTTOLOADBECAUSENOTTESTED |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2406 // SIM_Calcetu (p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2407 // return (0); //temporary disabling of speed enhancement feature |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2408 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2409 if (p->PTS_Try <= 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2410 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2411 n = 4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2412 p->xbuf[1] = 0x10; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2413 p->xbuf[2] = 0x94; // if speed enhancement, then at least (and at most) F = 512 and D = 8 is supported |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2414 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2415 //#endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2416 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2417 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2418 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2419 if ((TA1 == 0x11) || (TA1 == 0x01)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2420 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2421 SIM_Calcetu (p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2422 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2423 } //if TA1 != 0x11 and 0x94, need to send PTS request |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2424 //transmit request of speed enhancement : PTS |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2425 SIM_WriteBuffer(p, 0, n); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2426 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2427 p->moderx = 0; //mode of normal reception |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2428 p->expected_data = n; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2429 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2430 if (err = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2431 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2432 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2433 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2434 //should received same chars as PTS request |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2435 if ((p->rbuf[0] != p->xbuf[0]) || (p->rbuf[1] != p->xbuf[1]) || |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2436 (p->rbuf[2] != p->xbuf[2])) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2437 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2438 return(SIM_ERR_READ); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2439 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2440 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2441 if (n == 4) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2442 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2443 if (p->rbuf[3] != p->xbuf[3]) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2444 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2445 return(SIM_ERR_READ); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2446 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2447 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2448 //correct response from SIM : with speed enhanced |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2449 p->c->conf1 = p->conf1 |= SIM_CONF1_ETU; //set F=512 D=8 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2450 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2451 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2452 SIM_Calcetu (p); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2453 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2454 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2455 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2456 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2457 * procedure of WARM reset consists on asserting |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2458 * reset signal at 0 during at least 400 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2459 * input p pointer of type SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2460 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2461 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2462 void SIM_WARMReset (SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2463 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2464 p->c->conf1 = p->conf1 &= ~SIM_CONF1_SRSTLEV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2465 ind_os_sleep (p->etu400); /// wait 400 ETU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2466 p->c->conf1 = p->conf1 |= SIM_CONF1_SRSTLEV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2467 p->rx_index = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2468 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2469 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2470 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2471 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2472 * procedure use to get out sleepMode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2473 * input p pointer of type SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2474 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2475 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2476 void SIM_SleepMode_In (SYS_UWORD32 param) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2477 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2478 if (SIM_sleep_status == SIM_SLEEP_DESACT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2479 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2480 (&(Sim[0]))->c->conf1 &= ~SIM_CONF1_SCLKEN; //disabled the clock for the SIM card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2481 SIM_sleep_status = SIM_SLEEP_ACT; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2482 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2483 status_os_sim = NU_Control_Timer (&SIM_timer, NU_DISABLE_TIMER); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2484 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2485 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2486 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2487 * procedure use to get out sleepMode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2488 * input p pointer of type SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2489 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2490 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2491 void SIM_SleepMode_Out (SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2492 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2493 if (SIM_sleep_status == SIM_SLEEP_ACT) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2494 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2495 p->c->conf1 = p->conf1 |= SIM_CONF1_SCLKEN; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2496 // WCS patch for NU_Sleep(0) bug |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2497 if (p->startclock > 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2498 ind_os_sleep (p->startclock); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2499 // End WCS patch |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2500 SIM_sleep_status = SIM_SLEEP_DESACT; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2501 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2502 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2503 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2504 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2505 * procedure to parse ATR dynamically |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2506 * input p pointer of type SIM_PORT |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2507 * output return error code |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2508 * SIM_ERR_WAIT, p->errorSIM |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2509 * SIM_ERR_CARDREJECT, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2510 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2511 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2512 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2513 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2514 SYS_UWORD16 SIM_ATRdynamictreatement (SIM_PORT *p, SIM_CARD *cP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2515 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2516 volatile SYS_UWORD8 HistChar; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2517 volatile SYS_UWORD8 InterfChar; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2518 SYS_UWORD16 countT; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2519 SYS_UWORD16 mask; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2520 SYS_UWORD16 returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2521 SYS_UWORD8 i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2522 SYS_UWORD8 firstprotocol; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2523 SYS_UWORD8 Tx,T; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2524 SYS_UWORD8 TDi; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2525 SYS_UWORD8 position_of_TC1, position_of_TB1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2526 SYS_UWORD8 another_protocol_present; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2527 SYS_UWORD16 wait80000clk; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2528 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2529 i = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2530 //wait for TS and T0 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2531 p->moderx = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2532 p->expected_data= 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2533 firstprotocol = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2534 position_of_TC1 = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2535 position_of_TB1 = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2536 another_protocol_present = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2537 wait80000clk = 6; // > 24 ms |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2538 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2539 //wait for first character TS of ATR sequence. It should arrive before 80000sclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2540 if (returncode = SIM_Waitforchars (p, wait80000clk)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2541 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2542 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2543 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2544 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2545 //wait for T0 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2546 p->expected_data++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2547 if (returncode = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2548 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2549 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2550 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2551 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2552 ind_os_sleep(220); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2553 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2554 if (((p->rbuf[0] & 0xF0) == 0x30) && (p->rx_index != 0)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2555 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2556 cP->Inverse = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2557 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2558 /*-----------------------------------------------------------*/ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2559 /* Inverse convention card */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2560 // If first byte is correct for inverse card, return success |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2561 else if (((p->rbuf[0] & 0x0F) == 0x03) && (p->rx_index != 0)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2562 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2563 cP->Inverse = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2564 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2565 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2566 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2567 return (SIM_ERR_CARDREJECT); //Test 27.11.2.4.5 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2568 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2569 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2570 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2571 mask = 0x10; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2572 InterfChar = 2; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2573 TDi = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2574 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2575 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2576 Tx = SIM_Translate_atr_char (p->rbuf[1], cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2577 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2578 HistChar = Tx & 0x0F; //get K, number of transmitted historical character |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2579 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2580 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2581 while (TDi != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2582 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2583 while (mask < 0x100) //monitors interface chars |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2584 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2585 if ((Tx & mask) == mask) //monitors if interface character TAx,TBx,TCx,TDc present |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2586 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2587 InterfChar++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2588 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2589 //wait for TC1 and save its position |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2590 if ((firstprotocol == 0) && ((Tx & 0x40) == mask)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2591 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2592 position_of_TC1 = InterfChar - 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2593 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2594 if ((firstprotocol == 0) && ((Tx & 0x20) == mask)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2595 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2596 position_of_TB1 = InterfChar - 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2597 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2598 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2599 mask = mask << 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2600 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2601 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2602 p->expected_data = InterfChar; //wait for TAi,TBi,TCi,TDi if present |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2603 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2604 if (returncode = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2605 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2606 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2607 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2608 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2609 //need to monitor if TC1 present and if equal to 0 or 255 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2610 // on first protocol |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2611 if ((firstprotocol == 0) && (position_of_TC1 != 0)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2612 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2613 T = SIM_Translate_atr_char (p->rbuf[position_of_TC1], cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2614 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2615 if ((T != 0) && (T != 255)) //test 27.11.1.3 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2616 { //return Error in case of bad TC1 value |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2617 return (SIM_ERR_CARDREJECT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2618 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2619 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2620 //need to monitor if TB1 present and if differente from 0 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2621 // on first protocol |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2622 if ((firstprotocol == 0) && (position_of_TB1 != 0)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2623 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2624 T = SIM_Translate_atr_char (p->rbuf[position_of_TB1], cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2625 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2626 if (T != 0) //ITU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2627 { //return Error in case of bad TB1 value |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2628 return (SIM_ERR_CARDREJECT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2629 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2630 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2631 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2632 if ((Tx & 0x80) == 0x80) //TDi byte on first protocol must be 0 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2633 { //get new TD char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2634 Tx = SIM_Translate_atr_char (p->rbuf[InterfChar - 1], cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2635 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2636 if ((Tx & 0x0F) != 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2637 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2638 if (firstprotocol == 0) //if first protocol received is not T=0, card is rejected |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2639 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2640 return (SIM_ERR_CARDREJECT); //protocol other than T=0 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2641 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2642 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2643 { //if an another protocol T != 0 present, need to wait for TCK char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2644 another_protocol_present = 1; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2645 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2646 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2647 mask = 0x10; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2648 firstprotocol++; //indicate another protocol T |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2649 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2650 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2651 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2652 TDi = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2653 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2654 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2655 //add TCK if necessary |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2656 p->expected_data = HistChar + InterfChar + another_protocol_present; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2657 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2658 if (returncode = SIM_Waitforchars (p, p->etu9600)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2659 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2660 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2661 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2662 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2663 cP->AtrSize = p->rx_index; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2664 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2665 if (cP->Inverse) //inverse card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2666 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2667 // Copy ATR data |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2668 for (i=0;i<cP->AtrSize;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2669 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2670 cP->AtrData[i] = SIM_ByteReverse(p->rbuf[i]); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2671 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2672 p->c->conf1 = p->conf1 |= SIM_CONF1_CONV | SIM_CONF1_CHKPAR; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2673 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2674 else //direct card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2675 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2676 p->c->conf1 = p->conf1 |= SIM_CONF1_CHKPAR; //0x0409 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2677 // Copy ATR data |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2678 for (i=0;i<cP->AtrSize;i++) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2679 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2680 cP->AtrData[i] = p->rbuf[i]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2681 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2682 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2683 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2684 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2685 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2686 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2687 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2688 ** SIM_Translate_atr_char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2689 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2690 * FILENAME: sim.c |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2691 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2692 * PARAMETERS: input char to translate |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2693 * cP sim structure (indicates if inverse card present) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2694 * DESCRIPTION: return the correct value of input for inverse card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2695 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2696 * RETURNS: character after parsing |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2697 * stays the same if direct card |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2698 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2699 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2700 SYS_UWORD8 SIM_Translate_atr_char (SYS_UWORD8 input, SIM_CARD *cP) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2701 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2702 SYS_UWORD8 translated; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2703 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2704 if (cP->Inverse) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2705 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2706 translated = SIM_ByteReverse(input); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2707 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2708 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2709 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2710 translated = input; //get character next char T0 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2711 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2712 return (translated); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2713 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2714 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2715 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2716 * SIM_Waitforchars is used for waiting nbchar characters from SIM |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2717 * input p sim port |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2718 * max_wait max number of TDMA to wait between 2 characters |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2719 * output |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2720 * error code 0 if OK |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2721 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2722 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2723 SYS_UWORD16 SIM_Waitforchars (SIM_PORT *p, SYS_UWORD16 max_wait) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2724 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2725 volatile SYS_UWORD8 old_nb_char; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2726 volatile SYS_UWORD16 countT; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2727 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2728 if (p->moderx == 6) //use for reception of ACK when command need to transmit rest of data |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2729 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2730 p->ack = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2731 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2732 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2733 while((p->ack == 0) && (p->moderx == 6)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2734 { //if p->moderx change from 6 to 5, need to wait for SW1 and SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2735 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2736 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2737 countT++; //implementation of software Waiting time overflow |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2738 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2739 if (p->null_received) //if NULL char received, wait for next procedure char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2740 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2741 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2742 p->null_received = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2743 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2744 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2745 if (countT > max_wait) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2746 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2747 return (SIM_ERR_WAIT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2748 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2749 if (p->errorSIM) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2750 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2751 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2752 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2753 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2754 if (p->moderx == 6) //if transition to moderx = 5 in synchronous part |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2755 { //need to quit for SW1/SW2 reception |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2756 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2757 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2758 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2759 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2760 if ((p->moderx != 6) && (p->moderx != 5)) //treatement of mode 0, 1, 2, 3, 4 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2761 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2762 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2763 old_nb_char = p->rx_index; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2764 //leave while if moderx == 5 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2765 while((p->rx_index < p->expected_data) && (p->moderx != 5)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2766 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2767 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2768 countT++; //implementation of software Waiting time overflow |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2769 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2770 if (p->null_received) //if NULL char received, wait for next procedure char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2771 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2772 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2773 p->null_received = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2774 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2775 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2776 if (countT > max_wait) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2777 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2778 return (SIM_ERR_WAIT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2779 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2780 if (p->errorSIM) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2781 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2782 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2783 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2784 if (p->rx_index > old_nb_char) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2785 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2786 old_nb_char = p->rx_index; //if char received before max_wait TDMA, reset the counter |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2787 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2788 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2789 } //end while |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2790 if (p->moderx == 0) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2791 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2792 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2793 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2794 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2795 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2796 if (p->moderx == 5) //use for reception of SW1 SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2797 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2798 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2799 old_nb_char = p->SWcount; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2800 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2801 while(p->SWcount < 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2802 { //if p->moderx change from 6 to 5, need to wait for SW1 and SW2 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2803 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2804 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2805 countT++; //implementation of software Waiting time overflow |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2806 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2807 if (p->null_received) //if NULL char received, wait for next procedure char |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2808 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2809 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2810 p->null_received = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2811 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2812 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2813 if (countT > max_wait) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2814 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2815 return (SIM_ERR_WAIT); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2816 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2817 if (p->errorSIM) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2818 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2819 return(p->errorSIM); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2820 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2821 if (p->SWcount > old_nb_char) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2822 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2823 old_nb_char = p->SWcount; //if char received before max_wait TDMA, reset the counter |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2824 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2825 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2826 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2827 p->SWcount = 0; //reset SWcount buffer index when SW1 SW2 received |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2828 return (0); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2829 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2830 else //treatement of abnormal case of the asynchronous state machine |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2831 { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2832 return (SIM_ERR_ABNORMAL_CASE1); |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2833 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2834 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2835 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2836 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2837 * SIM_Calcetu is used for calculating 9600 etu and 400 etu depending on sim clock freq |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2838 * and etu period |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2839 * input p sim port |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2840 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2841 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2842 void SIM_Calcetu (SIM_PORT *p) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2843 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2844 if (p->conf1 & SIM_CONF1_SCLKDIV) //clock input is 13/8 Mhz |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2845 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2846 if (p->conf1 & SIM_CONF1_ETU) //etu period is 512/8*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2847 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2848 p->etu9600 = 319; // old = 88, increase of 363% |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2849 p->etu400 = 6; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2850 p->stopclock = 18; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2851 p->startclock = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2852 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2853 else //etu period is 372/1*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2854 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2855 p->etu9600 = 1815; // old = 500, increase of 363% |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2856 p->etu400 = 28; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2857 p->stopclock = 94; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2858 p->startclock = 38; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2859 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2860 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2861 else //clock input is 13/4 Mhz |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2862 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2863 if (p->conf1 & SIM_CONF1_ETU) //etu period is 512/8*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2864 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2865 p->etu9600 = 159; // old = 44, increase of 363% |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2866 p->etu400 = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2867 p->stopclock = 9; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2868 p->startclock = 4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2869 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2870 else //etu period is 372/1*Tsclk |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2871 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2872 p->etu9600 = 907; // old = 250, increase of 363% |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2873 p->etu400 = 14; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2874 p->stopclock = 47; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2875 p->startclock = 19; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2876 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2877 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2878 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2879 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2880 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2881 * Set the level shifter voltage for start up sequence |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2882 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2883 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2884 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2885 SYS_UWORD8 SIM_StartVolt (SYS_UWORD8 ResetFlag) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2886 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2887 SYS_UWORD8 abbmask; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2888 |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2889 #if(ANALOG == 1) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2890 // we assume that in SIM_TYPE_5V there is nothing to do because it is the reset value |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2891 #if ((SIM_TYPE == SIM_TYPE_3V) || (SIM_TYPE == SIM_TYPE_3_5V)) // { shut down VCC from ABB and prepare to start at 3V mode |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2892 if (ResetFlag) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2893 abbmask = MODE_INIT_OMEGA_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2894 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2895 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2896 else { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2897 if (CurrentVolt == SIM_3V) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2898 abbmask = MODE_INIT_OMEGA_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2899 else |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2900 abbmask = MODE5V_OMEGA; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2901 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2902 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & 0xC0) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2903 ind_os_sleep(1); //wait for charge pump regulation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2904 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2905 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2906 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2907 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2908 #if(ANALOG == 2) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2909 SYS_UWORD8 count = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2910 // code for Iota |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2911 // reset value for IOTA is for 1.8V, but specific procedure is needed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2912 #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 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2913 if (ResetFlag) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2914 abbmask = MODE_INIT_IOTA_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2915 // we assume the sim is 1.8v tech. from beginning. |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2916 CurrentVolt = SIM_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2917 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2918 else { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2919 if (CurrentVolt == SIM_1_8V) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2920 abbmask = MODE_INIT_IOTA_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2921 else |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2922 abbmask = MODE_INIT_IOTA_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2923 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2924 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2925 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2926 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2927 if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2928 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2929 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2930 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2931 // IOTA failure activation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2932 return(SIM_ERR_HARDWARE_FAIL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2933 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2934 // 3V only |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2935 #if (SIM_TYPE == SIM_TYPE_3V) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2936 abbmask = MODE_INIT_IOTA_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2937 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2938 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2939 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2940 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2941 if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) // test RSIMRSU |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2942 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2943 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2944 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2945 // IOTA failure activation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2946 return(SIM_ERR_HARDWARE_FAIL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2947 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2948 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2949 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2950 #if(ANALOG == 3) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2951 SYS_UWORD8 count = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2952 // code for Syren |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2953 // reset value for SYREN is for 1.8V, but specific procedure is needed |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2954 #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 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2955 if (ResetFlag) { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2956 abbmask = MODE_INIT_SYREN_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2957 // we assume the sim is 1.8v tech. from beginning. |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2958 CurrentVolt = SIM_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2959 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2960 else { |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2961 if (CurrentVolt == SIM_1_8V) |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2962 abbmask = MODE_INIT_SYREN_1_8V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2963 else |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2964 abbmask = MODE_INIT_SYREN_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2965 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2966 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2967 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2968 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2969 if (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x04) // test RSIMRSU |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2970 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2971 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2972 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2973 // SYREN failure activation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2974 return(SIM_ERR_HARDWARE_FAIL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2975 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2976 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2977 // 3V only |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2978 #if (SIM_TYPE == SIM_TYPE_3V) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2979 abbmask = MODE_INIT_SYREN_3V; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
2980 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2981 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2982 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2983 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2984 if (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x04) // test RSIMRSU |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2985 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2986 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2987 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2988 // SYREN failure activation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2989 return(SIM_ERR_HARDWARE_FAIL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2990 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2991 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2992 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2993 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2994 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2995 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2996 * Set the level shifter to switch from 3V to 5V |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2997 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2998 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2999 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3000 SYS_UWORD8 SIM_SwitchVolt (SYS_UWORD8 ResetFlag) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3001 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3002 SYS_UWORD8 count = 0; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3003 SYS_UWORD8 abbmask; |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3004 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3005 SIM_PowerOff(); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3006 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3007 #if(ANALOG == 1) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3008 #if (SIM_TYPE == SIM_TYPE_3_5V) // shut down VCC from ABB and prepare to start at 5V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3009 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3010 abbmask = MODE5V_OMEGA; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3011 CurrentVolt = SIM_5V; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3012 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3013 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3014 if (CurrentVolt == SIM_3V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3015 abbmask = MODE_INIT_OMEGA_3V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3016 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3017 abbmask = MODE5V_OMEGA; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3018 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3019 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & 0xC0) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3020 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3021 #endif |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3022 #elif(ANALOG == 2) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3023 #if (SIM_TYPE == SIM_TYPE_1_8_3V) // shut down VCC from ABB and prepare to start at 3V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3024 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3025 abbmask = MODE_INIT_IOTA_3V; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3026 CurrentVolt = SIM_3V; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3027 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3028 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3029 if (CurrentVolt == SIM_1_8V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3030 abbmask = MODE_INIT_IOTA_1_8V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3031 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3032 abbmask = MODE_INIT_IOTA_3V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3033 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3034 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0xF4) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3035 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3036 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3037 if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 0x04) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3038 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3039 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3040 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3041 // IOTA failure activation |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3042 return(SIM_ERR_HARDWARE_FAIL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3043 #endif |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3044 #elif(ANALOG == 3) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3045 #if (SIM_TYPE == SIM_TYPE_1_8_3V) // shut down VCC from ABB and prepare to start at 3V mode |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3046 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3047 abbmask = MODE_INIT_SYREN_3V; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3048 CurrentVolt = SIM_3V; |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3049 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3050 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3051 if (CurrentVolt == SIM_1_8V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3052 abbmask = MODE_INIT_SYREN_1_8V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3053 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3054 abbmask = MODE_INIT_SYREN_3V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3055 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3056 ABB_wa_VRPC ((ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x1F4) | abbmask); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3057 while(count++ < 5) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3058 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3059 if (ABB_Read_Register_on_page(PAGE1,VRPCSIMR) & 0x04) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3060 return(SIM_OK); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3061 ind_os_sleep(1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3062 } |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3063 // SYREN failure activation |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3064 return(SIM_ERR_HARDWARE_FAIL); |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3065 #endif |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3066 #endif // ANALOG == 1, 2, 3 |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3067 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3068 |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3069 SYS_UWORD8 SIM_Memcpy(SYS_UWORD8 *Buff_target, SYS_UWORD8 Buff_source[], |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3070 SYS_UWORD16 len) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3071 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3072 SYS_UWORD16 i; //unsigned short type counter chosen for copy of 256 bytes |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3073 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3074 for (i = 0; i < len; i++) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3075 { |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3076 if (i == RSIMBUFSIZE) |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3077 { |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3078 return (SIM_ERR_BUFF_OVERFL); |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3079 } |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3080 else |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3081 { |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3082 (*(Buff_target+i)) = Buff_source[i]; |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3083 } |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3084 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3085 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3086 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3087 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3088 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3089 * SIM_SleepStatus |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3090 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3091 * Return SIM status for sleep manager |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3092 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3093 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3094 SYS_BOOL SIM_SleepStatus(void) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3095 { |
645
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3096 if ((SIM_sleep_status == SIM_SLEEP_ACT) || |
14826aa2db26
SIM integration: sim.c compiles; massive cleaning for readability
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
163
diff
changeset
|
3097 (SIM_sleep_status == SIM_SLEEP_NONE)) |
163
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3098 return(1); // SIM is ready for deep sleep |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3099 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3100 return(0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3101 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3102 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3103 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3104 * Special lock function to force SIM entity to use adequat SIM Driver |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3105 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3106 void SIM_lock_cr17689(void) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3107 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3108 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3109 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3110 #ifdef SIM_DEBUG_TRACE |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3111 void SIM_dbg_write_trace(SYS_UWORD8 *ptr, SYS_UWORD16 len) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3112 SYS_UWORD16 i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3113 for(i=0;i<len;i++) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3114 if (SIM_dbg_cmd_cmpt == SIM_DBG_CMD) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3115 SIM_dbg_cmd_cmpt = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3116 SIM_dbg_cmd[SIM_dbg_cmd_cmpt++] = ptr[i]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3117 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3118 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3119 #endif |