changeset 12:23555b9a1c20

fc-mcsi-rxtx: implement pcm-fill command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 06:52:33 +0000
parents e93a11f44e6f
children 315428573a25
files sw/mcsi-rxtx/tx_func.c sw/mcsi-rxtx/usercmd.c
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sw/mcsi-rxtx/tx_func.c	Mon Oct 28 06:34:42 2024 +0000
+++ b/sw/mcsi-rxtx/tx_func.c	Mon Oct 28 06:52:33 2024 +0000
@@ -4,6 +4,7 @@
  */
 
 #include <sys/types.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -46,3 +47,26 @@
 	do_idle_fill(tx_samples);
 	emit_uart_output(tx_samples);
 }
+
+void
+cmd_pcm_fill(argc, argv)
+	char **argv;
+{
+	u_long val;
+	char *endp;
+
+	if (argc < 2) {
+		printf("%04x\n", pcm_fill_word);
+		return;
+	}
+	if (!isxdigit(argv[1][0])) {
+inv:		printf("error: pcm-fill argument is not a valid hex word\n");
+		return;
+	}
+	val = strtoul(argv[1], &endp, 16);
+	if (*endp)
+		goto inv;
+	if (val > 0xFFFF)
+		goto inv;
+	pcm_fill_word = val;
+}
--- a/sw/mcsi-rxtx/usercmd.c	Mon Oct 28 06:34:42 2024 +0000
+++ b/sw/mcsi-rxtx/usercmd.c	Mon Oct 28 06:52:33 2024 +0000
@@ -11,6 +11,7 @@
 
 extern char usercmd[];
 
+extern void cmd_pcm_fill();
 extern void cmd_print_rx();
 
 static void
@@ -27,6 +28,7 @@
 	void (*func)();
 } cmdtab[] = {
 	{"exit", 0, 0, cmd_exit},
+	{"pcm-fill", 0, 1, cmd_pcm_fill},
 	{"print-rx", 0, 0, cmd_print_rx},
 	{"quit", 0, 0, cmd_exit},
 	{0, 0, 0, 0}