Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 89

Advertising
background image

KTD-S0057-I

Page 85 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


int rts_transmit_control (int tx_enable)
{

char dev [64];

char str [16];

sprintf (dev, dev_val, GP2_3);

sprintf (str, "%d", tx_enable);

if (update_device (dev, str, TRUE))

return

-1;

return

0;

}


int init_uart_interface (int baudrate)
{
struct

termios

new_values;

fd = open (device, O_RDWR | O_NOCTTY);

if (fd < 0 )

return

-1;

if (tcflush (fd, TCIOFLUSH))

return

-1;

switch

(baudrate)

{

case 300

: baudrate = B300; break;

case 600

: baudrate = B600; break;

case 1200

: baudrate = B1200; break;

case 2400

: baudrate = B2400; break;

case 4800

: baudrate = B4800; break;

case 9600

: baudrate = B9600; break;

case 19200

: baudrate = B19200; break;

case 38400

: baudrate = B38400; break;

case 57600

: baudrate = B57600; break;

case 115200 : baudrate = B115200; break;

default

: return -1;

}

memset (&new_values, 0, sizeof (new_values));

new_values.c_cflag = CS8 | CLOCAL | CREAD;

new_values.c_iflag = IGNBRK | ICRNL;

new_values.c_lflag = ICANON;

new_values.c_cc[VMIN] = 1;

if (cfsetispeed (&new_values, baudrate))

return

-1;

if (cfsetospeed (&new_values, baudrate))

return

-1;

return tcsetattr (fd, TCSANOW, &new_values);

}

Advertising
This manual is related to the following products: