FreeCalypso > hg > freecalypso-tools
annotate target-utils/simagent/spenh.c @ 1013:bc4dc383ff4a default tip
doc/Loadtools-usage: list SE J110/120 pair properly
These two Chi-Mei phones are variants of the same design
with only minor diffs.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 23 Sep 2024 12:28:57 +0000 |
parents | b761029f9c03 |
children |
rev | line source |
---|---|
779
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <strings.h> |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include "types.h" |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include "simregs.h" |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
786
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
6 extern int sim_if_state; |
779
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 extern u16 conf1_reg; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
786
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
9 const u8 pts_for_spenh[4] = {0xFF, 0x10, 0x94, 0x7B}; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
10 |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
11 void |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
12 cmd_spenh() |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
13 { |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
14 int rc; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
15 unsigned count; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
16 |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
17 if (sim_if_state != 2) { |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
18 printf("ERROR: SIM interface is not up\n"); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
19 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
20 } |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
21 if (conf1_reg & SIM_CONF1_ETU) { |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
22 printf("ERROR: speed enhancement is already on\n"); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
23 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
24 } |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
25 rc = flush_rx_fifo(); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
26 if (rc < 0) |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
27 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
28 rc = send_to_sim(pts_for_spenh, 4); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
29 if (rc < 0) |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
30 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
31 for (count = 0; count < 4; count++) { |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
32 rc = rx_sim_byte_hl(); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
33 if (rc < 0) |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
34 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
35 if (rc != pts_for_spenh[count]) { |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
36 printf("ERROR: PTS response does not match request\n"); |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
37 return; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
38 } |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
39 } |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
40 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_ETU; |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
41 } |
b761029f9c03
simagent: spenh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
779
diff
changeset
|
42 |
779
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 void |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 cmd_set_spenh(argbulk) |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 char *argbulk; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 char *argv[2]; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (parse_args(argbulk, 1, 1, argv, 0) < 0) |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 return; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (!strcmp(argv[0], "0")) |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_ETU; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 else if (!strcmp(argv[0], "1")) |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_ETU; |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 else |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 printf("ERROR: \"0\" or \"1\" argument expected\n"); |
8196bba46318
simagent: set-spenh test command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |