Tty driver, Runtime configuration – Comtrol eCos User Manual

Page 375

Advertising
background image

Chapter 16. Serial driver details

CYG_IO_SET_CONFIG_SERIAL_WRITE_BLOCKING

Buf type:

cyg_uint32 (values 0 or 1)

Function:

This function will set the blocking-mode for write calls on this device. This call is only available if the
configuration option

CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING

is enabled.

TTY driver

Use the include file

<

cyg/io/ttyio.h

>

for this driver.

This driver is built on top of the simple serial driver and is typically used for a device that interfaces with humans
such as a terminal. It provides some minimal formatting of data on output and allows for line-oriented editing on
input.

Runtime configuration

Runtime configuration is achieved by exchanging data structures with the driver via the

cyg_io_set_config()

and

cyg_io_get_config()

functions.

typedef struct {

cyg_uint32 tty_out_flags;

cyg_uint32 tty_in_flags;

} cyg_tty_info_t;

The field

tty_out_flags

is used to control what happens to data as it is send to the serial port. It contains a

bitmap comprised of the bits as defined by the

CYG_TTY_OUT_FLAGS_xxx

values below.

#define CYG_TTY_OUT_FLAGS_CRLF 0x0001 // Map ’\n’ =

>

’\n\r’ on output

If this bit is set in

tty_out_flags

, any occurrence of the character "\n" will be replaced by the sequence "\n\r"

before being sent to the device.

The field

tty_in_flags

is used to control how data is handled as it comes from the serial port. It contains a

bitmap comprised of the bits as defined by the

CYG_TTY_IN_FLAGS_xxx

values below.

#define CYG_TTY_IN_FLAGS_CR 0x0001 // Map ’\r’ =

>

’\n’ on input

If this bit is set in

tty_in_flags

, the character "\r" (“return” or “enter” on most keyboards) will be mapped to

"\n".

#define CYG_TTY_IN_FLAGS_CRLF 0x0002 // Map ’\n\r’ =

>

’\n’ on input

271

Advertising