no-OS
Classes | Enumerations | Functions
uart.h File Reference

Header file of UART interface. More...

#include <stdint.h>
Include dependency graph for uart.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  uart_init_param
 Structure holding the parameters for UART initialization. More...
 
struct  uart_desc
 Stucture holding the UART descriptor. More...
 

Enumerations

enum  uart_size {
  UART_CS_5,
  UART_CS_6,
  UART_CS_7,
  UART_CS_8,
  UART_CS_9
}
 UART character size (number of data bits) options. More...
 
enum  uart_parity {
  UART_PAR_NO,
  UART_PAR_MARK,
  UART_PAR_SPACE,
  UART_PAR_ODD,
  UART_PAR_EVEN
}
 UART parity options. More...
 
enum  uart_stop {
  UART_STOP_1,
  UART_STOP_2
}
 UART number of stop bits options. More...
 

Functions

int32_t uart_read (struct uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Read data from UART. Blocking function. More...
 
int32_t uart_write (struct uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Write data to UART. Blocking function. More...
 
int32_t uart_read_nonblocking (struct uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Submit reading buffer to the UART driver. More...
 
int32_t uart_write_nonblocking (struct uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Submit writting buffer to the UART driver. More...
 
int32_t uart_init (struct uart_desc **desc, struct uart_init_param *param)
 Initialize the UART communication peripheral. More...
 
int32_t uart_remove (struct uart_desc *desc)
 Free the resources allocated by uart_init() More...
 
uint32_t uart_get_errors (struct uart_desc *desc)
 Free the resources allocated by uart_init() More...
 

Detailed Description

Header file of UART interface.

Author
Cristian Pop (crist.nosp@m.ian..nosp@m.pop@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2019(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Enumeration Type Documentation

◆ uart_parity

UART parity options.

Enumerator
UART_PAR_NO 

no parity

UART_PAR_MARK 

mark parity

UART_PAR_SPACE 

space parity

UART_PAR_ODD 

odd parity

UART_PAR_EVEN 

even parity

◆ uart_size

enum uart_size

UART character size (number of data bits) options.

Enumerator
UART_CS_5 

5 data bits

UART_CS_6 

6 data bits

UART_CS_7 

7 data bits

UART_CS_8 

8 data bits

UART_CS_9 

9 data bits

◆ uart_stop

enum uart_stop

UART number of stop bits options.

Enumerator
UART_STOP_1 

one stop bit

UART_STOP_2 

two stop bits

Function Documentation

◆ uart_get_errors()

uint32_t uart_get_errors ( struct uart_desc desc)

Free the resources allocated by uart_init()

Parameters
descDescriptor of the UART device
Returns
SUCCESS in case of success, FAILURE otherwise.

Free the resources allocated by uart_init()

Parameters
desc- The UART descriptor.
Returns
number of errors.

◆ uart_init()

int32_t uart_init ( struct uart_desc **  desc,
struct uart_init_param param 
)

Initialize the UART communication peripheral.

To configure the UART, the user must set the extra parameter from param with a pointer to the configured platform specific structure aducm_uart_init_param .

Parameters
descDescriptor of the UART device used in the call of the drivers functions
paramDescriptor used to configure the UART device
Returns
SUCCESS in case of success, FAILURE otherwise.
Parameters
desc- The UART descriptor.
param- The structure that contains the UART parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.
Parameters
desc- The UART descriptor.
param- The structure that contains the UART parameters.
Returns
SUCCESS in case of success, error code otherwise.
Here is the caller graph for this function:

◆ uart_read()

int32_t uart_read ( struct uart_desc desc,
uint8_t *  data,
uint32_t  bytes_number 
)

Read data from UART. Blocking function.

Parameters
descDescriptor of the UART device
dataBuffer where data will be read
bytes_numberNumber of bytes to be read. Between 1 and 1024
Returns
SUCCESS in case of success, FAILURE otherwise.

Read data from UART. Blocking function.

Parameters
desc- Instance of UART.
data- Pointer to buffer containing data.
bytes_number- Number of bytes to read.
Returns
SUCCESS in case of success, FAILURE otherwise.

Read data from UART. Blocking function.

Parameters
desc- Instance of UART.
data- Pointer to buffer containing data.
bytes_number- Number of bytes to read.
Returns
positive number of received bytes in case of success, negative error code otherwise.

◆ uart_read_nonblocking()

int32_t uart_read_nonblocking ( struct uart_desc desc,
uint8_t *  data,
uint32_t  bytes_number 
)

Submit reading buffer to the UART driver.

Buffer is used until bytes_number bytes are read.

Parameters
descDescriptor of the UART device
dataBuffer where data will be read
bytes_numberNumber of bytes to be read.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ uart_remove()

int32_t uart_remove ( struct uart_desc desc)

Free the resources allocated by uart_init()

Parameters
descDescriptor of the UART device
Returns
SUCCESS in case of success, FAILURE otherwise.

Free the resources allocated by uart_init()

Parameters
desc- The UART descriptor.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ uart_write()

int32_t uart_write ( struct uart_desc desc,
const uint8_t *  data,
uint32_t  bytes_number 
)

Write data to UART. Blocking function.

Parameters
descDescriptor of the UART device
dataBuffer with the data to be written
bytes_numberNumber of bytes to be written. Between 1 and 1024
Returns
SUCCESS in case of success, FAILURE otherwise.

Write data to UART. Blocking function.

Parameters
desc- Instance of UART.
data- Pointer to buffer containing data.
bytes_number- Number of bytes to read.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ uart_write_nonblocking()

int32_t uart_write_nonblocking ( struct uart_desc desc,
const uint8_t *  data,
uint32_t  bytes_number 
)

Submit writting buffer to the UART driver.

Data from the buffer is sent over the UART, the function returns immediately.

Parameters
descDescriptor of the UART device
dataBuffer where data will be written
bytes_numberNumber of bytes to be written.
Returns
SUCCESS in case of success, FAILURE otherwise.

Data from the buffer is sent over the UART, the function returns imediatly.

Parameters
descDescriptor of the UART device
dataBuffer where data will be written
bytes_numberNumber of bytes to be written.
Returns
SUCCESS in case of success, FAILURE otherwise.