comparison miscutil/arfcn2ti.c @ 758:b8cb116a7dc7

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