# HG changeset patch # User Mychaela Falconia # Date 1730097282 0 # Node ID e93a11f44e6f9d5a29272d66161a72cb3ddab675 # Parent c1d9b5d128f5b34117ed65d16691f2308c97bd47 fc-mcsi-rxtx: implement basic Tx diff -r c1d9b5d128f5 -r e93a11f44e6f sw/mcsi-rxtx/Makefile --- 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 diff -r c1d9b5d128f5 -r e93a11f44e6f sw/mcsi-rxtx/mainloop.c --- 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); diff -r c1d9b5d128f5 -r e93a11f44e6f sw/mcsi-rxtx/tx_func.c --- /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 +#include +#include +#include + +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); +}