Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add S/PDIF RX/TX via 4-bit XCORE-200 port #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion app_example_rx/src/main.xc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "SpdifReceive.h"

buffered in port:4 oneBitPort = XS1_PORT_1F;
buffered in port:32 fourBitsPort = XS1_PORT_4D;
clock clockblock = XS1_CLKBLK_1;
//::

Expand All @@ -30,7 +31,10 @@ void handleSamples(streaming chanend c) {
int main(void) {
streaming chan c;
par {
SpdifReceive(oneBitPort, c, 1, clockblock);
//------ Use one of these functions -------
SpdifReceive(oneBitPort, c, 1, clockblock);
//SpdifReceive_port4_buf32(fourBitsPort, c, 1, clockblock);
//-----------------------------------------
handleSamples(c);
}
return 0;
Expand Down
14 changes: 13 additions & 1 deletion app_example_tx/src/main.xc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#include <xs1.h>
#include <platform.h>
#include "SpdifTransmit.h"
#include "SpdifTransmit_4bitPort.h"

#define SAMPLE_FREQUENCY_HZ 96000
#define MASTER_CLOCK_FREQUENCY_HZ 12288000

on stdcore[1] : buffered out port:32 oneBitPort = XS1_PORT_1K;
on stdcore[1] : buffered out port:32 fourBitsPort = XS1_PORT_4D;
on stdcore[1] : in port masterClockPort = XS1_PORT_1L;
on stdcore[1] : clock clockblock = XS1_CLKBLK_1;
//::
Expand Down Expand Up @@ -106,6 +108,13 @@ void transmitSpdif(chanend c) {
}
//::

//::spdif thread 2
void transmitSpdif_4bitPort(chanend c) {
SpdifTransmitPortConfig_4bitPort(fourBitsPort, clockblock, masterClockPort);
SpdifTransmit_4bitPort(fourBitsPort, c);
}
//::

//::data generation
#define WAVE_LEN 512
void generate(chanend c) {
Expand Down Expand Up @@ -139,7 +148,10 @@ void example(void) {
chan c;
setupPll();
par {
transmitSpdif(c);
//------- Use one of these functions -------
transmitSpdif(c);
//transmitSpdif_4bitPort(c);
//------------------------------------------
generate(c);
clockGen();
}
Expand Down
4 changes: 2 additions & 2 deletions module_spdif_rx/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module_spdif_tx
module_spdif_rx
================

:scope: General Use
:description: S/PDIF transmit module
:description: S/PDIF receive module
16 changes: 16 additions & 0 deletions module_spdif_rx/src/SpdifReceive.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,20 @@
**/
void SpdifReceive(in buffered port:4 p, streaming chanend c, int initial_divider, clock clk);


/**
* \param p S/PDIF input 4-bit port. This port must be 32-bit buffered,
* declared as ``in buffered port:32``
*
* \param c channel to output samples to
*
* \param initial_divider initial divide for initial estimate of sample rate
* For a 100Mhz reference clock, use an initial divider
* of 1 for 192000, 2 for 96000/88200, and 4 for 48000/44100.
*
* \param clk clock block sourced from the 100 MHz reference clock.
*
**/
void SpdifReceive_port4_buf32(in buffered port:32 p, streaming chanend c, int initial_divider, clock clk);

#endif // _SpdifReceive_h_