Here is my error message :
Code: Select all
xrun: Program received signal ET_ECALL, Application exception.
[Switching to stdcore[0] hwthread 2]
Code: Select all
///////////////////////////////////////////////////////////////////////////////////
//
// File : uart.xc
//
// Sypnosis : Communication between xmos, arduino and gps.
//
///////////////////////////////////////////////////////////////////////////////////
#include <xs1.h>
#include <platform.h>
#include "uart_tx.h"
#include "uart_rx.h"
#include "ports.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
// uart communication function
void forward(chanend arduinoRX, chanend loggerTX, chanend gpsRX);
#define BUFF_SIZE 640
//baud rates
#define BAUD_9600 9600
#define BAUD_115200 115200
///////////////////////////////////////////////////////////////////////////////////
//
// Name : main
//
// Sypnosis : main function
//
// Parameters : None
//
// Returns : ErrorCode
//
///////////////////////////////////////////////////////////////////////////////////
#pragma unsafe arrays
int main()
{
chan arduinoRX, dntTX, gpsRX;
par
{
// Set UART context
on stdcore[0] :
{
unsigned char dnt_tx_buffer[BUFF_SIZE];
unsigned char arduino_rx_buffer[BUFF_SIZE];
unsigned char gps_rx_buffer[BUFF_SIZE];
tx_dnt <: 1;
par
{
uart_rx(rx_gps, gps_rx_buffer, ARRAY_SIZE(gps_rx_buffer), BAUD_115200, 8, UART_TX_PARITY_NONE, 1, gpsRX);
uart_rx(rx_arduino, arduino_rx_buffer, ARRAY_SIZE(arduino_rx_buffer), BAUD_115200, 8, UART_TX_PARITY_NONE, 1, arduinoRX);
uart_tx(tx_dnt, dnt_tx_buffer, ARRAY_SIZE(dnt_tx_buffer), BAUD_115200, 8, UART_TX_PARITY_NONE, 1, dntTX);
}
}
// UART communication
on stdcore[0] :
{
forward(arduinoRX, dntTX, gpsRX);
}
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////
//
// Name : forward
//
// Sypnosis : UART communication between xmos, arduino and logger
//
// Parameters : chanend arduinoTX, chanend arduinoRX, chanend loggerTX
//
// Returns : Nothing
//
///////////////////////////////////////////////////////////////////////////////////
void forward(chanend arduinoRX, chanend dntTX, chanend gpsRX)
{
uart_rx_client_state rxStateArduino;
uart_rx_client_state rxStateGPS;
unsigned char receivedByteArduino;
unsigned char receivedByteGPS;
uart_rx_init(arduinoRX, rxStateArduino);
uart_rx_init(gpsRX, rxStateGPS);
while(1)
{
receivedByteArduino = uart_rx_get_byte(arduinoRX, rxStateArduino);
uart_tx_send_byte(dntTX, receivedByteArduino);
receivedByteGPS = uart_rx_get_byte(gpsRX, rxStateGPS);
uart_tx_send_byte(dntTX, receivedByteGPS);
}
}