FreeCalypso > hg > freecalypso-tools
comparison miscutil/ti2arfcn.c @ 759:d2fccd82a83e
ti2arfcn utility added to miscutil
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 27 Nov 2020 04:39:38 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
758:b8cb116a7dc7 | 759:d2fccd82a83e |
---|---|
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 TI's radio_freq numbers as seen in L1 traces | |
11 * into standard ARFCNs. | |
12 */ | |
13 | |
14 #include <stdio.h> | |
15 #include <stdlib.h> | |
16 #include <string.h> | |
17 #include <strings.h> | |
18 | |
19 main(argc, argv) | |
20 char **argv; | |
21 { | |
22 int ti_num; | |
23 | |
24 if (argc != 3) { | |
25 usage: fprintf(stderr, "usage: %s {eu|us} L1_radio_freq\n", argv[0]); | |
26 exit(1); | |
27 } | |
28 ti_num = atoi(argv[2]); | |
29 if (!strcmp(argv[1], "eu")) | |
30 ti2arfcn_eu(ti_num); | |
31 else if (!strcmp(argv[1], "us")) | |
32 ti2arfcn_us(ti_num); | |
33 else | |
34 goto usage; | |
35 exit(0); | |
36 } | |
37 | |
38 ti2arfcn_eu(radio_freq) | |
39 { | |
40 int arfcn; | |
41 | |
42 if (radio_freq < 1 || radio_freq > 548) { | |
43 fprintf(stderr, | |
44 "error: specified radio_freq is out of range for dual-EU\n"); | |
45 exit(1); | |
46 } | |
47 if (radio_freq < 175) { | |
48 if (radio_freq <= 124) | |
49 arfcn = radio_freq; | |
50 else if (radio_freq < 174) | |
51 arfcn = radio_freq - 125 + 975; | |
52 else | |
53 arfcn = 0; | |
54 } else | |
55 arfcn = radio_freq - 175 + 512; | |
56 printf("%d\n", arfcn); | |
57 } | |
58 | |
59 ti2arfcn_us(radio_freq) | |
60 { | |
61 int arfcn; | |
62 | |
63 if (radio_freq < 1 || radio_freq > 423) { | |
64 fprintf(stderr, | |
65 "error: specified radio_freq is out of range for dual-US\n"); | |
66 exit(1); | |
67 } | |
68 if (radio_freq < 125) | |
69 arfcn = radio_freq - 1 + 128; | |
70 else | |
71 arfcn = radio_freq - 125 + 512; | |
72 printf("%d\n", arfcn); | |
73 } |