Code Confidencebuild 3.0.0.201402161939

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' => '\r\n' on output

If this bit is set in tty_out_flags, any occurrence of the character "\n" will be replaced by the sequence "\r\n" 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 '\r\n' => '\n' on input

If this bit is set in tty_in_flags, the character sequence "\r\n" (often sent by DOS/Windows based terminals) will be mapped to "\n".

#define CYG_TTY_IN_FLAGS_ECHO 0x0004 // Echo characters as processed

If this bit is set in tty_in_flags, characters will be echoed back to the serial port as they are processed.

#define CYG_TTY_IN_FLAGS_BINARY 0x0008 // No input processing

If this bit is set in tty_in_flags, the input will not be manipulated in any way before being placed in the user’s buffer.

API details

cyg_io_read(handle, buf, len)

This function is used to read data from the device. In the default case, data is read until an end-of-line character ("\n" or "\r") is read. Additionally, the characters are echoed back to the [terminal] device. Minimal editing of the input is also supported.

Note: When connecting to a remote target via GDB it is not possible to provide console input while GDB is connected. The GDB remote protocol does not support input. Users must disconnect from GDB if this functionality is required.

	
cyg_io_write(handle, buf, len)

This function is used to send data to the device. In the default case, the end-of-line character "\n" is replaced by the sequence "\r\n".

cyg_io_get_config(handle, key, buf, len)

This function is used to get information about the channel’s configuration at runtime.

CYG_IO_GET_CONFIG_TTY_INFO

Buf type:

cyg_tty_info_t

Function:

This function retrieves the current state of the driver.

Serial driver keys (see above) may also be specified in which case the call is passed directly to the serial driver.

cyg_io_set_config(handle, key, buf, len)

This function is used to modify the channel’s configuration at runtime.

CYG_IO_SET_CONFIG_TTY_INFO

Buf type:

cyg_tty_info_t

Function:

This function changes the current state of the driver.

Serial driver keys (see above) may also be specified in which case the call is passed directly to the serial driver.