annotate sw/mcsi-rxtx/rx_samples.c @ 13:315428573a25

fc-mcsi-rxtx: implement record function
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 07:24:53 +0000
parents c1d9b5d128f5
children f422d19c0118
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }
13
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
24 record_process();
3
de85c3680d7e sw: fc-mcsi-rx program put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
10
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
26
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
27 void
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
28 cmd_print_rx()
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
29 {
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
30 unsigned i, j, n;
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
31
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
32 if (!is_active) {
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
33 printf("Rx is not active\n");
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
34 return;
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
35 }
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
36 n = 0;
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
37 for (i = 0; i < 10; i++) {
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
38 for (j = 0; j < 16; j++) {
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
39 printf("%04x", rx_pcm_samples[n++]);
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
40 if (j == 15)
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
41 putchar('\n');
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
42 else
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
43 putchar(' ');
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 }
c1d9b5d128f5 fc-mcsi-rxtx: implement print-rx command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
46 }