comparison 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
comparison
equal deleted inserted replaced
10:c1d9b5d128f5 11:e93a11f44e6f
1 /*
2 * Here we implement basic Tx functions: emitting an uplink sample stream
3 * to Calypso MCSI via the FPGA.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10
11 extern int target_fd;
12
13 u_short pcm_fill_word;
14
15 static void
16 do_idle_fill(buf)
17 u_short *buf;
18 {
19 unsigned n;
20
21 for (n = 0; n < 160; n++)
22 buf[n] = pcm_fill_word;
23 }
24
25 static void
26 emit_uart_output(samples)
27 u_short *samples;
28 {
29 u_char bytes[320], *dp;
30 unsigned n, samp;
31
32 dp = bytes;
33 for (n = 0; n < 160; n++) {
34 samp = samples[n];
35 *dp++ = samp;
36 *dp++ = samp >> 8;
37 }
38 write(target_fd, bytes, 320);
39 }
40
41 void
42 transmit_20ms_block()
43 {
44 u_short tx_samples[160];
45
46 do_idle_fill(tx_samples);
47 emit_uart_output(tx_samples);
48 }