annotate miscutil/arfcn2ti.c @ 853:faf91432121a

CHANGES: first change since fc-host-tools-r16
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Oct 2021 21:34:35 +0000
parents b8cb116a7dc7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
758
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * TI's TCS211 L1 does not use standard ARFCNs internally, instead it uses
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * its own non-standard radio_freq numbers in their place. Other firmware
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * components and all external interfaces do use standard ARFCNs, thus
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * conversion functions are invoked at appropriate points in the firmware.
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * However, L1-internal radio_freq numbers are emitted in L1 debug traces,
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 * thus anyone looking at these traces needs to be able to convert between
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * standard ARFCNs and L1-internal radio_freq.
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * The present utility converts a standard ARFCN into TI L1 radio_freq.
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 */
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdio.h>
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <stdlib.h>
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <string.h>
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <strings.h>
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 main(argc, argv)
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 char **argv;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 int arfcn;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (argc != 3) {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 usage: fprintf(stderr, "usage: %s {eu|us} arfcn\n", argv[0]);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 exit(1);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 arfcn = atoi(argv[2]);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (!strcmp(argv[1], "eu"))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 arfcn2ti_eu(arfcn);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 else if (!strcmp(argv[1], "us"))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 arfcn2ti_us(arfcn);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 else
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 goto usage;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(0);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 arfcn2ti_eu(arfcn)
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (arfcn == 0)
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 arfcn = 174;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 else if ((arfcn >= 975) && (arfcn <= 1023))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 arfcn -= 850;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 else if ((arfcn >= 512) && (arfcn <= 885))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 arfcn -= 337;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 else if ((arfcn >= 1) && (arfcn <= 124))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 ;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 else {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 fprintf(stderr,
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 "error: specified ARFCN is invalid for dual-EU\n");
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 exit(1);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 printf("%d\n", arfcn);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 arfcn2ti_us(arfcn)
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if ((arfcn >= 128) && (arfcn <= 251))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 arfcn -= 127;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 else if ((arfcn >= 512) && (arfcn <= 810))
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 arfcn -= 387;
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 else {
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 fprintf(stderr,
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 "error: specified ARFCN is invalid for dual-US\n");
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 exit(1);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 printf("%d\n", arfcn);
b8cb116a7dc7 arfcn2ti utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }