FreeCalypso > hg > fc-pcm-if
diff sw/mcsi-rxtx/tx_func.c @ 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 | f908a782cff9 |
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; +}