dnx RTOS 2.2.0 "Eagle"
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
UART Driver

Detailed Description

Description

Driver handles UART peripheral.

Supported architectures

Details

Meaning of major and minor numbers

Some manufactures enumerate devices starting from 1 instead of 0 (e.g. ST). In this case major number starts from 0 and is connected to the first device e.g. UART1.

The minor number has no meaning and should be always set to 0.

Numeration restrictions

Number of peripherals determines how big major number can be. If there is only one UART peripheral then the major number is always 0. The minor number should be always set to 0.

Driver initialization

To initialize driver the following code can be used:

driver_init("UART", 0, 0, "/dev/ttyS0"); // UART0
driver_init("UART", 1, 0, "/dev/ttyS1"); // UART1

Driver release

To release driver the following code can be used:

driver_release("UART", 0, 0);
driver_release("UART", 1, 0);

Driver configuration

The default driver values should be configured in project configuration (Configtool). Runtime configuration should be always done at system startup or later in application. In this case the ioctl() function should be used and UART_config_t object.

Data write

Writing data to device is the same as writing data to regular file. File position is ignored because device handle stream.

Data read

Reading data from device is the same as reading data from regular file. Driver support not blocking character read by using ioctl() function (by using following requests: IOCTL_UART__GET_CHAR_UNBLOCKING or IOCTL_VFS__NON_BLOCKING_RD_MODE with fread() function). File position is ignored because device handle stream.

Data Structures

struct  UART_config_t
 

Macros

#define IOCTL_UART__SET_CONFIGURATION   _IOW(UART, 0x00, struct UART_config*)
 Set UART configuration. More...
 
#define IOCTL_UART__GET_CONFIGURATION   _IOR(UART, 0x01, struct UART_config*)
 Gets UART configuration. More...
 
#define IOCTL_UART__GET_CHAR_UNBLOCKING   _IOR(UART, 0x02, char*)
 Gets character from UART in non-blocking mode. More...
 

Enumerations

enum  UART_parity
 
enum  UART_stop_bit
 
enum  UART_LIN_break
 

Data Structure Documentation

struct UART_config_t

Type represent UART configuration.

Data Fields
u32_t baud

Baudrate.

bool hardware_flow_ctrl

Hardware flow control enable (RTS, CTS).

enum UART_LIN_break LIN_break_length

LIN break length.

bool LIN_mode_enable

LIN mode enable.

enum UART_parity parity

Parity configuration.

bool rx_enable

Rx channel enable.

bool single_wire_mode

Single wire mode enable.

enum UART_stop_bit stop_bits

Stop bits configuration.

bool tx_enable

Tx channel enable.

Macro Definition Documentation

#define IOCTL_UART__GET_CHAR_UNBLOCKING   _IOR(UART, 0x02, char*)
Parameters
[RD]char * read character
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_UART__GET_CONFIGURATION   _IOR(UART, 0x01, struct UART_config*)
Parameters
[RD]struct UART_config_t * UART peripheral configuration
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_UART__SET_CONFIGURATION   _IOW(UART, 0x00, struct UART_config*)
Parameters
[WR]struct UART_config_t * UART peripheral configuration
Returns
On success 0 is returned, otherwise -1.

Enumeration Type Documentation

Type represent LIN break mode configuration.

Enumerator
UART_LIN_BREAK__10_BITS 

Break condition 10 bits long.

UART_LIN_BREAK__11_BITS 

Break condition 11 bits long.

Type represent parity configuration.

Enumerator
UART_PARITY__OFF 

Parity disabled.

UART_PARITY__ODD 

Odd parity enabled.

UART_PARITY__EVEN 

Even parity enabled.

Type represent stop bit configuration.

Enumerator
UART_STOP_BIT__1 

One stop bit.

UART_STOP_BIT__2 

Two stop bit.