So, here is my setup:
On the one side there's the windows host, which is the master of the bus and the software to use TBL-Library is written in C#.
The other side is the Atxmega128A1 Board, which is the Slave with Address 10 (0xA).
The two of them are connected via USB-RS485-Converter Cable from FTDI (see http://www.ftdichip.com/Products/Cables/USBRS485.htm)
To verify communication I simply pinged the slave, because there's no additional coding needed, this command is already implemented in Master and Slave implementation and even measures the roundtrip time.
Here's the result:
To get an idea of how simple the use of this system is, here's all the source code needed to get the 3 parts working:
Complete Master Implementation Code on PC (C#)
using System;
using TBL.Communication;
using TBL.EDOLL;
namespace bac1_hardwareController
{
class Program
{
public static void Main(string[] args)
{
DevComMaster master = new DevComMaster(new devComSerialInterface("COM17"));
int err;
if(!master.Connect(out err))
{
stdOut.Error(EDOLLHandler.Verbalize(err));
Environment.Exit(err);
}
long rtt;
if(!master.Ping(10, out rtt, out err))
{
stdOut.Error(EDOLLHandler.Verbalize(err));
}
else
{
stdOut.Info("Pinged with " + rtt + "ms ping");
}
// TODO: Implement Functionality Here
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Complete Slave implementation Code on ATxmega128A1
int main()
{
system_clocks_init();
DevComSlave_t* dc = dcs_create(SLAVE_ADDRESS);
// R/W Line of RS485 buscoupler
dc->RWPort = ((uint8_t*)(&(PORTD.OUT)));
dc->RW_bp = PIN5_bp;
dcs_start(UARTD1, dc, F_CPU, 500000); // Start @ UART0 with 500kbits
while(1)
{
if(dc->NewReceived & DCS_REC_DATA_gm)
{
// Do something, access Data ranging from dc.Data[0] .. dc.Data[dc.DataUpperBound]
dc->NewReceived &= ~(DCS_REC_DATA_gm); // Reset Flags
}
}
}
That's all... quite simple, uh?
Next steps:
- Working on the Projects website, pre-releases of the library upon request
- Testing the library extensively on AtXmega and after testing include the XMega support to the library