FreeCalypso > hg > fc-pcm-if
annotate sw/mcsi-rxtx/rx_samples.c @ 10:c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2024 06:11:23 +0000 |
parents | 62579cfff4fc |
children | 315428573a25 |
rev | line source |
---|---|
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
7
8a386263dd51
fc-mcsi-rxtx skeleton put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
2 * In this module we handle PCM samples received from MCSI via the FPGA. |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
9
62579cfff4fc
fc-mcsi-rxtx: more proper integration with ttyhacks
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
8 extern int is_active; |
62579cfff4fc
fc-mcsi-rxtx: more proper integration with ttyhacks
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
9 |
7
8a386263dd51
fc-mcsi-rxtx skeleton put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
10 u_short rx_pcm_samples[160]; |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
9
62579cfff4fc
fc-mcsi-rxtx: more proper integration with ttyhacks
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
12 void |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 process_rx_block(buf) |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char *buf; |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
7
8a386263dd51
fc-mcsi-rxtx skeleton put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
16 unsigned n, samp; |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 u_char *sp; |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 sp = buf; |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 for (n = 0; n < 160; n++) { |
7
8a386263dd51
fc-mcsi-rxtx skeleton put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
21 samp = ((unsigned) sp[1] << 8) | ((unsigned) sp[0]); |
8a386263dd51
fc-mcsi-rxtx skeleton put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
22 rx_pcm_samples[n] = samp; |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
10
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
25 |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
26 void |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
27 cmd_print_rx() |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
28 { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
29 unsigned i, j, n; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
30 |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
31 if (!is_active) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
32 printf("Rx is not active\n"); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
33 return; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
34 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
35 n = 0; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
36 for (i = 0; i < 10; i++) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
37 for (j = 0; j < 16; j++) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
38 printf("%04x", rx_pcm_samples[n++]); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
39 if (j == 15) |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
40 putchar('\n'); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
41 else |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
42 putchar(' '); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
43 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
44 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
45 } |