annotate sw/mcsi-rxtx/tx_func.c @ 11:e93a11f44e6f

fc-mcsi-rxtx: implement basic Tx
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 06:34:42 +0000
parents
children 23555b9a1c20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement basic Tx functions: emitting an uplink sample stream
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * to Calypso MCSI via the FPGA.
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern int target_fd;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_short pcm_fill_word;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static void
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 do_idle_fill(buf)
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 u_short *buf;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 unsigned n;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 for (n = 0; n < 160; n++)
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 buf[n] = pcm_fill_word;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 static void
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 emit_uart_output(samples)
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 u_short *samples;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 u_char bytes[320], *dp;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 unsigned n, samp;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 dp = bytes;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 for (n = 0; n < 160; n++) {
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 samp = samples[n];
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 *dp++ = samp;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 *dp++ = samp >> 8;
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 write(target_fd, bytes, 320);
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 void
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 transmit_20ms_block()
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 {
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 u_short tx_samples[160];
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 do_idle_fill(tx_samples);
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 emit_uart_output(tx_samples);
e93a11f44e6f fc-mcsi-rxtx: implement basic Tx
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }