beautypg.com

Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual

Page 75

background image

74

CHAPTER 7 • SERIAL PORTS

if (ClickBtnPressed())
{
ClickSerialPortTransmit(V1, 18, “Button Pressed V1\n”);
ClickSerialPortTransmit(V2, 18, “Button Pressed V2\n”);
}
}

void Setup1( void )
{
ClickSerialPortDisconnectAll();
ClickSerialPortConnect(V1, _485TOP);
ClickSerialPortConnect(V2, _485TBUS);

ClickSerialPortConfigureVirtual(V1, 9600,
DATABIT_8, PARITY_N);
ClickSerialPortConfigureVirtual(V2, 115200,
DATABIT_8, PARITY_N);
}

void Mode2( void )
{
char string[30];
int bytesReceived;

bytesReceived = ClickSerialPortReceive(V1,29,string);

if (bytesReceived != 0)
{
string[bytesReceived] = 0; // null terminate string
printf(“%s\n”, string);
}
}

void Setup2( void )
{
ClickSerialPortDisconnectAll();
ClickSerialPortConnect(V1, _485TOP);
ClickSerialPortConnect(V1, _485TBUS);
ClickSerialPortConnect(V2, _232TOP);
ClickSerialPortConnect(V2, _232FRONT);