no-OS
aducm3029_uart.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef ADUCM3029_UART_H_
41 #define ADUCM3029_UART_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <drivers/uart/adi_uart.h>
48 #include <stdbool.h>
49 #include <stdint.h>
50 #include "no_os_error.h"
51 #include "no_os_irq.h"
52 #include "no_os_uart.h"
53 
55 #define NO_OS_UART_MAX_BYTES 1024u
56 
57 /******************************************************************************/
58 /*************************** Types Declarations *******************************/
59 /******************************************************************************/
60 
65 enum UART_ERROR {
67  NO_ERR = 0x00,
78  HW_ERR_PARITY = 0x20,
95 };
96 
105  uint32_t baud_rate;
107  uint16_t div_n;
109  uint8_t div_m;
111  uint16_t div_c;
113  uint8_t osr;
114 };
115 
124  uint8_t *buff;
126  uint32_t pending;
127 };
128 
136  ADI_UART_HANDLE uart_handler;
145  uint8_t *adi_uart_buffer;
159 };
160 
164 extern const struct no_os_uart_platform_ops aducm_uart_ops;
165 
166 #endif /* ADUCM3029_UART_H_ */
NO_OS_UART_MAX_BYTES
#define NO_OS_UART_MAX_BYTES
Definition: aducm3029_uart.h:55
no_os_aducm_uart_desc::read_desc
struct no_os_op_desc read_desc
Definition: aducm3029_uart.h:154
no_os_uart_init_param::parity
enum no_os_uart_parity parity
Definition: no_os_uart.h:122
lf256fifo_remove
void lf256fifo_remove(struct lf256fifo *fifo)
HW_ERR_RX_CHAN_DMA_INVALID_DESCR
@ HW_ERR_RX_CHAN_DMA_INVALID_DESCR
Definition: aducm3029_uart.h:88
no_os_uart_platform_ops
Structure holding UART function pointers that point to the platform specific function.
Definition: no_os_uart.h:153
aducm3029_uart.h
Header file of UART driver for ADuCM302x.
NO_OS_EVT_UART_RX_COMPLETE
@ NO_OS_EVT_UART_RX_COMPLETE
Definition: no_os_irq.h:70
no_os_aducm_uart_desc::rx_callback
struct no_os_callback_desc rx_callback
Definition: aducm3029_uart.h:158
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:136
no_os_irq.h
Header file of IRQ interface.
no_os_irq_register_callback
int32_t no_os_irq_register_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: no_os_irq.c:94
lf256fifo_init
int lf256fifo_init(struct lf256fifo **)
no_os_uart_init_param::size
enum no_os_uart_size size
Definition: no_os_uart.h:120
no_os_aducm_uart_desc::uart_handler
ADI_UART_HANDLE uart_handler
Definition: aducm3029_uart.h:136
no_os_uart_platform_ops::init
int32_t(* init)(struct no_os_uart_desc **, struct no_os_uart_init_param *)
Definition: no_os_uart.h:155
no_os_uart_desc::baud_rate
uint32_t baud_rate
Definition: no_os_uart.h:142
no_os_op_desc
It stores the state of a operation.
Definition: aducm3029_uart.h:120
uart_rx_callback
void uart_rx_callback(void *context)
Definition: aducm3029_uart.c:89
no_os_op_desc::buff
uint8_t * buff
Definition: aducm3029_uart.h:124
no_os_baud_desc::baud_rate
uint32_t baud_rate
Definition: aducm3029_uart.h:105
no_os_trng_desc::dev
ADI_RNG_HANDLE dev
Definition: aducm3029_trng.c:75
no_os_aducm_uart_desc::adi_uart_buffer
uint8_t * adi_uart_buffer
Definition: aducm3029_uart.h:145
no_os_uart_desc::device_id
uint8_t device_id
Definition: no_os_uart.h:136
HW_ERR_RX_CHAN_DMA_BUS_FAULT
@ HW_ERR_RX_CHAN_DMA_BUS_FAULT
Definition: aducm3029_uart.h:84
no_os_callback_desc::peripheral
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:154
no_os_op_desc::is_nonblocking
bool is_nonblocking
Definition: aducm3029_uart.h:122
baud_rates_26MHz
const struct no_os_baud_desc baud_rates_26MHz[NO_OS_BAUDS_NB]
Definition: aducm3029_uart.c:66
no_os_aducm_uart_desc::callback_enabled
bool callback_enabled
Definition: aducm3029_uart.h:140
no_os_aducm_uart_desc::errors
enum UART_ERROR errors
Definition: aducm3029_uart.h:138
HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
@ HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
Definition: aducm3029_uart.h:92
aducm_uart_ops
const struct no_os_uart_platform_ops aducm_uart_ops
aducm3029 platform specific UART platform ops structure
Definition: aducm3029_uart.c:506
lf256fifo_read
int lf256fifo_read(struct lf256fifo *, uint8_t *)
no_os_min
#define no_os_min(x, y)
Definition: no_os_util.h:63
NO_OS_TRNG_PRESCALER
#define NO_OS_TRNG_PRESCALER
Definition: aducm3029_trng.c:58
no_os_uart_desc
Stucture holding the UART descriptor.
Definition: no_os_uart.h:134
no_os_trng_desc
TRNG Descriptor.
Definition: aducm3029_trng.c:67
no_os_error.h
Error codes definition.
no_os_trng.h
Header file of true random number generator.
no_os_uart_init_param::asynchronous_rx
bool asynchronous_rx
Definition: no_os_uart.h:116
aducm_irq_ops
const struct no_os_irq_platform_ops aducm_irq_ops
Aducm3029 platform specific IRQ platform ops structure.
Definition: aducm3029_irq.c:556
no_os_uart_desc::extra
void * extra
Definition: no_os_uart.h:145
BAD_INPUT_PARAMETERS
@ BAD_INPUT_PARAMETERS
Definition: aducm3029_uart.h:72
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:148
no_os_trng_fill_buffer
int32_t no_os_trng_fill_buffer(struct no_os_trng_desc *desc, uint8_t *buff, uint32_t len)
Fill buffer with random numbers.
Definition: aducm3029_trng.c:153
WAITING_FOR_CALLBACK
@ WAITING_FOR_CALLBACK
Definition: aducm3029_uart.h:74
no_os_irq_unregister_callback
int32_t no_os_irq_unregister_callback(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id, struct no_os_callback_desc *callback_desc)
Unregisters a generic IRQ handling function.
Definition: no_os_irq.c:114
NO_ERR
@ NO_ERR
Definition: aducm3029_uart.h:67
UART_ERROR
UART_ERROR
Values returned by no_os_uart_get_errors. Multiple values can be set.
Definition: aducm3029_uart.h:65
no_os_trng_init_param
Init parameter for TRNG.
Definition: no_os_trng.h:64
aducm3029_irq.h
Header file of IRQ driver for ADuCM302x.
no_os_irq_init_param::platform_ops
const struct no_os_irq_platform_ops * platform_ops
Definition: no_os_irq.h:107
no_os_uart_desc::rx_fifo
struct lf256fifo * rx_fifo
Definition: no_os_uart.h:140
lf256fifo_write
int lf256fifo_write(struct lf256fifo *, uint8_t)
NO_OS_UNUSED_PARAM
#define NO_OS_UNUSED_PARAM(x)
Definition: no_os_util.h:115
no_os_baud_desc
Structure of an element from baud_rates_26MHz. The baud rate is calculated with the formula: Baudrate...
Definition: aducm3029_uart.h:103
no_os_irq_ctrl_init
int32_t no_os_irq_ctrl_init(struct no_os_irq_ctrl_desc **desc, const struct no_os_irq_init_param *param)
Initialize the IRQ interrupts.
Definition: no_os_irq.c:51
no_os_callback_desc::handle
void * handle
Definition: no_os_irq.h:156
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:138
no_os_aducm_uart_desc::adi_uart_buffer_offset
uint32_t adi_uart_buffer_offset
Definition: aducm3029_uart.h:150
no_os_baud_desc::div_m
uint8_t div_m
Definition: aducm3029_uart.h:109
no_os_uart_init_param::baud_rate
uint32_t baud_rate
Definition: no_os_uart.h:118
no_os_baud_desc::osr
uint8_t osr
Definition: aducm3029_uart.h:113
no_os_trng_init
int32_t no_os_trng_init(struct no_os_trng_desc **desc, struct no_os_trng_init_param *param)
Initialize descriptor.
Definition: aducm3029_trng.c:117
no_os_uart_init_param::stop
enum no_os_uart_stop stop
Definition: no_os_uart.h:124
no_os_op_desc::pending
uint32_t pending
Definition: aducm3029_uart.h:126
no_os_callback_desc::event
enum no_os_irq_event event
Definition: no_os_irq.h:152
NO_OS_UART_PAR_EVEN
@ NO_OS_UART_PAR_EVEN
Definition: no_os_uart.h:85
no_os_trng_desc::dev_mem
uint32_t dev_mem[(ADI_RNG_MEMORY_SIZE+3)/4]
Definition: aducm3029_trng.c:73
no_os_aducm_uart_desc::write_desc
struct no_os_op_desc write_desc
Definition: aducm3029_uart.h:152
no_os_baud_desc::div_n
uint16_t div_n
Definition: aducm3029_uart.h:107
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.
Definition: no_os_uart.c:150
no_os_uart_desc::irq_id
uint32_t irq_id
Definition: no_os_uart.h:138
HW_ERR_PARITY
@ HW_ERR_PARITY
Definition: aducm3029_uart.h:78
NULL
#define NULL
Definition: wrapper.h:64
no_os_uart_init_param
Structure holding the parameters for UART initialization.
Definition: no_os_uart.h:110
HW_ERR_TX_CHAN_DMA_BUS_FAULT
@ HW_ERR_TX_CHAN_DMA_BUS_FAULT
Definition: aducm3029_uart.h:86
NO_OS_TRNG_CNT_VAL
#define NO_OS_TRNG_CNT_VAL
Definition: aducm3029_trng.c:56
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:103
NO_OS_UART_PAR_NO
@ NO_OS_UART_PAR_NO
Definition: no_os_uart.h:77
NO_OS_UART_IRQ
@ NO_OS_UART_IRQ
Definition: no_os_irq.h:87
no_os_irq_ctrl_remove
int32_t no_os_irq_ctrl_remove(struct no_os_irq_ctrl_desc *desc)
Free the resources allocated by no_os_irq_ctrl_init().
Definition: no_os_irq.c:76
no_os_uart_init_param::device_id
uint8_t device_id
Definition: no_os_uart.h:112
NO_OS_CLK_FREQ
#define NO_OS_CLK_FREQ
Definition: aducm3029_uart.c:55
no_os_aducm_uart_desc::nvic
struct no_os_irq_ctrl_desc * nvic
Definition: aducm3029_uart.h:156
no_os_irq_enable
int32_t no_os_irq_enable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: no_os_irq.c:183
NO_OS_UART_PAR_ODD
@ NO_OS_UART_PAR_ODD
Definition: no_os_uart.h:83
aducm_uart_ops
const struct no_os_uart_platform_ops aducm_uart_ops
aducm3029 platform specific UART platform ops structure
Definition: aducm3029_uart.c:506
no_os_uart.h
Header file of UART interface.
HW_ERR_TX_CHAN_DMA_UNKNOWN_ERROR
@ HW_ERR_TX_CHAN_DMA_UNKNOWN_ERROR
Definition: aducm3029_uart.h:94
NO_OS_NUM_UART_DEVICES
#define NO_OS_NUM_UART_DEVICES
Definition: aducm3029_uart.c:62
no_os_baud_desc::div_c
uint16_t div_c
Definition: aducm3029_uart.h:111
HW_ERR_OVERRUN
@ HW_ERR_OVERRUN
Definition: aducm3029_uart.h:80
no_os_util.h
Header file of utility functions.
NO_OS_BAUDS_NB
#define NO_OS_BAUDS_NB
Definition: aducm3029_uart.c:56
no_os_irq_disable
int32_t no_os_irq_disable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: no_os_irq.c:200
BREAK_INTERRUPT
@ BREAK_INTERRUPT
Definition: aducm3029_uart.h:82
HW_ERR_TX_CHAN_DMA_INVALID_DESCR
@ HW_ERR_TX_CHAN_DMA_INVALID_DESCR
Definition: aducm3029_uart.h:90
no_os_irq_ctrl_desc
Definition: no_os_irq.h:119
no_os_aducm_uart_desc
Stores specific parameter needed by the UART driver for internal operations.
Definition: aducm3029_uart.h:134
NO_OS_UART_CS_8
@ NO_OS_UART_CS_8
Definition: no_os_uart.h:66
NO_OS_ADUCM_TRNG_DEVICE_ID
#define NO_OS_ADUCM_TRNG_DEVICE_ID
Definition: aducm3029_trng.c:60
HW_ERR_FRAMING
@ HW_ERR_FRAMING
Definition: aducm3029_uart.h:76
no_os_trng_remove
void no_os_trng_remove(struct no_os_trng_desc *desc)
Free resources allocated in descriptor.
Definition: aducm3029_trng.c:138