Ioct() operations – Altera Embedded Peripherals IP User Manual

Page 79

Advertising
background image

The small driver is a polled implementation that waits for the UART hardware before sending and

receiving each character. There are two ways to enable the small footprint driver:
• Enable the small footprint setting for the HAL system library project. This option affects device drivers

for all devices in the system as well.

• Specify the preprocessor option

-DALTERA_AVALON_UART_SMALL

. You can use this option if you want

the small, polled implementation of the UART driver, but do not want to affect the drivers for other

devices.

Refer to the help system in the Nios II IDE for details about how to set HAL properties and preprocessor

options.
If the CTS/RTS flow control signals are enabled in hardware, the fast driver automatically uses them. The

small driver always ignores them.

ioct() Operations

The UART driver supports the

ioctl()

function to allow HAL-based programs to request device-specific

operations. The table below defines operation requests that the UART driver supports.

Table 8-4: UART ioctl() Operations

Request

Description

TIOCEXCL

Locks the device for exclusive access. Further calls to

open()

for this device will

fail until either this file descriptor is closed, or the lock is released using the

TIOCNXCL ioctl

request. For this request to succeed there can be no other

existing file descriptors for this device. The parameter

arg

is ignored.

TIOCNXCL

Releases a previous exclusive access lock. The parameter

arg

is ignored.

Additional operation requests are also optionally available for the fast driver only, as shown in Optional

UART ioctl() Operations for the Fast Driver Only Table. To enable these operations in your program,

you must set the preprocessor option

-DALTERA_AVALON_UART_USE_IOCTL

.

Table 8-5: Optional UART ioctl() Operations for the Fast Driver Only

Request

Description

TIOCMGET

Returns the current configuration of the device by filling in the contents of the input

termios structure.

A pointer to this structure is supplied as the value of the parameter

opt

.

TIOCMSET

Sets the configuration of the device according to the values contained in the input

termios structure.

A pointer to this structure is supplied as the value of the parameter

arg

.

Note: The termios structure is defined by the Newlib C standard library. You can find the definition in

the file <Nios II EDS install path>

/components/altera_hal/HAL/inc/sys/termios.h

.

8-10

ioct() Operations

UG-01085

2014.24.07

Altera Corporation

UART Core

Send Feedback

Advertising