I have an XC-3 sitting on my bench running a slightly modified version of the stock LED display tile driver firmware.
I wanted to add some further functionality to the network side of things but I am truly lost as to how I should go about it.
Before we get going I will say that I spent some time reading the XC-3 source code and trawling through the Ethernet documentation. Alas - I am none the wiser as to how the thing is really working. In fact - I'm not sure if the sc_ethernet stuff applies to the XC-3. For one - the XC-3 is not mentioned in the hardware notes. Further - I can't find some of the most basic sc_ethernet components for example ethernet_conf.h is nowhere to be found...
In the first instance, I want to take a single byte of data (let's say ASCII "X") and destination IP/port and release it on to the network as a UDP packet.
I was somewhat hoping there would be a nice method I could use for this e.g.
Code: Select all
byte[] send_buffer = Encoding.ASCII.GetBytes("X");
UDPClient.senddata(send_buffer,IP,Port);
Ultimately want to send packets on a button press event.
For demo purposes I knocked up this:
Code: Select all
in port button = XS1_PORT_4E;
out port LED = XS1_PORT_4F;
int main(void) {
int x;
while (1) {
button :> x;
if (x == 8)
LED <: 2;
else
LED <: 1;
}
return 0;
}
Code: Select all
in port button = XS1_PORT_4E;
out port LED = XS1_PORT_4F;
#define DELAY 5000000 //half a second at 100MHz
int main(void) {
int x;
unsigned state = 1, time;
timer t;
t :> time;
while (1) {
time += DELAY;
t when timerafter(time) :> void;
state = !state;
if (state == 1)
button :> x;
if (x == 8) //Button pressed
//Generate UDP packet (content,destination,port)
//Insert packet into ethernet output buffer
else
//Do nothing
}
return 0;
}
Now I understand that I'll probably have to write the helper functions to generate my packets and so on but I have no idea where to start.
Further - my little routine (above) is all good and well as a standalone piece of code, but the XC-3 firmware is already a complex ecosystem of interrelated functions. Where would you advise this code is run (i.e. which core).
Any advice much appreciated,
Best
D