Hi...
Trying to set up a test application using two XK-1A's. I want to use a "service" to represent the link I will later try to initialize in code. I do NOT want to have the SPI's programmed as a multi-tile boot. I want to program each SPI separately and then connect the XK-1A's later. (There is a method to my madness, and no, I do not make hats).
I used the noinit flag mentioned in this post thread to get my code to run up to the point it actually tries to access the "service" channel. Both the master and the slave correctly compile and run, and on the first attempt to either read or write to the "service" channel, an ET_ILLEGAL_RESOURCE exception (correctly) gets thrown. WHAT I NEED IS A SEQUENCE OF CALLS IN XC TO SAY "HELLO" TO THE L1 THAT WILL LATER BE CONNECTED, AND WAIT FOR A VALID CONNECTION OF THE LINKS. Since I am using the XK-1A's they are X0LC(slave) and X0LD(master). Whatever code is used should properly set up these channels. Can someone help me fill in the "BLANKS"?
My end product is combining several camera streams (up to 4) on an L1-128QFP and sending it to an SU1 and then to the USB 2.0 line. That application will have a 5 wire link, the L1-128 using X0LD, and the SU1 using X0LC. I already have the board printed and will assemble it, but I am trying to get my code ready this weekend...
Here is my slave code:
Code: Select all
#include <xs1.h>
#include <print.h>
#include <platform.h>
port leds0 = PORT_LED_1;
long nMillionSlave = 4000000 ;
void flashLEDSlave(port leds, streaming chanend c)
{
long a ;
long i ;
// We need to initialize the link before attempting to read.
// We will do this by using read_sswitch_reg and write_sswitch_reg
printstr("Hello! Entering flashLEDSlave\n");
// Do some initialization of the links here:
// HELP ME HERE! I NEED SOME READ_SSWITCH_REG AND WRITE_SSWITCH_REG
// CALLS HERE
// BLANKS
// Check that the link really works...
printstr("Try to read first byte\n");
c :> a ;
printstr("O.K. That's done\n");
while(1)
{
// Loop and calculate the
for (i=0; i<4000000; i++)
c :> a ;
c :> a ;
c :> a ;
leds <: a ;
}
}
int main(void)
{
streaming chan c ;
par
{
//flashLEDSlave(leds0, c);
on stdcore[0]: flashLEDSlave(leds0, c);
waffleBaker(c) ;
}
return 0 ;
}
Here's my slave XN file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Board</Type>
<Name>XK-1A Development Board</Name>
<BoardId>0005021X</BoardId>
<Declarations>
<Declaration>tileref tile[1]</Declaration>
</Declarations>
<Packages>
<Package id="P1" Type="XS1-L1A-TQ128">
<Nodes>
<Node Id="Slave" InPackageId="0" Type="XS1-L1A" Oscillator="20MHz" SystemFrequency="400MHz" ReferenceFrequency="100MHz">
<Boot>
<Source Location="SPI:bootFlash1"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<Port Location="XS1_PORT_1M" Name="PORT_SPI_MISO1"/>
<Port Location="XS1_PORT_1N" Name="PORT_SPI_SS1"/>
<Port Location="XS1_PORT_1O" Name="PORT_SPI_CLK1"/>
<Port Location="XS1_PORT_1P" Name="PORT_SPI_MOSI1"/>
<Port Location="XS1_PORT_4F" Name="PORT_LED_1"/>
</Tile>
</Node>
<Node Id="1" Type="device:waffle_iron">
<Service Id="0" Proto="waffleBaker(streaming chanend cIn )">
<Chanend identifier="cIn" end="0:0:6" remote="0:1:0"/>
</Service>
</Node>
</Nodes>
</Package>
</Packages>
<Links>
<Link Encoding="2wire" Delays="0,1" Flags="noinit">
<LinkEndpoint NodeId="Slave" Link="X0LC"/>
<LinkEndpoint NodeId="1" Link="X0LD"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="Slave" Tile="0" Class="SPIFlash" Name="bootFlash1" Type="AT25FS010">
<Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO1"/>
<Attribute Name="PORT_SPI_SS" Value="PORT_SPI_SS1"/>
<Attribute Name="PORT_SPI_CLK" Value="PORT_SPI_CLK1"/>
<Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI1"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="Slave" Position="0"/>
</JTAGChain>
</Network>
Here is my master code:
Code: Select all
#include <xs1.h>
#include <print.h>
#include <platform.h>
port leds0 = PORT_LED_0;
long nMillionMaster = 4000000 ;
void flashLEDMaster(port leds, streaming chanend c)
{
long a ;
long i ;
// We need to initialize the link before attempting to read.
// We will do this by using read_sswitch_reg and write_sswitch_reg
printstr("Hello! Entering flashLEDMaster\n");
// Do some initialization of the links here:
// HELP ME HERE! I NEED SOME READ_SSWITCH_REG AND WRITE_SSWITCH_REG
// CALLS HERE. DON'T START SENDING UNTIL WE HAVE A VALID LINK.
// BLANKS
// Check that the link really works...
printstr("Try to write first byte\n");
c <: a ;
printstr("O.K. That's done\n");
while(1)
{
a = 1 ;
for (i=0; i<4000000; i++)
c <: i ;
c <: 1 ;
leds <: a ;
a = 0 ;
for (i=0; i<4000000; i++)
c <: i ;
c <: 0 ;
leds <: a ;
}
}
int main(void)
{
streaming chan c ;
par
{
on stdcore[0]: flashLEDMaster(leds0, c);
waffleBaker(c) ;
}
return 0 ;
}
Here is my master XN:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Board</Type>
<Name>XK-1A Development Board</Name>
<BoardId>0005021X</BoardId>
<Declarations>
<Declaration>tileref tile[1]</Declaration>
</Declarations>
<Packages>
<Package id="P0" Type="XS1-L1A-TQ128">
<Nodes>
<Node Id="Master" InPackageId="0" Type="XS1-L1A" Oscillator="20MHz" SystemFrequency="400MHz" ReferenceFrequency="100MHz">
<Boot>
<Source Location="SPI:bootFlash0"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<Port Location="XS1_PORT_1M" Name="PORT_SPI_MISO0"/>
<Port Location="XS1_PORT_1N" Name="PORT_SPI_SS0"/>
<Port Location="XS1_PORT_1O" Name="PORT_SPI_CLK0"/>
<Port Location="XS1_PORT_1P" Name="PORT_SPI_MOSI0"/>
<Port Location="XS1_PORT_4F" Name="PORT_LED_0"/>
</Tile>
</Node>
<Node Id="1" Type="device:waffle_iron">
<Service Id="0" Proto="waffleBaker(streaming chanend cIn )">
<Chanend identifier="cIn" end="0:0:6" remote="0:1:0"/>
</Service>
</Node>
</Nodes>
</Package>
</Packages>
<Links>
<Link Encoding="2wire" Delays="0,1" Flags="noinit">
<LinkEndpoint NodeId="Master" Link="X0LD"/>
<LinkEndpoint NodeId="1" Link="X0LC"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="Master" Tile="0" Class="SPIFlash" Name="bootFlash0" Type="AT25FS010">
<Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO0"/>
<Attribute Name="PORT_SPI_SS" Value="PORT_SPI_SS0"/>
<Attribute Name="PORT_SPI_CLK" Value="PORT_SPI_CLK0"/>
<Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI0"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="Master" Position="0"/>
</JTAGChain>
</Network>