I am currently working on a software project on a XMOS platform (Sparkfun XMOS XS1-L1-64). I choose to do my own Makefiles for easier project handling. In my project, I choose to build each software component as a static library for modularity.
One of my modules handles UART communication via 2 ports. Ports are defined as global variables as required by XMOS tools, in my file uart.xc. In my file main.xc the main function is declared, and no ports are defined (not needed and already defined in uart.xc).
When I compile my files together without using a library, all is fine. But if I make uart.xc as a static library (uart.a) I get a strange error message:
Code: Select all
xcc -o test.xe main.o uart.a XC-5.xn
xmap: Error: Symbol "txd" for resolution of resource expression for ".tmpLLNKi26" is undefined.
xmap: Error: Symbol "txr" for resolution of resource expression for ".tmpLLNKi29" is undefined.
uart.xc
Code: Select all
#include <platform.h>
#define BIT_LENGTH XS1_TIMER_HZ/9600 //13MHz / 9600 baud
#define STOP_BIT_LENGTH BIT_LENGTH // One stop bit
out port txd = PORT_UART_TX; // X0D23, TX-O
in port txr = PORT_UART_RX; // X0D24, RX-I
void transmitByte(unsigned byte)
{
unsigned time;
// Start bit
txd <: 0 @ time;
// Data bits
for (int j = 0; j < 8; j += 1)
{
time += BIT_LENGTH;
txd @ time <: >> byte;
}
// Stop bit
time += BIT_LENGTH;
txd @ time <: 1;
time += STOP_BIT_LENGTH;
txd @ time <: 1;
}
void uart(chanend c)
{
unsigned data;
while (1) {
c :> data;
transmitByte(data);
}
}
Code: Select all
#include <xs1.h>
#include <platform.h>
void uart(chanend c);
void testing(chanend c)
{
unsigned data = 0x42;
while (1) {
c <: data;
}
}
int main()
{
chan ch;
par {
on stdcore[0] : testing(ch);
on stdcore[0] : uart(ch);
}
return 0;
}
Code: Select all
xcc -O0 -g -Wall -c -o main.o main.xc XC-5.xn
xcc -O0 -g -Wall -c -o uart.o uart.xc XC-5.xn
xmosar crsv uart.a uart.o
xcc -o test.xe main.o uart.a XC-5.xn
I have no idea why this way of doing is not working. When I declare the ports in main.xc and use extern port in uart.xc, it is also working fine (but not what I want, as I don't want my main.xc file to know about the ports).
Any ideas?
Cheers,
Julien