Hi
I have a problem with the UART/serial interface and the simulator.
I have the forlowing code in a file called MyUart.c:
//includes
#include "config.h"
//Prototypes
void setUart(unsigned char mode);
// Global variables
static QUEUE_HANDLE SerialPortID; // quehandler for serialport 0
//call functions
void fnSerialTest(TTASKTABLE *ptrTaskTable) // my task task in polling mode (at the moment)
{
static int iState = 0;
if (iState== 0)
{
setUart(FOR_I_O); //Rx & Tx
iState = 1;
}
fnWrite(SerialPortID, (unsigned char *)"Hello world", uStrlen("Hello world"));
}
void setUart(unsigned char mode)
{
TTYTABLE tInterfaceParameters; //table for passing information to driver
tInterfaceParameters.Channel = 0; // serial 0, 1, 2, 3, 4, etc.
tInterfaceParameters.ucSpeed = SERIAL_BAUD_19200; // baud rate
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE; // outpu buffer size
tInterfaceParameters.Task_to_wake = TASK_MYUART;
tInterfaceParameters.usConfig = (CHAR_8 | NO_PARITY | ONE_STOP | NO_HANDSHAKE | CHAR_MODE);
if ( (SerialPortID = fnOpen(TYPE_TTY, mode, &tInterfaceParameters)) != 0 ) // open or change the channel with defined configurations (initially inactive)
fnDriver( SerialPortID, (RX_ON | TX_ON), 0 ); // enable RX & TX
}
In TaskConfig.h I have the forlowing entrys:
#define TASK_MYUART 'u'
...
extern void fnSerialTest(TTASKTABLE *ptrTaskTable);
...
TASK_MYUART, //ctNodes
...
{ "uart", fnSerialTest, NO_QUE, 0, 0, UTASKER_GO}, //ctTaskTable
and in app_hw_m5223x.h:
#define SERIAL_PORT_0 '1'
This is correct since I use channel zero and com1 for communication.
The problem is that nothing is written to com1 using the simulator.
When i debug in MyUart.c at:
if ( (SerialPortID = fnOpen(TYPE_TTY, mode, &tInterfaceParameters)) != 0 )
fnOpen() doesn't return to this line. Instad it returns to
if ((SerialPortID = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParameters )) != 0)
in application.c.
I am using uTasker sp6.
ZeroOne