no-OS
Macros | Functions | Variables
aducm3029_uart.c File Reference

Implementation of UART driver for ADuCM302x. More...

#include <stdlib.h>
#include "no_os_uart.h"
#include "aducm3029_uart.h"
#include "aducm3029_irq.h"
#include "no_os_util.h"
#include <drivers/uart/adi_uart.h>
Include dependency graph for aducm3029_uart.c:

Macros

#define NO_OS_CLK_FREQ   26000000u
 
#define NO_OS_BAUDS_NB   10u
 
#define NO_OS_NUM_UART_DEVICES   1
 

Functions

void uart_rx_callback (void *context)
 
int32_t no_os_uart_read (struct no_os_uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Read data from UART. Blocking function. More...
 
int32_t no_os_uart_write (struct no_os_uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Write data to UART. Blocking function. More...
 
int32_t no_os_uart_read_nonblocking (struct no_os_uart_desc *desc, uint8_t *data, uint32_t bytes_number)
 Submit reading buffer to the UART driver. More...
 
int32_t no_os_uart_write_nonblocking (struct no_os_uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
 Submit writting buffer to the UART driver. 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)
 Free the resources allocated by no_os_uart_init(). More...
 

Variables

const struct no_os_baud_desc baud_rates_26MHz [NO_OS_BAUDS_NB]
 

Detailed Description

Implementation of UART driver for ADuCM302x.

Author
Mihail Chindris (mihai.nosp@m.l.ch.nosp@m.indri.nosp@m.s@an.nosp@m.alog..nosp@m.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

◆ NO_OS_BAUDS_NB

#define NO_OS_BAUDS_NB   10u

◆ NO_OS_CLK_FREQ

#define NO_OS_CLK_FREQ   26000000u

◆ NO_OS_NUM_UART_DEVICES

#define NO_OS_NUM_UART_DEVICES   1

In ADuCM302x UART0 is available

Function Documentation

◆ no_os_uart_get_errors()

uint32_t no_os_uart_get_errors ( struct no_os_uart_desc desc)

Free the resources allocated by no_os_uart_init().

Parameters
descDescriptor of the UART device
Returns
0 in case of success, -1 otherwise.

◆ 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
descDescriptor of the UART device used in the call of the drivers functions
paramDescriptor used to configure the UART device
Returns
0 in case of success, -1 otherwise.

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

◆ 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 
)

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
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
descDescriptor of the UART device
Returns
0 in case of success, -1 otherwise.

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

◆ 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 
)

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

◆ uart_rx_callback()

void uart_rx_callback ( void *  context)

Variable Documentation

◆ baud_rates_26MHz

const struct no_os_baud_desc baud_rates_26MHz[NO_OS_BAUDS_NB]
Initial value:
= {
{9600, 1078, 3, 24, 3},
{19200, 1078, 3, 12, 3},
{38400, 1321, 3, 8, 2},
{57600, 1078, 3, 4, 3},
{115200, 1563, 1, 4, 3},
{230400, 1563, 1, 2, 3},
{460800, 1563, 1, 1, 3},
{921600, 1563, 1, 1, 2},
{1000000,1280, 1, 1, 2},
{1500000, 171, 1, 1, 2}
}

Stores calculated baud rates and parameters