Code: Select all
/*
* Ultranet Receiver.xc
*
* Created on: 11 Aug 2015
* Author: steve
*
* Captures incoming data from I2Ss port and streams it via a channel to a debug process.
*/
#include <stdio.h>
#include <xscope.h>
#include <xs1.h>
#include <platform.h>
#include <timer.h>
#include <xclib.h>
#include "i2s_slave.h"
struct i2s_slave myports =
{
XS1_CLKBLK_1, // Clock Block
XS1_PORT_1H, // J7 pin 2 = BLCK from WM8804
XS1_PORT_1F, // J7 pin 1 = LRCLK from WM8804
{ XS1_PORT_1G }, // J7 pin 3 = DOUT from WM8804
{ XS1_PORT_1I }, // DOUT = dummy port
};
#define NSAMPLES 256
// Display up to n incoming samples, then wait a bit
void display_task(streaming chanend c) {
int v[NSAMPLES], i;
printf("Starting\n");
for(i=0;i<NSAMPLES;i++) {
c:> v[i]; // Receive an integer from the channel
}
//Now dump a block of samples
for(i=0; i<NSAMPLES; i++) {
printf("%08x\n", v[i]);
}
}
// Simulate input to the channel as a sequence of incrementing integers
void gen_task(streaming chanend c) {
int v = 0;
while(1) {
v++;
c<: v; // Output an integer to the channel
//delay_milliseconds(1);
}
}
int main() {
streaming chan c, d;
par {
// Capture input from the i2s interface.
i2s_slave(myports, c, d);
display_task(c);
}
return 0;
}