FreeCalypso > hg > fc-pcm-if
changeset 11:e93a11f44e6f
fc-mcsi-rxtx: implement basic Tx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2024 06:34:42 +0000 |
parents | c1d9b5d128f5 |
children | 23555b9a1c20 |
files | sw/mcsi-rxtx/Makefile sw/mcsi-rxtx/mainloop.c sw/mcsi-rxtx/tx_func.c |
diffstat | 3 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sw/mcsi-rxtx/Makefile Mon Oct 28 06:11:23 2024 +0000 +++ b/sw/mcsi-rxtx/Makefile Mon Oct 28 06:34:42 2024 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 PROG= fc-mcsi-rxtx -OBJS= main.o mainloop.o rx_samples.o ttymagic.o usercmd.o +OBJS= main.o mainloop.o rx_samples.o ttymagic.o tx_func.o usercmd.o LIBS= ../libserial/libserial.a INSTALL_PREFIX= /opt/freecalypso
--- a/sw/mcsi-rxtx/mainloop.c Mon Oct 28 06:11:23 2024 +0000 +++ b/sw/mcsi-rxtx/mainloop.c Mon Oct 28 06:34:42 2024 +0000 @@ -71,6 +71,7 @@ if (off >= sizeof(buf)) { process_rx_block(buf); off = 0; + transmit_20ms_block(); } } fflush(stdout);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sw/mcsi-rxtx/tx_func.c Mon Oct 28 06:34:42 2024 +0000 @@ -0,0 +1,48 @@ +/* + * Here we implement basic Tx functions: emitting an uplink sample stream + * to Calypso MCSI via the FPGA. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +extern int target_fd; + +u_short pcm_fill_word; + +static void +do_idle_fill(buf) + u_short *buf; +{ + unsigned n; + + for (n = 0; n < 160; n++) + buf[n] = pcm_fill_word; +} + +static void +emit_uart_output(samples) + u_short *samples; +{ + u_char bytes[320], *dp; + unsigned n, samp; + + dp = bytes; + for (n = 0; n < 160; n++) { + samp = samples[n]; + *dp++ = samp; + *dp++ = samp >> 8; + } + write(target_fd, bytes, 320); +} + +void +transmit_20ms_block() +{ + u_short tx_samples[160]; + + do_idle_fill(tx_samples); + emit_uart_output(tx_samples); +}