FreeCalypso > hg > freecalypso-reveng
annotate miscprog/osmo2psi.c @ 367:6dd0fc53bcba
pirelli/battery: battery icon experiments
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 21 Oct 2020 22:40:28 +0000 |
parents | 63c5bb42eca5 |
children |
rev | line source |
---|---|
222
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This test program seeks to help figure out the mapping between OsmocomBB's |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * AFC_SLOPE constant and the Psi constants used by TI's AFC implementation, |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * as our fc-rfcal-vcxo tool would compute them from CMU200 measurements. |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <math.h> |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 main(argc, argv) |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char **argv; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 int afc_slope; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 float lin_a; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 float Psi_sta, Psi_st; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (argc != 2) { |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 fprintf(stderr, "usage: %s osmo-afc-slope\n", argv[0]); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 exit(1); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 afc_slope = atoi(argv[1]); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 lin_a = (float)afc_slope / 32768.0f * 898.0f; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* Psi computations */ |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 Psi_st = Psi_sta * 0.8f; |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 printf("Psi_sta_inv = %u\n", (unsigned)(1.0f / Psi_sta)); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 printf("Psi_st = %u\n", (unsigned)(Psi_st * 65536.0f)); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 printf("Psi_st_32 = %u\n", (unsigned)(Psi_st * 65536.0f * 65536.0f)); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 printf("Psi_st_inv = %u\n", (unsigned)(1.0f / Psi_st)); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 exit(0); |
63c5bb42eca5
osmo2psi test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |