FreeCalypso > hg > fc-pcm-if
annotate sw/mcsi-rxtx/rx_samples.c @ 16:f422d19c0118 default tip
fc-mcsi-rxtx: fix bug in PCM sample Rx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 29 Oct 2024 01:41:33 +0000 |
parents | 315428573a25 |
children |
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; |
16
f422d19c0118
fc-mcsi-rxtx: fix bug in PCM sample Rx
Mychaela Falconia <falcon@freecalypso.org>
parents:
13
diff
changeset
|
23 sp += 2; |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
13
315428573a25
fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
10
diff
changeset
|
25 record_process(); |
3
de85c3680d7e
sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
10
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
27 |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
28 void |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
29 cmd_print_rx() |
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 unsigned i, j, n; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
32 |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
33 if (!is_active) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
34 printf("Rx is not active\n"); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
35 return; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
36 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
37 n = 0; |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
38 for (i = 0; i < 10; i++) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
39 for (j = 0; j < 16; j++) { |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
40 printf("%04x", rx_pcm_samples[n++]); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
41 if (j == 15) |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
42 putchar('\n'); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
43 else |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
44 putchar(' '); |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
45 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
46 } |
c1d9b5d128f5
fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
47 } |