no-OS
Classes | Macros | Enumerations | Functions
no_os_uart.h File Reference

Header file of UART interface. More...

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

Go to the source code of this file.

Classes

struct  no_os_uart_init_param
 Structure holding the parameters for UART initialization. More...
 
struct  no_os_uart_desc
 Stucture holding the UART descriptor. More...
 
struct  no_os_uart_platform_ops
 Structure holding UART function pointers that point to the platform specific function. More...
 

Macros

#define UART_MAX_NUMBER   10
 

Enumerations

enum  no_os_uart_size {
  NO_OS_UART_CS_5,
  NO_OS_UART_CS_6,
  NO_OS_UART_CS_7,
  NO_OS_UART_CS_8,
  NO_OS_UART_CS_9
}
 UART character size (number of data bits) options. More...
 
enum  no_os_uart_parity {
  NO_OS_UART_PAR_NO,
  NO_OS_UART_PAR_MARK,
  NO_OS_UART_PAR_SPACE,
  NO_OS_UART_PAR_ODD,
  NO_OS_UART_PAR_EVEN
}
 UART parity options. More...
 
enum  no_os_uart_stop {
  NO_OS_UART_STOP_1_BIT,
  NO_OS_UART_STOP_2_BIT
}
 UART number of stop bits options. More...
 

Functions

int32_t no_os_uart_read (struct no_os_uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Read data from UART. More...
 
int32_t no_os_uart_write (struct no_os_uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Write to UART. More...
 
int32_t no_os_uart_read_nonblocking (struct no_os_uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Read data from UART non-blocking. More...
 
int32_t no_os_uart_write_nonblocking (struct no_os_uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Write to UART non-blocking. More...
 
int32_t no_os_uart_init (struct no_os_uart_desc **desc, struct no_os_uart_init_param *param)
 Initialize the UART communication peripheral. More...
 
int32_t no_os_uart_remove (struct no_os_uart_desc *desc)
 Free the resources allocated by no_os_uart_init(). More...
 
uint32_t no_os_uart_get_errors (struct no_os_uart_desc *desc)
 Check if errors occurred on UART. More...
 
void no_os_uart_stdio (struct no_os_uart_desc *desc)
 

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.

Macro Definition Documentation

◆ UART_MAX_NUMBER

#define UART_MAX_NUMBER   10

Enumeration Type Documentation

◆ no_os_uart_parity

UART parity options.

Enumerator
NO_OS_UART_PAR_NO 

no parity

NO_OS_UART_PAR_MARK 

mark parity

NO_OS_UART_PAR_SPACE 

space parity

NO_OS_UART_PAR_ODD 

odd parity

NO_OS_UART_PAR_EVEN 

even parity

◆ no_os_uart_size

UART character size (number of data bits) options.

Enumerator
NO_OS_UART_CS_5 

5 data bits

NO_OS_UART_CS_6 

6 data bits

NO_OS_UART_CS_7 

7 data bits

NO_OS_UART_CS_8 

8 data bits

NO_OS_UART_CS_9 

9 data bits

◆ no_os_uart_stop

UART number of stop bits options.

Enumerator
NO_OS_UART_STOP_1_BIT 

one stop bit

NO_OS_UART_STOP_2_BIT 

two stop bits

Function Documentation

◆ no_os_uart_get_errors()

uint32_t no_os_uart_get_errors ( struct no_os_uart_desc desc)

Check if errors occurred on UART.

Parameters
desc- The UART descriptor.
Returns
number of errors in case of success, error code otherwise.

Check if errors occurred on UART.

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

◆ no_os_uart_init()

int32_t no_os_uart_init ( struct no_os_uart_desc **  desc,
struct no_os_uart_init_param param 
)

Initialize the UART communication peripheral.

Parameters
desc- The UART descriptor.
param- The structure that contains the UART parameters.
Returns
0 in case of success, error code otherwise.
Parameters
desc- The UART descriptor.
param- The structure that contains the UART parameters.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ no_os_uart_read()

int32_t no_os_uart_read ( struct no_os_uart_desc desc,
uint8_t *  data,
uint32_t  bytes_number 
)

Read data from UART.

Parameters
desc- The UART descriptor.
data- The buffer with the received data.
bytes_number- Number of bytes to read.
Returns
0 in case of success, error code otherwise.

Read data from UART.

Parameters
desc- Instance of UART.
data- Pointer to buffer containing data.
bytes_number- Number of bytes to read.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ no_os_uart_read_nonblocking()

int32_t no_os_uart_read_nonblocking ( struct no_os_uart_desc desc,
uint8_t *  data,
uint32_t  bytes_number 
)

Read data from UART non-blocking.

Parameters
desc- The UART descriptor.
data- The buffer with the received data.
bytes_number- Number of bytes to read.
Returns
0 in case of success, error code otherwise.

Read data from UART non-blocking.

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
0 in case of success, -1 otherwise.

◆ no_os_uart_remove()

int32_t no_os_uart_remove ( struct no_os_uart_desc desc)

Free the resources allocated by no_os_uart_init().

Parameters
desc- The UART descriptor.
Returns
0 in case of success, error code otherwise.
Parameters
desc- The UART descriptor.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ no_os_uart_stdio()

void no_os_uart_stdio ( struct no_os_uart_desc desc)
Here is the caller graph for this function:

◆ no_os_uart_write()

int32_t no_os_uart_write ( struct no_os_uart_desc desc,
const uint8_t *  data,
uint32_t  bytes_number 
)

Write to UART.

Parameters
desc- The UART descriptor.
data- The buffer with the transmitted data.
bytes_number- Number of bytes to write.
Returns
0 in case of success, error code otherwise.

Write to UART.

Parameters
desc- Instance of UART.
data- Pointer to buffer containing data.
bytes_number- Number of bytes to read.
Returns
0 in case of success, -1 otherwise.
Here is the caller graph for this function:

◆ no_os_uart_write_nonblocking()

int32_t no_os_uart_write_nonblocking ( struct no_os_uart_desc desc,
const uint8_t *  data,
uint32_t  bytes_number 
)

Write to UART non-blocking.

Parameters
desc- The UART descriptor.
data- The buffer with the transmitted data.
bytes_number- Number of bytes to write.
Returns
0 in case of success, error code otherwise.

Write to UART non-blocking.

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
0 in case of success, -1 otherwise.