view sw/mcsi-rxtx/rx_samples.c @ 16:f422d19c0118 default tip

fc-mcsi-rxtx: fix bug in PCM sample Rx
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Oct 2024 01:41:33 +0000
parents 315428573a25
children
line wrap: on
line source

/*
 * In this module we handle PCM samples received from MCSI via the FPGA.
 */

#include <sys/types.h>
#include <stdio.h>

extern int is_active;

u_short rx_pcm_samples[160];

void
process_rx_block(buf)
	u_char *buf;
{
	unsigned n, samp;
	u_char *sp;

	sp = buf;
	for (n = 0; n < 160; n++) {
		samp = ((unsigned) sp[1] << 8) | ((unsigned) sp[0]);
		rx_pcm_samples[n] = samp;
		sp += 2;
	}
	record_process();
}

void
cmd_print_rx()
{
	unsigned i, j, n;

	if (!is_active) {
		printf("Rx is not active\n");
		return;
	}
	n = 0;
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 16; j++) {
			printf("%04x", rx_pcm_samples[n++]);
			if (j == 15)
				putchar('\n');
			else
				putchar(' ');
		}
	}
}