Beispiel #1
0
u2_t ctrl_get()
{
	static SPI_MISO ctrl;
	
	spi_get_noduplex(CmdCtrlGet, &ctrl, sizeof(ctrl.word[0]));
	return ctrl.word[0];
}
Beispiel #2
0
u2_t getmem(u2_t addr)
{
	SPI_MISO mem;
	
	spi_get_noduplex(CmdGetMem, &mem, 4, addr);
	assert(addr == mem.word[1]);
	
	return mem.word[0];
}
Beispiel #3
0
u2_t getmem(u2_t addr)
{
	static SPI_MISO mem;
	
	memset(mem.word, 0x55, sizeof(mem.word));
	spi_get_noduplex(CmdGetMem, &mem, 4, addr);
	assert(addr == mem.word[1]);
	
	return mem.word[0];
}
Beispiel #4
0
float ecpu_use()
{
	typedef struct {
		u1_t f0, g0, f1, g1, f2, g2, f3, g3;
	} ctr_t;
	ctr_t *c;
	SPI_MISO cpu;
	
	if (down || do_fft) return 0;
	spi_get_noduplex(CmdGetCPUCtr, &cpu, sizeof(u2_t[3]));
	c = (ctr_t*) &cpu.word[0];
	u4_t gate = (c->g3 << 24) | (c->g2 << 16) | (c->g1 << 8) | c->g0;
	u4_t free = (c->f3 << 24) | (c->f2 << 16) | (c->f1 << 8) | c->f0;
	spi_set_noduplex(CmdCPUCtrClr);
	return ((float) gate / (float) free * 100);
}
Beispiel #5
0
static void snd_service()
{
	int j;
	
	SPI_MISO *miso = &dp_miso;

	rx_data_t *rxd = (rx_data_t *) &miso->word[0];

	#ifdef SND_SEQ_CHECK
	rxd->magic = 0;
	#endif
	
	// use noduplex here because we don't want to yield
	evDPC(EC_TRIG3, EV_DPUMP, -1, "snd_svc", "CmdGetRX..");
	spi_get_noduplex(CmdGetRX, miso, sizeof(rx_data_t));
	evDPC(EC_EVENT, EV_DPUMP, -1, "snd_svc", "..CmdGetRX");

	evDP(EC_TRIG2, EV_DPUMP, -1, "snd_service", evprintf("SERVICED SEQ %d %%%%%%%%%%%%%%%%%%%%",
		rxd->seq));
	//evDP(EC_TRIG2, EV_DPUMP, 15000, "SND", "SERVICED ----------------------------------------");
	
	#ifdef SND_SEQ_CHECK
	if (rxd->magic != 0x0ff0) {
		evDPC(EC_EVENT, EV_DPUMP, -1, "DATAPUMP", evprintf("BAD MAGIC 0x%04x", rxd->magic));
		if (ev_dump) evDP(EC_DUMP, EV_DPUMP, ev_dump, "DATAPUMP", evprintf("DUMP in %.3f sec", ev_dump/1000.0));
	}
	
	if (!initial_seq) {
		seq = rxd->seq;
		initial_seq = true;
	}
	u2_t new_seq = rxd->seq;
	if (seq != new_seq) {
		//printf("$dp %d:%d(%d)\n", seq, new_seq, new_seq-seq);
		evDPC(EC_EVENT, EV_DPUMP, -1, "SEQ DROP", evprintf("$dp %d:%d(%d)", seq, new_seq, new_seq-seq));
		audio_dropped++;
		//TaskLastRun();
		bool dump = false;
		//bool dump = true;
		//bool dump = (new_seq-seq < 0);
		//bool dump = (audio_dropped == 6);
		if (dump && ev_dump) evNT(EC_DUMP, EV_NEXTTASK, ev_dump, "NextTask", evprintf("DUMP IN %.3f SEC",
			ev_dump/1000.0));
		seq = new_seq;
	}
	seq++;
	#endif

	TYPECPX *i_samps[RX_CHANS];
	for (j=0; j < RX_CHANS; j++) {
		rx_dpump_t *rx = &rx_dpump[j];
		i_samps[j] = rx->in_samps[rx->wr_pos];
	}

	rx_iq_t *iqp = (rx_iq_t*) &rxd->iq_t;

	for (j=0; j<NRX_SAMPS; j++) {

		for (int ch=0; ch < RX_CHANS; ch++) {
			if (rx_chan[ch].enabled) {
				s4_t i, q;
				i = S24_8_16(iqp->i3, iqp->i);
				q = S24_8_16(iqp->q3, iqp->q);
				
				// NB: i&q reversed to get correct sideband polarity; fixme: why?
				// [probably because mixer NCO polarity is wrong, i.e. cos/sin should really be cos/-sin]
				i_samps[ch]->re = q * rescale;
				i_samps[ch]->im = i * rescale;
				i_samps[ch]++;
			}
			iqp++;
		}
	}

	for (int ch=0; ch < RX_CHANS; ch++) {
		if (rx_chan[ch].enabled) {
			rx_dpump_t *rx = &rx_dpump[ch];
			rx->wr_pos = (rx->wr_pos+1) & (N_DPBUF-1);
		}
	}
}