FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/bsp/sim.c @ 203:99c234bf6a9b
fc-loadtool flash ID check: definitions created
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 23 Dec 2013 07:26:37 +0000 |
parents | 5e0e41cd7c9f |
children | 14826aa2db26 |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 #ifndef _WINDOWS |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 #include "l1sw.cfg" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #include "chipset.cfg" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 #include "main/sys_types.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 #include "memif/mem.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 //#include "assert.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 #if (CHIPSET == 12) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 #include "inth/sys_inth.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 #else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 #include "inth/iq.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 #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
|
35 #include <string.h> |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 #include "armio/armio.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 #include "ind_os.h" |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 #include "abb/abb.h" //controls level shifter of ABB |
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 //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
|
42 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
|
43 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 #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
|
47 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #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
|
49 /* 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
|
50 #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
|
51 #else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 /* 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
|
53 #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
|
54 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 /* 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
|
57 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
|
58 /* 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
|
59 #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
|
60 /* 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
|
61 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
|
62 /* 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
|
63 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
|
64 /* 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
|
65 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
|
66 /* 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
|
67 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
|
68 /* 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
|
69 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
|
70 /* 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
|
71 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
|
72 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 #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
|
76 /* 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
|
77 #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
|
78 /* 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
|
79 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
|
80 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 |
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 * 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
|
89 * SIM_WriteBuffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 * SIM_Command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 * SIM_Reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 * |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 * SIM_WriteBuffer |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 * 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
|
101 * 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
|
102 * 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
|
103 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 * Parameters : |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 * 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
|
106 * 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
|
107 * 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
|
108 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 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
|
110 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 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
|
112 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 // 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
|
114 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
|
115 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
|
116 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 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
|
122 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
|
123 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 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
|
125 { //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
|
126 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
|
127 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 // 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
|
129 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
|
130 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 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
|
132 { // 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
|
133 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
|
134 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
|
135 |
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 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 * SIM_Result |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 * 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
|
143 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 * 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
|
145 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 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
|
147 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 // 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
|
153 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
|
154 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
|
155 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 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
|
157 *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
|
158 if ((*lenP == 0) && (p->apdu_ans_length == 256)) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 *lenP = 256; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 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
|
162 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 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
|
164 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
|
165 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 return (verdict); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 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
|
170 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 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
|
172 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
|
173 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 return (verdict); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 // 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
|
179 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
|
180 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
|
181 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 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
|
183 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 * 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
|
191 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 * 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
|
193 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 * 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
|
195 * 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
|
196 * 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
|
197 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 * 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
|
199 * 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
|
200 * 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
|
201 * 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
|
202 * 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
|
203 * 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
|
204 * 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
|
205 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 SYS_UWORD16 SIM_Command_Base(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, 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
|
208 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 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
|
217 { //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
|
218 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
|
219 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 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
|
221 { //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
|
222 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
|
223 SIM_SleepMode_Out (p); //get up SIM card of sleep mode before executing the command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 } |
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 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
|
227 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 //adaptative driver |
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 (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
|
231 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 offset = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 // 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
|
234 // 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
|
235 // ~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
|
236 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
|
237 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
|
238 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 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
|
240 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 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
|
242 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 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
|
244 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 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
|
246 { //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
|
247 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
|
248 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
|
249 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
|
250 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 return (err); |
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 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
|
255 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 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
|
257 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 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
|
259 { //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
|
260 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
|
261 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
|
262 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
|
263 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 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
|
268 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 // 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
|
270 // 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
|
271 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 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
|
273 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 // 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
|
275 // 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
|
276 // 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
|
277 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
|
278 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 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
|
280 offset++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 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
|
282 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 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
|
285 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
|
286 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 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
|
288 { //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
|
289 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
|
290 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
|
291 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
|
292 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 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
|
298 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 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
|
300 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 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
|
302 { //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
|
303 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
|
304 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
|
305 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
|
306 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 return (err); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 } |
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 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
|
312 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 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
|
314 { //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
|
315 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
|
316 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
|
317 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
|
318 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
319 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
320 return(res); |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 /* Main function to manage the retry mechanism */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, 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
|
326 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 #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
|
329 memset(SIM_dbg_null, 0x00, 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
|
330 SIM_dbg_tdma_diff = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 // Issue initial SIM_Command() call |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 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
|
335 /* 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
|
336 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 #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
|
338 // While there is an error then retry NUM_SIM_RETRIES times |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 while ((res & 0xFF00) == 0) { // Reissue command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 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
|
341 if(++SimRetries > NUM_SIM_RETRIES) { // return special retry failure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 res = SIM_ERR_RETRY_FAILURE; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 break; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 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
|
346 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 #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
|
349 SIM_dbg_null[SIM_DBG_NULL-1] = SimRetries; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 #endif |
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 SimRetries = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 #endif |
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 return(res); |
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 |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 * SIM_ByteReverse |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 * 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
|
367 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 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
|
370 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 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
|
372 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 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
|
374 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
|
375 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 // Up/Down |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 b = ~ b; |
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 // 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
|
380 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
|
381 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
|
382 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 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
|
384 return(b); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 |
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 |
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 * SIM_TxParityErrors |
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 * 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
|
392 * 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
|
393 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 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
|
396 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 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
|
398 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 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
|
400 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 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
|
402 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 * SIM_Reset |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 * 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
|
409 * 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
|
410 * 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
|
411 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
412 * 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
|
413 * 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
|
414 * 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
|
415 * 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
|
416 * 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
|
417 * 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
|
418 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 * 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
|
420 * 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
|
421 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 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
|
423 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
424 return(SIM_Reset_Restart_Internal(cP, 1)); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
425 } |
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 |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
430 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
431 |
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 * SIM_Restart |
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 * 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
|
437 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 * 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
|
439 * 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
|
440 * 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
|
441 * 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
|
442 * 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
|
443 * 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
|
444 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 * 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
|
446 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 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
|
448 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 return(SIM_Reset_Restart_Internal(cP, 0)); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
450 } |
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 |
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_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
|
455 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 * 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
|
457 * 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
|
458 * 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
|
459 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
460 * 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
|
461 * 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
|
462 * 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
|
463 * 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
|
464 * 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
|
465 * 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
|
466 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 * 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
|
468 * 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
|
469 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 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
|
471 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 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
|
473 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
|
474 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
|
475 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
|
476 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 #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
|
478 memset(SIM_dbg_null, 0x00, 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
|
479 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
|
480 memset(SIM_dbg_cmd, 0x00, 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
|
481 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 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
|
485 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
486 // 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
|
487 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
|
488 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
|
489 // 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
|
490 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 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
|
492 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
|
493 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
|
494 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
495 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
|
496 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
497 COLD_RESET: |
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 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
|
500 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
|
501 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
|
502 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
503 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 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
|
511 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
|
512 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
|
513 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
514 |
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->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
|
516 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
517 //#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
|
518 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
519 // // 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
|
520 // 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
|
521 // 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
|
522 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
524 // 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
|
525 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 // |
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_STOP; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 // 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
|
529 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
530 // 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
|
531 // 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
|
532 // // 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
|
533 // 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
|
534 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 // // 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
|
536 // 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
|
537 // 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
|
538 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
539 // //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
540 // #if(ANLG_FAM == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 // SPIABB_wa_VRPC (SPIRead_ABB_Register (PAGE1,VRPCCTRL1) | 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
|
542 // #elif(ANLG_FAM == 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
543 // 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
|
544 // #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
545 // 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
|
546 // |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 //#endif |
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 /*-----------------------------------------------------------*/ |
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 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
|
552 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
553 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
|
554 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 // 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
|
556 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
|
557 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
558 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
|
559 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 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
|
562 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 // 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
|
564 // 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
|
565 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
|
566 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
567 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
|
568 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
569 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
570 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
|
571 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
572 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
574 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
|
575 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
576 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
|
577 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 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
|
579 { // 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
|
580 // 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
|
581 // 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
|
582 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
583 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
|
584 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
585 // 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
|
586 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 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
|
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 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
591 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
|
592 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 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
|
594 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
595 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 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
|
597 } |
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 ATR_Attempt++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
600 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
|
601 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 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
|
606 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 } |
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 // PTS procedure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 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
|
611 // 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
|
612 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 if (BackValue) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
614 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 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
|
616 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
617 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
|
618 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
|
619 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 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
|
621 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
622 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
|
623 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 else |
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 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
|
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 /*-----------------------------------------------------------*/ |
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 //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
|
633 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 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
|
635 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 #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
|
637 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
|
638 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
639 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
|
640 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
642 // 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
|
643 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
|
644 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 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
|
646 } |
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 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
|
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 ((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
|
651 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
|
652 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
|
653 #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
|
654 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
|
655 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 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
|
657 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
659 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
|
660 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 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
|
662 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
|
663 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
664 #endif |
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 else |
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 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
|
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 (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
|
671 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
|
672 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
|
673 #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
|
674 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
|
675 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 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
|
677 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
678 SIM_PowerOff (); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
679 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
|
680 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
681 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
|
682 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
|
683 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 #endif |
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 else |
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->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
|
689 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
690 #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
|
691 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
|
692 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
|
693 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
694 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 // 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
|
698 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
|
699 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
|
700 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
704 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
|
705 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 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
|
707 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 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
|
709 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
711 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
|
712 //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
|
713 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 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
|
715 (p->InsertFunc)(cP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 return(0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
729 |
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 /* 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
|
732 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 * 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
|
734 * 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
|
735 * output : none |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
738 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
|
739 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 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
|
741 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 //!! |
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 = 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
|
744 //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
|
745 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
|
746 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
747 //#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
|
748 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
749 // 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
|
750 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
|
751 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
|
752 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 // 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
|
754 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
|
755 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
756 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
|
757 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
|
758 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
759 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
|
760 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
|
761 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 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
|
764 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
765 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
|
766 // 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
|
767 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
|
768 |
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 //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
|
771 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
|
772 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
|
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_SVCCLEV; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 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
|
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(ANLG_FAM == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
778 //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
|
779 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
780 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
|
781 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
|
782 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
|
783 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
|
784 #elif(ANLG_FAM == 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
785 //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
|
786 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 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
|
788 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
|
789 #elif(ANLG_FAM == 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
790 //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
|
791 //enable VCC |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
792 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
|
793 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
|
794 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
796 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
|
797 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
798 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
|
799 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
800 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
|
801 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
802 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
|
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 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
|
806 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
807 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
|
808 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
809 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 i = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
811 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
|
812 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
813 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
|
814 i++; |
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 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
|
818 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
819 i = 0; |
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 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
|
822 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 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
|
824 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
825 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
|
826 i++; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 } |
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 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
831 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
832 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 /* 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
|
834 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
835 * 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
|
836 * 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
|
837 * output : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
838 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
839 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
840 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
|
841 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
842 // to write |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
843 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
844 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 /* 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
|
846 * input : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
847 * output : none |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
848 */ |
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 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
|
851 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
852 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
|
853 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
|
854 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
855 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
856 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
857 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
858 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
|
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 // 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
|
862 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
|
863 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
|
864 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
865 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
|
866 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
867 #if(ANLG_FAM == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
868 //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
|
869 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
|
870 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCCTRL1) & 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
|
871 #elif(ANLG_FAM == 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
872 //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
|
873 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
|
874 ABB_wa_VRPC (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 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
|
875 #elif(ANLG_FAM == 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
876 //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
|
877 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
|
878 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
|
879 #endif |
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 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
|
882 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 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
|
884 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
885 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
|
886 { //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
|
887 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
|
888 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
892 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 * SIM_Init |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
895 * 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
|
896 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
897 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
898 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
899 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
|
900 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
901 // 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
|
902 (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
|
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_Initialize |
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 * 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
|
909 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
912 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
|
913 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
914 int n; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
915 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
|
916 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
|
917 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 // Initialize registers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 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
|
920 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
|
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->errorSIM = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
923 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
|
924 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
925 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
|
926 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
|
927 //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
|
928 //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
|
929 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
|
930 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
931 #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
|
932 SimRetries = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
934 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
936 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
937 * SIM_Register |
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 * 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
|
940 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 * 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
|
942 * 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
|
943 * |
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 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
|
947 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
948 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
|
949 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
950 // Initialize pointers |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 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
|
952 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 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
|
954 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
|
955 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 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
|
957 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
958 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
959 |
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 * 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
|
962 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
963 * 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
|
964 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 * 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
|
966 * write command |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
967 * 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
|
968 * 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
|
969 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 * 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
|
971 * 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
|
972 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
973 * 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
|
974 * 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
|
975 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
976 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
977 //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
|
978 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
979 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
980 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
981 * SIM_Select |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
982 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
983 * 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
|
984 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
985 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
|
986 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
987 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
|
988 int res; |
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 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
|
991 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 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
|
993 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
|
994 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
|
995 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
|
996 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
|
997 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
|
998 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
|
999 |
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 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
|
1002 /* 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
|
1003 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 // 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
|
1005 // 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
|
1006 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1007 #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
|
1008 SIM_dbg_write_trace((SYS_UWORD8 *)"AACMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1009 SIM_dbg_write_trace(p->xbuf, 7); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 SIM_dbg_write_trace((SYS_UWORD8 *)"AAANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1012 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1013 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 SIM_dbg_write_trace(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
|
1015 if (SIM_dbg_tdma_diff > 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
|
1016 SIM_dbg_max_interchardelay = 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
|
1017 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1018 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1019 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1020 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1021 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1022 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1023 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1024 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1025 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1026 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1027 * SIM_Status |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1028 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1029 * 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
|
1030 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 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
|
1032 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 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
|
1034 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1035 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
|
1036 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1037 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 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
|
1039 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1046 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
|
1047 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1048 #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
|
1049 SIM_dbg_write_trace((SYS_UWORD8 *)"ABCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1050 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 SIM_dbg_write_trace((SYS_UWORD8 *)"ABANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1052 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1054 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1055 SIM_dbg_write_trace(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
|
1056 if (SIM_dbg_tdma_diff > 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
|
1057 SIM_dbg_max_interchardelay = 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
|
1058 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1059 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1060 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1061 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1062 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1063 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1064 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1065 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1066 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1067 * 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
|
1068 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1069 * 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
|
1070 * 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
|
1071 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1072 SYS_UWORD16 SIM_Status_Extended(SYS_UWORD8 *dat, 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
|
1073 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 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
|
1075 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1076 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1077 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1078 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
|
1079 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1086 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
|
1087 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1088 #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
|
1089 SIM_dbg_write_trace((SYS_UWORD8 *)"ACCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1091 SIM_dbg_write_trace((SYS_UWORD8 *)"ACANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1092 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1093 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 SIM_dbg_write_trace(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
|
1096 if (SIM_dbg_tdma_diff > 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
|
1097 SIM_dbg_max_interchardelay = 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
|
1098 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1100 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 #endif |
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 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1104 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1105 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1106 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1107 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1108 * SIM_ReadBinary |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1109 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1110 * 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
|
1111 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1112 SYS_UWORD16 SIM_ReadBinary(SYS_UWORD8 *dat, SYS_UWORD16 offset, 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
|
1113 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1114 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
|
1115 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1116 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1117 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1118 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
|
1119 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1120 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
|
1121 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
|
1122 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
|
1123 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
|
1124 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
|
1125 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1126 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
|
1127 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 // 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
|
1129 // 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
|
1130 // 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
|
1131 // } |
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 #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
|
1134 SIM_dbg_write_trace((SYS_UWORD8 *)"ADCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1135 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 SIM_dbg_write_trace((SYS_UWORD8 *)"ADANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1137 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1138 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1139 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1140 SIM_dbg_write_trace(dat, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1142 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1144 SIM_dbg_write_trace(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
|
1145 if (SIM_dbg_tdma_diff > 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
|
1146 SIM_dbg_max_interchardelay = 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
|
1147 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1148 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1149 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 #endif |
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 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1153 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1154 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1155 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1156 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1157 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1158 * SIM_VerifyChv |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1159 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1160 * 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
|
1161 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1162 SYS_UWORD16 SIM_VerifyCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 chvType, 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
|
1163 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1164 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
|
1165 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
|
1166 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1167 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1168 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1169 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
|
1170 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1179 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
|
1180 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1181 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
|
1182 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 #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
|
1184 SIM_dbg_write_trace((SYS_UWORD8 *)"AECMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1185 SIM_dbg_write_trace(p->xbuf, len+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 SIM_dbg_write_trace((SYS_UWORD8 *)"AEANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1187 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1193 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1194 SIM_dbg_write_trace(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
|
1195 if (SIM_dbg_tdma_diff > 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
|
1196 SIM_dbg_max_interchardelay = 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
|
1197 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1199 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1200 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1202 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 } |
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 |
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 * SIM_RunGSMAlgo |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1208 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1209 * Authentication procedure |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1210 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1211 SYS_UWORD16 SIM_RunGSMAlgo(SYS_UWORD8 *result, 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
|
1212 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1213 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
|
1214 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1215 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1216 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1217 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1218 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
|
1219 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1220 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
|
1221 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
|
1222 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1223 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1224 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 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
|
1230 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 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
|
1232 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 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
|
1234 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1235 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
|
1236 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1237 #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
|
1238 SIM_dbg_write_trace((SYS_UWORD8 *)"AFCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1239 SIM_dbg_write_trace(p->xbuf, len+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1240 SIM_dbg_write_trace((SYS_UWORD8 *)"AFANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1241 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1243 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1245 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1246 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1248 SIM_dbg_write_trace(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
|
1249 if (SIM_dbg_tdma_diff > 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
|
1250 SIM_dbg_max_interchardelay = 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
|
1251 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1252 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1253 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1254 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1256 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
|
1257 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
|
1258 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1259 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1260 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1261 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1262 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1263 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1264 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1265 * SIM_GetResponse |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1266 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1267 * 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
|
1268 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1269 * 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
|
1270 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1271 SYS_UWORD16 SIM_GetResponse(SYS_UWORD8 *dat, 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
|
1272 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1273 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
|
1274 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1275 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1277 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
|
1278 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 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
|
1280 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
|
1281 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
|
1282 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
|
1283 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
|
1284 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1285 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
|
1286 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1287 #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
|
1288 SIM_dbg_write_trace((SYS_UWORD8 *)"AGCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1290 SIM_dbg_write_trace((SYS_UWORD8 *)"AGANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 SIM_dbg_write_trace(dat, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1295 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1297 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1298 SIM_dbg_write_trace(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
|
1299 if (SIM_dbg_tdma_diff > 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
|
1300 SIM_dbg_max_interchardelay = 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
|
1301 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1302 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1303 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1304 #endif |
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 return(res); |
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 |
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 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1311 * SIM_ChangeCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1312 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1313 * 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
|
1314 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1315 SYS_UWORD16 SIM_ChangeCHV(SYS_UWORD8 *result,SYS_UWORD8 *oldChv, SYS_UWORD8 *newChv, SYS_UWORD8 chvType, 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
|
1316 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1317 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
|
1318 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
|
1319 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1320 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
|
1321 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1322 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
|
1323 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1324 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1325 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
|
1326 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
|
1327 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
|
1328 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
|
1329 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
|
1330 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1331 // 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
|
1332 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
|
1333 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1334 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
|
1335 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1336 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
|
1337 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1338 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
|
1339 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1340 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
|
1341 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1342 #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
|
1343 SIM_dbg_write_trace((SYS_UWORD8 *)"AHCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1344 SIM_dbg_write_trace(p->xbuf, len+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1345 SIM_dbg_write_trace((SYS_UWORD8 *)"AHANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1346 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1347 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1348 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1349 SIM_dbg_write_trace(result, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1350 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1351 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1352 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1353 SIM_dbg_write_trace(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
|
1354 if (SIM_dbg_tdma_diff > 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
|
1355 SIM_dbg_max_interchardelay = 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
|
1356 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1357 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1358 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1359 #endif |
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 return(res); |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1364 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1365 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1366 * SIM_DisableCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1367 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1368 * 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
|
1369 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1370 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
|
1371 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1372 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
|
1373 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1374 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1375 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1376 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1377 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
|
1378 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1379 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1380 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
|
1381 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
|
1382 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
|
1383 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
|
1384 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
|
1385 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
|
1386 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1387 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
|
1388 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1389 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
|
1390 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1391 #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
|
1392 SIM_dbg_write_trace((SYS_UWORD8 *)"AICMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1393 SIM_dbg_write_trace(p->xbuf, 8+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1394 SIM_dbg_write_trace((SYS_UWORD8 *)"AIANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1395 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1396 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1397 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1398 SIM_dbg_write_trace(result, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1399 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1400 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1401 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1402 SIM_dbg_write_trace(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
|
1403 if (SIM_dbg_tdma_diff > 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
|
1404 SIM_dbg_max_interchardelay = 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
|
1405 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1406 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1407 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1408 #endif |
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 return(res); |
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 |
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 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1416 * SIM_EnableCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1417 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1418 * 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
|
1419 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1420 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
|
1421 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1422 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
|
1423 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1424 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1425 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1426 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1427 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
|
1428 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1429 len = 8; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1430 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1431 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
|
1432 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
|
1433 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
|
1434 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
|
1435 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
|
1436 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1437 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
|
1438 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1439 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
|
1440 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1441 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1442 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
|
1443 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1444 #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
|
1445 SIM_dbg_write_trace((SYS_UWORD8 *)"AJCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1446 SIM_dbg_write_trace(p->xbuf, len+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1447 SIM_dbg_write_trace((SYS_UWORD8 *)"AJANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1448 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1449 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1450 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1451 SIM_dbg_write_trace(result, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1452 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1453 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1454 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1455 SIM_dbg_write_trace(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
|
1456 if (SIM_dbg_tdma_diff > 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
|
1457 SIM_dbg_max_interchardelay = 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
|
1458 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1459 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1460 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1461 #endif |
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 return(res); |
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 |
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 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1469 * SIM_UnblockCHV |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1470 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1471 * 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
|
1472 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1473 SYS_UWORD16 SIM_UnblockCHV(SYS_UWORD8 *result, SYS_UWORD8 *unblockChv, SYS_UWORD8 *newChv, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1474 SYS_UWORD8 chvType, 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
|
1475 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1476 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
|
1477 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1478 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1479 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1480 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1481 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
|
1482 len = 16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1483 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1484 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
|
1485 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
|
1486 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
|
1487 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
|
1488 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
|
1489 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
|
1490 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1491 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
|
1492 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1493 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
|
1494 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1495 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
|
1496 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1497 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1498 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
|
1499 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1500 #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
|
1501 SIM_dbg_write_trace((SYS_UWORD8 *)"AKCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1502 SIM_dbg_write_trace(p->xbuf, len+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1503 SIM_dbg_write_trace((SYS_UWORD8 *)"AKANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1504 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1505 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1506 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1507 SIM_dbg_write_trace(result, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1508 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1509 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1510 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1511 SIM_dbg_write_trace(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
|
1512 if (SIM_dbg_tdma_diff > 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
|
1513 SIM_dbg_max_interchardelay = 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
|
1514 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1515 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1516 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1517 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1518 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1519 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1520 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1521 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1522 * SIM_Invalidate |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1523 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1524 * 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
|
1525 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1526 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
|
1527 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1528 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
|
1529 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1530 int res; |
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 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
|
1533 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1534 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
|
1535 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
|
1536 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
|
1537 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
|
1538 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
|
1539 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1540 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
|
1541 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1542 #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
|
1543 SIM_dbg_write_trace((SYS_UWORD8 *)"ALCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1544 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1545 SIM_dbg_write_trace((SYS_UWORD8 *)"ALANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1546 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1547 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1548 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1549 SIM_dbg_write_trace(rP, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1550 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1551 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1552 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1553 SIM_dbg_write_trace(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
|
1554 if (SIM_dbg_tdma_diff > 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
|
1555 SIM_dbg_max_interchardelay = 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
|
1556 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1557 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1558 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1559 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1560 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1561 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1562 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1563 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1564 * SIM_Rehabilitate |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1565 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1566 * 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
|
1567 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1568 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
|
1569 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1570 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
|
1571 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1572 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1573 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1574 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
|
1575 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1576 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
|
1577 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
|
1578 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
|
1579 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
|
1580 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
|
1581 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1582 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
|
1583 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1584 #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
|
1585 SIM_dbg_write_trace((SYS_UWORD8 *)"AMCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1586 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1587 SIM_dbg_write_trace((SYS_UWORD8 *)"AMANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1588 SIM_dbg_tmp[0] = (SYS_UWORD8)(*lP >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1589 SIM_dbg_tmp[1] = (SYS_UWORD8)(*lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1590 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1591 SIM_dbg_write_trace(rP, *lP); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1592 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1593 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1594 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1595 SIM_dbg_write_trace(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
|
1596 if (SIM_dbg_tdma_diff > 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
|
1597 SIM_dbg_max_interchardelay = 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
|
1598 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1599 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1600 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1601 #endif |
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 return(res); |
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 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1608 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1609 * SIM_UpdateBinary |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1610 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1611 * 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
|
1612 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1613 SYS_UWORD16 SIM_UpdateBinary(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 offset, 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
|
1614 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1615 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
|
1616 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1617 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1618 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1619 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1620 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
|
1621 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1622 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
|
1623 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
|
1624 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
|
1625 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
|
1626 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
|
1627 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1628 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
|
1629 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1630 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
|
1631 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1632 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
|
1633 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1634 #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
|
1635 SIM_dbg_write_trace((SYS_UWORD8 *)"ANCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1636 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1637 SIM_dbg_write_trace((SYS_UWORD8 *)"ANANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1638 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1639 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1640 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1641 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1642 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1643 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1644 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1645 SIM_dbg_write_trace(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
|
1646 if (SIM_dbg_tdma_diff > 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
|
1647 SIM_dbg_max_interchardelay = 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
|
1648 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1649 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1650 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1651 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1652 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1653 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1654 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1655 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1656 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1657 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1658 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1659 * SIM_ReadRecord |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1660 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1661 * 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
|
1662 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1663 SYS_UWORD16 SIM_ReadRecord(SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, 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
|
1664 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1665 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
|
1666 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1667 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1668 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1669 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
|
1670 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1671 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
|
1672 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
|
1673 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
|
1674 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
|
1675 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
|
1676 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1677 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
|
1678 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1679 #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
|
1680 SIM_dbg_write_trace((SYS_UWORD8 *)"AOCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1681 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1682 SIM_dbg_write_trace((SYS_UWORD8 *)"AOANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1683 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1684 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1685 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1686 SIM_dbg_write_trace(dat, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1687 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1688 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1689 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1690 SIM_dbg_write_trace(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
|
1691 if (SIM_dbg_tdma_diff > 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
|
1692 SIM_dbg_max_interchardelay = 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
|
1693 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1694 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1695 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1696 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1697 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1698 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1699 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1700 } |
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_APDU_TEST |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 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
|
1708 #endif |
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 #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
|
1711 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
|
1712 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
|
1713 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
|
1714 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1715 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1716 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1717 * SIM_UpdateRecord |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1718 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1719 * 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
|
1720 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1721 SYS_UWORD16 SIM_UpdateRecord(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, 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
|
1722 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1723 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
|
1724 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1725 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1726 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1727 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1728 #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
|
1729 // 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
|
1730 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
|
1731 SIM_PowerOff(); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1732 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
|
1733 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
|
1734 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
|
1735 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1736 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1737 #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
|
1738 // send OPEN LOGICAL CHANNEL |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1739 snd[0] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1740 snd[1] = 0x70; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1741 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
|
1742 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1743 snd[4] = 0x01; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1744 resopen = SIM_XchTPDU(&snd[0], 5, &rec[0], 1, &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1745 if (resopen == 0x9000) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1746 logchan = rec[0]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1747 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1748 // Select AID PKCS |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1749 snd[0] = logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1750 snd[1] = 0xA4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1751 snd[2] = 0x04; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1752 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1753 snd[4] = 0x0C; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1754 snd[5] = 0xA0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1755 snd[6] = 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[7] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1757 snd[8] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1758 snd[9] = 0x63; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1759 snd[10] = 0x50; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1760 snd[11] = 0x4B; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1761 snd[12] = 0x43; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1762 snd[13] = 0x53; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1763 snd[14] = 0x2D; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1764 snd[15] = 0x31; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1765 snd[16] = 0x35; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1766 rescmd = SIM_XchTPDU(&snd[0], 17, &rec[0], 0, &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1767 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1768 // Select file EF odf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1769 snd[0] = 0x80 | logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1770 snd[1] = 0xA4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1771 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
|
1772 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1773 snd[4] = 0x02; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1774 snd[5] = 0x50; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1775 snd[6] = 0x31; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1776 rescmd = SIM_XchTPDU(&snd[0], 7, &rec[0], 0, &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1777 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1778 // get response EF odf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1779 snd[0] = logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1780 snd[1] = 0xC0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1781 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
|
1782 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1783 snd[4] = rescmd; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1784 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1785 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1786 // read binary EF odf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1787 snd[0] = 0x80 | logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1788 snd[1] = 0xB0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1789 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
|
1790 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1791 snd[4] = rec[3]-16; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1792 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1793 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1794 // Select file EF cdf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1795 snd[0] = 0x80 | logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1796 snd[1] = 0xA4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1797 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
|
1798 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1799 snd[4] = 0x02; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1800 snd[5] = 0x51; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1801 snd[6] = 0x03; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1802 rescmd = SIM_XchTPDU(&snd[0], 7, &rec[0], 0, &recl); |
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 // get response EF odf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1805 snd[0] = logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1806 snd[1] = 0xC0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1807 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
|
1808 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1809 snd[4] = rescmd; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1810 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
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 // read binary EF cdf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1813 snd[0] = 0x80 | logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1814 snd[1] = 0xB0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1815 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
|
1816 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1817 snd[4] = 0xff; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1818 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], snd[4], &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1819 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1820 // read binary EF cdf |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1821 snd[0] = 0x80 | logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1822 snd[1] = 0xB0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1823 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
|
1824 snd[3] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1825 snd[4] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1826 rescmd = SIM_XchTPDU(&snd[0], 5, &rec[0], 256, &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1827 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1828 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1829 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1830 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1831 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1832 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1833 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1834 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
|
1835 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1836 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
|
1837 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
|
1838 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
|
1839 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
|
1840 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
|
1841 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1842 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
|
1843 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1844 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
|
1845 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1846 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1847 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
|
1848 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1849 #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
|
1850 SIM_dbg_write_trace((SYS_UWORD8 *)"APCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1851 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1852 SIM_dbg_write_trace((SYS_UWORD8 *)"APANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1853 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1854 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1855 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1856 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1857 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1858 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1859 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1860 SIM_dbg_write_trace(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
|
1861 if (SIM_dbg_tdma_diff > 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
|
1862 SIM_dbg_max_interchardelay = 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
|
1863 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1864 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1865 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1866 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1867 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1868 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1869 #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
|
1870 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1871 // send CLOSE LOGICAL CHANNEL |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1872 snd[0] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1873 snd[1] = 0x70; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1874 snd[2] = 0x80; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1875 snd[3] = logchan; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1876 snd[4] = 0x00; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1877 resclose = SIM_XchTPDU(&snd[0], 5, &rec[0], 0, &recl); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1878 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1879 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1880 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1881 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1882 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1883 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1884 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1885 * SIM_Seek |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1886 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1887 * 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
|
1888 * 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
|
1889 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1890 SYS_UWORD16 SIM_Seek(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, 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
|
1891 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1892 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
|
1893 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1894 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1895 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1896 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1897 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
|
1898 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1899 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
|
1900 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
|
1901 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
|
1902 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
|
1903 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
|
1904 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1905 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
|
1906 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1907 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
|
1908 } |
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 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
|
1911 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1912 #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
|
1913 SIM_dbg_write_trace((SYS_UWORD8 *)"AQCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1914 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1915 SIM_dbg_write_trace((SYS_UWORD8 *)"AQANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1916 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1917 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1918 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1919 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1920 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1921 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1922 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1923 SIM_dbg_write_trace(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
|
1924 if (SIM_dbg_tdma_diff > 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
|
1925 SIM_dbg_max_interchardelay = 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
|
1926 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1927 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1928 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1929 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1930 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1931 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1932 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1933 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1934 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1935 * SIM_Increase |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1936 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1937 * 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
|
1938 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1939 SYS_UWORD16 SIM_Increase(SYS_UWORD8 *result, 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
|
1940 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1941 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
|
1942 int len; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1943 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1944 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1945 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1946 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
|
1947 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1948 len = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1949 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1950 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
|
1951 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
|
1952 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
|
1953 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
|
1954 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
|
1955 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1956 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
|
1957 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1958 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
|
1959 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1960 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1961 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
|
1962 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1963 #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
|
1964 SIM_dbg_write_trace((SYS_UWORD8 *)"ARCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1965 SIM_dbg_write_trace(p->xbuf, 3+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1966 SIM_dbg_write_trace((SYS_UWORD8 *)"ARANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1967 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1968 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1969 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1970 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1971 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1972 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1973 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1974 SIM_dbg_write_trace(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
|
1975 if (SIM_dbg_tdma_diff > 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
|
1976 SIM_dbg_max_interchardelay = 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
|
1977 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1978 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
1979 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1980 #endif |
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 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1983 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1984 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1985 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1986 * SIM_TerminalProfile |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1987 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1988 * 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
|
1989 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1990 SYS_UWORD16 SIM_TerminalProfile(SYS_UWORD8 *result, SYS_UWORD8 *dat, 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
|
1991 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1992 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
|
1993 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1994 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1995 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
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 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
|
1998 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1999 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
|
2000 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
|
2001 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
|
2002 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
|
2003 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
|
2004 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2005 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
|
2006 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2007 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
|
2008 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2009 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2010 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
|
2011 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2012 #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
|
2013 SIM_dbg_write_trace((SYS_UWORD8 *)"ASCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2014 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2015 SIM_dbg_write_trace((SYS_UWORD8 *)"ASANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2016 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2017 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2018 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2019 SIM_dbg_write_trace(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
|
2020 if (SIM_dbg_tdma_diff > 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
|
2021 SIM_dbg_max_interchardelay = 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
|
2022 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2023 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
2024 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2025 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2026 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2027 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2028 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2029 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2030 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2031 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2032 * SIM_FETCH |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2033 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2034 * 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
|
2035 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2036 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
|
2037 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2038 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
|
2039 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2040 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2041 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2042 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2043 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
|
2044 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2045 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
|
2046 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
|
2047 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
|
2048 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
|
2049 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
|
2050 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2051 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2052 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
|
2053 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2054 #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
|
2055 SIM_dbg_write_trace((SYS_UWORD8 *)"ATCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2056 SIM_dbg_write_trace(p->xbuf, 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2057 SIM_dbg_write_trace((SYS_UWORD8 *)"ATANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2058 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2059 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2060 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2061 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2062 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2063 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2064 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2065 SIM_dbg_write_trace(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
|
2066 if (SIM_dbg_tdma_diff > 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
|
2067 SIM_dbg_max_interchardelay = 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
|
2068 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2069 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
2070 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2071 #endif |
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 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2074 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2075 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2076 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2077 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2078 * SIM_TerminalResponse * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2079 * 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
|
2080 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2081 SYS_UWORD16 SIM_TerminalResponse(SYS_UWORD8 *result, SYS_UWORD8 *dat, 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
|
2082 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2083 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
|
2084 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2085 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2086 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
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 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
|
2089 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2090 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
|
2091 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
|
2092 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
|
2093 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
|
2094 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
|
2095 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2096 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
|
2097 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2098 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
|
2099 } |
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 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
|
2102 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2103 #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
|
2104 SIM_dbg_write_trace((SYS_UWORD8 *)"AUCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2105 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2106 SIM_dbg_write_trace((SYS_UWORD8 *)"AUANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2107 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2108 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2109 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2110 SIM_dbg_write_trace(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
|
2111 if (SIM_dbg_tdma_diff > 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
|
2112 SIM_dbg_max_interchardelay = 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
|
2113 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2114 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
2115 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2116 #endif |
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 return(res); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2119 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2122 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2123 * SIM_Envelope |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2124 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2125 * Used by Network to tansfert data download to the SIM in a transparent way for user |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2126 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2127 SYS_UWORD16 SIM_Envelope(SYS_UWORD8 *result, SYS_UWORD8 *dat, 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
|
2128 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2129 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
|
2130 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2131 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2132 SYS_UWORD16 llen = len & SIM_UWORD16_MASK; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2133 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2134 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
|
2135 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2136 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
|
2137 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
|
2138 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
|
2139 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
|
2140 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
|
2141 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2142 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
|
2143 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2144 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
|
2145 } |
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 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
|
2148 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2149 #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
|
2150 SIM_dbg_write_trace((SYS_UWORD8 *)"AVCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2151 SIM_dbg_write_trace(p->xbuf, llen+5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2152 SIM_dbg_write_trace((SYS_UWORD8 *)"AVANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2153 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2154 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2155 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2156 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2157 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2158 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2159 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2160 SIM_dbg_write_trace(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
|
2161 if (SIM_dbg_tdma_diff > 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
|
2162 SIM_dbg_max_interchardelay = 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
|
2163 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2164 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
2165 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2166 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2167 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2168 return(res); |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2171 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2172 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2173 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2174 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2175 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2176 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2177 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2178 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2179 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2180 * SIM_XchTPDU * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2181 * 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
|
2182 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2183 SYS_UWORD16 SIM_XchTPDU(SYS_UWORD8 *dat, SYS_UWORD16 trxLen, SYS_UWORD8 *result, |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2184 SYS_UWORD16 rcvLen, 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
|
2185 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2186 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
|
2187 int i; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2188 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2189 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2190 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
|
2191 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2192 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
|
2193 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
|
2194 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
|
2195 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
|
2196 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
|
2197 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2198 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
|
2199 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2200 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
|
2201 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2202 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2203 // enable the WIM behavior of the sim driver |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2204 p->apdu_ans_length = rcvLen; |
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 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
|
2207 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2208 // disable the WIM behavior of the sim driver |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2209 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
|
2210 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2211 #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
|
2212 SIM_dbg_write_trace((SYS_UWORD8 *)"AWCMD", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2213 SIM_dbg_write_trace(p->xbuf, trxLen); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2214 SIM_dbg_write_trace((SYS_UWORD8 *)"AWANS", 5); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2215 SIM_dbg_tmp[0] = (SYS_UWORD8)(*rcvSize >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2216 SIM_dbg_tmp[1] = (SYS_UWORD8)(*rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2217 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2218 SIM_dbg_write_trace(result, *rcvSize); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2219 SIM_dbg_tmp[0] = (SYS_WORD8)(res>>8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2220 SIM_dbg_tmp[1] = (SYS_WORD8)res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2221 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2222 SIM_dbg_write_trace(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
|
2223 if (SIM_dbg_tdma_diff > 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
|
2224 SIM_dbg_max_interchardelay = 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
|
2225 SIM_dbg_tmp[0] = (SYS_UWORD8)(SIM_dbg_tdma_diff >> 8); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2226 SIM_dbg_tmp[1] = (SYS_UWORD8)(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
|
2227 SIM_dbg_write_trace(SIM_dbg_tmp, 2); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2228 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2229 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2230 return(res); |
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 |
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 |
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 |
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 |
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 * 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
|
2242 * 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
|
2243 * 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
|
2244 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2245 * 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
|
2246 * 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
|
2247 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2248 */ |
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 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
|
2251 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2252 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
|
2253 |
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 //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
|
2256 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2257 if ( |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2258 (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
|
2259 (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
|
2260 (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
|
2261 (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
|
2262 (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
|
2263 (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
|
2264 ) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2265 //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
|
2266 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2267 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
|
2268 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2269 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
|
2270 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2271 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2272 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2273 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
|
2274 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2275 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2276 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
|
2277 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2278 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
|
2279 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2280 return returncode; |
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 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
|
2284 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2285 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
|
2286 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2287 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
|
2288 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2289 return returncode; |
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 return (0); |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2295 |
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 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2298 * 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
|
2299 * 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
|
2300 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2301 * 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
|
2302 * 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
|
2303 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2304 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2305 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2306 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2307 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
|
2308 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2309 int res; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2310 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
|
2311 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
|
2312 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2313 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
|
2314 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
|
2315 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2316 res = SIM_Select(DF_DCS1800, ubuf, &sz); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2317 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
|
2318 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2319 return (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2320 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2321 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2322 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
|
2323 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
|
2324 return (1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2325 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2326 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
|
2327 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2328 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2329 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2330 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2331 * 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
|
2332 * 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
|
2333 * 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
|
2334 * 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
|
2335 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2336 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2337 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2338 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2339 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
|
2340 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2341 //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
|
2342 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
|
2343 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2344 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
|
2345 } |
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 //interpret Clock stop behavior |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2348 // modified by J. Yp-Tcha to integrate all the behaviors required by ETSI. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2349 // 18/11/2002 : TI Chip always allowed low level, high level is hard dependant |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2350 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2351 if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_NOT_ALLWD) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2352 /* Sim Clock Stop Not Allowed */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2353 SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2354 /* There is not need to modifiy p->conf1 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2355 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
|
2356 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2357 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2358 if ((p->FileC & SIM_CLK_STOP_MASK) == SIM_CLK_STOP_ALLWD) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2359 /* Sim Clock Stop Allowed, no prefered level */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2360 /* Default value for TI Chip shall always be Low Level */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2361 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
|
2362 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
|
2363 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2364 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2365 /* Clock Stop is allowed, the level shall be checked */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2366 if ((p->FileC & SIM_CLK_STOP_HIGH) == SIM_CLK_STOP_HIGH) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2367 /* high level is mandatory */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2368 /* 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
|
2369 #ifndef ANALOG1 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2370 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
|
2371 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
|
2372 #else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2373 /* Sim Clock Stop Not Allowed because the interface do not support this level */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2374 SIM_sleep_status = SIM_SLEEP_NOT_ALLOWED; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2375 /* There is not need to modifiy p->conf1 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2376 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
|
2377 #endif |
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 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2380 /* by default, Low Level is allowed */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2381 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
|
2382 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
|
2383 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2384 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2385 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2386 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
|
2387 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2388 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
|
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 |
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 * 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
|
2394 * 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
|
2395 * 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
|
2396 * 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
|
2397 * 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
|
2398 * value. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2399 * 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
|
2400 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2401 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2402 |
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 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
|
2405 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2406 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2407 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
|
2408 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
|
2409 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
|
2410 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2411 p->xbuf[0] = 0xFF; //character of PTS proc to send |
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] = 0; |
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] = 0xFF; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2414 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
|
2415 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2416 //TA1,TB1,TC1,TD1 present in ATR ? |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2417 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2418 n = 3; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2419 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2420 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
|
2421 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2422 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
|
2423 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2424 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
|
2425 } // at the fourth attempt, PTS procedure is unusefull. Use default value. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2426 //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
|
2427 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
|
2428 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2429 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
|
2430 return (0); |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2433 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
|
2434 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2435 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
|
2436 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2437 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
|
2438 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2439 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
|
2440 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2441 } |
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 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
|
2444 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
|
2445 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2446 // 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
|
2447 //#ifdef NOTTOLOADBECAUSENOTTESTED |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2448 // 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
|
2449 // 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
|
2450 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2451 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
|
2452 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2453 n = 4; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2454 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
|
2455 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
|
2456 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2457 //#endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2458 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2459 #endif |
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 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
|
2462 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2463 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
|
2464 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2465 } //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
|
2466 //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
|
2467 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
|
2468 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2469 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
|
2470 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
|
2471 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2472 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
|
2473 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2474 return (err); |
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 //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
|
2477 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
|
2478 (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
|
2479 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2480 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
|
2481 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2484 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
|
2485 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2486 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
|
2487 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2488 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
|
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 //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
|
2492 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
|
2493 } |
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 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
|
2496 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2497 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2498 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2499 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2500 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2501 * 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
|
2502 * 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
|
2503 * 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
|
2504 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2505 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2506 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
|
2507 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2508 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2509 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
|
2510 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
|
2511 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
|
2512 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
|
2513 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2514 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2517 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2518 * 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
|
2519 * 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
|
2520 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2521 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2522 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
|
2523 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2524 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
|
2525 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2526 (&(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
|
2527 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
|
2528 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2529 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
|
2530 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2531 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2532 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2533 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2534 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2535 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2536 * 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
|
2537 * 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
|
2538 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2539 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2540 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
|
2541 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2542 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
|
2543 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2544 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
|
2545 // 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
|
2546 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
|
2547 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
|
2548 // 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
|
2549 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
|
2550 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2551 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2552 |
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 * 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
|
2555 * 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
|
2556 * 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
|
2557 * 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
|
2558 * 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
|
2559 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2560 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2561 */ |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2564 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
|
2565 { |
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 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
|
2568 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
|
2569 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
|
2570 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
|
2571 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
|
2572 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
|
2573 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
|
2574 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
|
2575 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
|
2576 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
|
2577 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
|
2578 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
|
2579 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2580 i = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2581 //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
|
2582 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
|
2583 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
|
2584 firstprotocol = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2585 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
|
2586 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
|
2587 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
|
2588 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
|
2589 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2590 //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
|
2591 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
|
2592 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2593 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2594 } |
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 //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
|
2597 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
|
2598 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
|
2599 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2600 return returncode; |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2603 ind_os_sleep(220); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2604 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2605 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
|
2606 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2607 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
|
2608 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2609 /*-----------------------------------------------------------*/ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2610 /* 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
|
2611 // 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
|
2612 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
|
2613 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2614 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
|
2615 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2616 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2617 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2618 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
|
2619 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2620 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2621 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2622 mask = 0x10; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2623 InterfChar = 2; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2624 TDi = 1; |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2627 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
|
2628 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2629 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
|
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 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
|
2633 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2634 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
|
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 & 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
|
2637 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2638 InterfChar++; |
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 //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
|
2641 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
|
2642 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2643 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
|
2644 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2645 if ((firstprotocol == 0) && ((Tx & 0x20) == mask)) |
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 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
|
2648 } |
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 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
|
2651 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2652 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2653 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
|
2654 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2655 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
|
2656 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2657 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2658 } |
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 //need to monitor if TC1 present and if equal to 0 or 255 on first protocol |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2661 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
|
2662 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2663 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
|
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 ((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
|
2666 { //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
|
2667 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
|
2668 } |
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 //need to monitor if TB1 present and if differente from 0 on first protocol |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2671 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
|
2672 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2673 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
|
2674 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2675 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
|
2676 { //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
|
2677 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
|
2678 } |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2681 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
|
2682 { //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
|
2683 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
|
2684 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2685 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
|
2686 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2687 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
|
2688 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2689 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
|
2690 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2691 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2692 { //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
|
2693 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
|
2694 } |
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 mask = 0x10; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2697 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
|
2698 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2699 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2700 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2701 TDi = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2702 } |
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 //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
|
2705 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
|
2706 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2707 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
|
2708 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2709 return returncode; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2710 } |
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 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
|
2713 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2714 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
|
2715 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2716 // 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
|
2717 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
|
2718 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2719 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
|
2720 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2721 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
|
2722 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2723 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
|
2724 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2725 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
|
2726 // 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
|
2727 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
|
2728 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2729 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
|
2730 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2731 } |
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 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2734 } |
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 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2737 ** 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
|
2738 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2739 * 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
|
2740 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2741 * 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
|
2742 * 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
|
2743 * 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
|
2744 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2745 * 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
|
2746 * 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
|
2747 */ |
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 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
|
2750 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2751 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
|
2752 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2753 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
|
2754 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2755 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
|
2756 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2757 else |
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 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
|
2760 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2761 return (translated); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2762 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2763 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2764 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2765 |
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 * 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
|
2768 * 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
|
2769 * 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
|
2770 * output |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2771 * 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
|
2772 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2773 |
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 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
|
2776 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2777 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
|
2778 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
|
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->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
|
2781 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2782 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
|
2783 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2784 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2785 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
|
2786 { //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
|
2787 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2788 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
|
2789 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
|
2790 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2791 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
|
2792 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2793 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2794 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
|
2795 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2796 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2797 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
|
2798 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2799 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
|
2800 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2801 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
|
2802 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2803 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
|
2804 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2805 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2806 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
|
2807 { //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
|
2808 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2809 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2810 } |
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 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
|
2813 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2814 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2815 old_nb_char = 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
|
2816 //leave while if moderx == 5 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2817 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
|
2818 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2819 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
|
2820 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
|
2821 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2822 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
|
2823 { |
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 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
|
2826 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2827 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2828 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
|
2829 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2830 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
|
2831 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2832 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
|
2833 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2834 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
|
2835 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2836 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
|
2837 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2838 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
|
2839 countT = 0; |
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 } //end while |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2842 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
|
2843 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2844 return (0); |
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 } |
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 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
|
2849 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2850 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2851 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
|
2852 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2853 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
|
2854 { //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
|
2855 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2856 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
|
2857 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
|
2858 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2859 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
|
2860 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2861 countT = 0; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2862 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
|
2863 } |
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 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
|
2866 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2867 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
|
2868 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2869 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
|
2870 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2871 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
|
2872 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2873 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
|
2874 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2875 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
|
2876 countT = 0; |
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 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
|
2880 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2881 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2882 else //treatement of abnormal case of the asynchronous state machine |
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 return (SIM_ERR_ABNORMAL_CASE1); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2885 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2886 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2887 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2888 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2889 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2890 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2891 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2892 * 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
|
2893 * 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
|
2894 * 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
|
2895 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2896 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2897 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
|
2898 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2899 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
|
2900 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2901 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
|
2902 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2903 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
|
2904 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
|
2905 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
|
2906 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
|
2907 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2908 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
|
2909 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2910 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
|
2911 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
|
2912 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
|
2913 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
|
2914 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2915 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2916 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
|
2917 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2918 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
|
2919 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2920 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
|
2921 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
|
2922 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
|
2923 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
|
2924 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2925 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
|
2926 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2927 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
|
2928 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
|
2929 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
|
2930 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
|
2931 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2932 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2933 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2934 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2935 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2936 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2937 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2938 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2939 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2940 * 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
|
2941 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2942 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2943 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2944 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
|
2945 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2946 SYS_UWORD8 abbmask; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2947 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2948 #if(ANLG_FAM == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2949 // 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
|
2950 #if ((SIM_TYPE == SIM_TYPE_3V) || (SIM_TYPE == SIM_TYPE_3_5V)) // { 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
|
2951 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2952 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
|
2953 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2954 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2955 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2956 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
|
2957 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
|
2958 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2959 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
|
2960 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2961 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
|
2962 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
|
2963 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
|
2964 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2965 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2966 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2967 #if(ANLG_FAM == 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2968 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
|
2969 // 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
|
2970 // 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
|
2971 #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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2972 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2973 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
|
2974 CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2975 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2976 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2977 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
|
2978 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
|
2979 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2980 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
|
2981 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2982 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
|
2983 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
|
2984 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2985 if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 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
|
2986 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
|
2987 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
|
2988 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2989 // 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
|
2990 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
|
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 // 3V only |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2993 #if (SIM_TYPE == SIM_TYPE_3V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2994 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
|
2995 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2996 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
|
2997 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
|
2998 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2999 if (ABB_Read_Register_on_page(PAGE1,VRPCSIM) & 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
|
3000 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
|
3001 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
|
3002 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3003 // 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
|
3004 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
|
3005 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3006 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3007 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3008 #if(ANLG_FAM == 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3009 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
|
3010 // 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
|
3011 // 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
|
3012 #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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3013 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3014 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
|
3015 CurrentVolt = SIM_1_8V; // we assume the sim is 1.8v tech. from beginning. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3016 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3017 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3018 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
|
3019 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
|
3020 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3021 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
|
3022 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3023 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
|
3024 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
|
3025 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3026 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
|
3027 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
|
3028 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
|
3029 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3030 // 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
|
3031 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
|
3032 #endif |
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 // 3V only |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3035 #if (SIM_TYPE == SIM_TYPE_3V) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3036 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
|
3037 CurrentVolt = SIM_3V; // we assume the sim is 3v tech. from beginning. |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3038 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
|
3039 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
|
3040 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3041 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
|
3042 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
|
3043 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
|
3044 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3045 // 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
|
3046 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
|
3047 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3048 #endif |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3051 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3052 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3053 * 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
|
3054 * |
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 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3057 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3058 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
|
3059 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3060 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
|
3061 SYS_UWORD8 abbmask; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3062 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3063 SIM_PowerOff(); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3064 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3065 #if(ANLG_FAM == 1) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3066 #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
|
3067 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3068 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
|
3069 CurrentVolt = SIM_5V; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3070 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3071 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3072 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
|
3073 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
|
3074 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3075 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
|
3076 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3077 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
|
3078 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
|
3079 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3080 #elif(ANLG_FAM == 2) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3081 #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
|
3082 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3083 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
|
3084 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
|
3085 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3086 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3087 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
|
3088 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
|
3089 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3090 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
|
3091 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3092 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
|
3093 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
|
3094 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3095 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
|
3096 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
|
3097 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
|
3098 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3099 // 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
|
3100 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
|
3101 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3102 #elif(ANLG_FAM == 3) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3103 #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
|
3104 if (ResetFlag) { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3105 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
|
3106 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
|
3107 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3108 else { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3109 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
|
3110 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
|
3111 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3112 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
|
3113 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3114 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
|
3115 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
|
3116 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3117 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
|
3118 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
|
3119 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
|
3120 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3121 // 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
|
3122 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
|
3123 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3124 #endif // ANLG_FAM == 1, 2, 3 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3125 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3126 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3127 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3128 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3129 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3130 SYS_UWORD8 SIM_Memcpy(SYS_UWORD8 *Buff_target, SYS_UWORD8 Buff_source[], 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
|
3131 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3132 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
|
3133 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3134 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
|
3135 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3136 if (i == RSIMBUFSIZE) |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3137 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3138 return (SIM_ERR_BUFF_OVERFL); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3139 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3140 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3141 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3142 (*(Buff_target+i)) = Buff_source[i]; |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3143 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3144 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3145 return (0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3146 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3147 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3148 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3149 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3150 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3151 * SIM_SleepStatus |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3152 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3153 * 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
|
3154 * |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3155 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3156 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
|
3157 { |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3158 if ((SIM_sleep_status == SIM_SLEEP_ACT) || (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
|
3159 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
|
3160 else |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3161 return(0); |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3162 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3163 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3164 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3165 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3166 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3167 /* |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3168 * 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
|
3169 */ |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3170 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
|
3171 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3172 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3173 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3174 #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
|
3175 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
|
3176 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
|
3177 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
|
3178 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
|
3179 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
|
3180 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
|
3181 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3182 } |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3183 #endif |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3184 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3185 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3186 |
5e0e41cd7c9f
gsm-fw/bsp/sim*.c: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3187 |