no-OS
uart_extra.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef UART_EXTRA_H_
41 #define UART_EXTRA_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 #include "error.h"
50 
51 /******************************************************************************/
52 /*************************** Types Declarations *******************************/
53 /******************************************************************************/
54 
59 enum UART_ERROR {
61  NO_ERR = 0x00,
72  HW_ERR_PARITY = 0x20,
89 };
90 
104 };
105 
121 };
122 
135 };
136 
144 enum UART_BAUD {
146  BD_9600 = 9600,
148  BD_19200 = 19200,
150  BD_38400 = 38400,
152  BD_57600 = 57600,
154  BD_115200 = 115200,
156  BD_230400 = 230400,
158  BD_460800 = 460800,
160  BD_921600 = 921600,
162  BD_1000000 = 1000000,
164  BD_1500000 = 1500000
165 };
166 
179 };
180 
181 #endif /* UART_H_ */
uart_get_errors
uint32_t uart_get_errors(struct uart_desc *desc)
Free the resources allocated by uart_init()
Definition: uart.c:530
UART_ONE_STOPBIT
@ UART_ONE_STOPBIT
Definition: uart_extra.h:129
HW_ERR_RX_CHAN_DMA_INVALID_DESCR
@ HW_ERR_RX_CHAN_DMA_INVALID_DESCR
Definition: uart_extra.h:82
HW_ERR_PARITY
@ HW_ERR_PARITY
Definition: uart_extra.h:72
UART_WORDLEN
UART_WORDLEN
Values for word_length in aducm_uart_init_param.
Definition: uart_extra.h:95
uart_read
int32_t uart_read(struct uart_desc *desc, uint8_t *data, uint32_t bytes_number)
Read data from UART. Blocking function.
Definition: uart.c:271
trng.h
Header file of true random number generator.
irq_ctrl_desc
Definition: irq.h:97
HW_ERR_TX_CHAN_DMA_BUS_FAULT
@ HW_ERR_TX_CHAN_DMA_BUS_FAULT
Definition: uart_extra.h:80
NO_ERR
@ NO_ERR
Definition: uart_extra.h:61
BD_460800
@ BD_460800
Definition: uart_extra.h:158
min
#define min(x, y)
Definition: util.h:63
xil_uart_init_param::type
enum xil_uart_type type
Definition: uart_extra.h:75
trng_desc::dev_mem
uint32_t dev_mem[(ADI_RNG_MEMORY_SIZE+3)/4]
Definition: trng.c:73
IRQ_WRITE_DONE
@ IRQ_WRITE_DONE
Definition: irq.h:59
xil_uart_desc::buff
char buff[UART_BUFF_LENGTH]
Definition: uart_extra.h:98
xil_uart_desc
Xilinx platform specific UART descriptor.
Definition: uart_extra.h:86
xil_uart_desc::bytes_received
uint32_t bytes_received
Definition: uart_extra.h:100
callback_desc::ctx
void * ctx
Definition: irq.h:119
uart_init_param::extra
void * extra
Definition: uart.h:113
WRITE_SIZE
#define WRITE_SIZE
Definition: uart.c:56
uart_init
int32_t uart_init(struct uart_desc **desc, struct uart_init_param *param)
Initialize the UART communication peripheral.
Definition: uart.c:441
fifo.h
Implementation of fifo.
BD_9600
@ BD_9600
Definition: uart_extra.h:146
u8
unsigned char u8
Definition: wrapper.h:156
xil_uart_init_param::irq_id
uint32_t irq_id
Definition: uart_extra.h:77
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.
Definition: uart.c:365
xil_uart_desc::type
enum xil_uart_type type
Definition: uart_extra.h:88
UART_STOPBITS
UART_STOPBITS
Values for stop_bits in aducm_uart_init_param.
Definition: uart_extra.h:127
BD_19200
@ BD_19200
Definition: uart_extra.h:148
UART_WORDLEN_5BITS
@ UART_WORDLEN_5BITS
Definition: uart_extra.h:97
BD_230400
@ BD_230400
Definition: uart_extra.h:156
UART_WORDLEN_7BITS
@ UART_WORDLEN_7BITS
Definition: uart_extra.h:101
IRQ_READ_DONE
@ IRQ_READ_DONE
Definition: irq.h:61
HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
@ HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
Definition: uart_extra.h:86
ADUCM_TRNG_DEVICE_ID
#define ADUCM_TRNG_DEVICE_ID
Definition: trng.c:60
xil_uart_desc::irq_desc
struct irq_ctrl_desc * irq_desc
Definition: uart_extra.h:92
trng_desc
TRNG Descriptor.
Definition: trng.c:67
TRNG_PRESCALER
#define TRNG_PRESCALER
Definition: trng.c:58
irq_enable
int32_t irq_enable(struct irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: irq.c:139
fifo_remove
struct fifo_element * fifo_remove(struct fifo_element *p_fifo)
BD_921600
@ BD_921600
Definition: uart_extra.h:160
uart_init_param::device_id
uint8_t device_id
Definition: uart.h:103
UART_PARITY
UART_PARITY
Values for parity in aducm_uart_init_param.
Definition: uart_extra.h:110
xil_uart_desc::total_error_count
uint32_t total_error_count
Definition: uart_extra.h:102
baud_desc
Structure of an element from baud_rates_26MHz. The baud rate is calculated with the formula: Baudrate...
Definition: uart.c:61
aducm_uart_desc::read_desc
struct op_desc read_desc
Definition: uart.c:112
uart.h
Header file of UART interface.
BREAK_INTERRUPT
@ BREAK_INTERRUPT
Definition: uart_extra.h:76
CLK_FREQ
#define CLK_FREQ
Definition: uart.c:120
UART_WORDLEN_6BITS
@ UART_WORDLEN_6BITS
Definition: uart_extra.h:99
uart_desc::extra
void * extra
Definition: uart.h:131
aducm_uart_desc
Stores specific parameter needed by the UART driver for internal operations.
Definition: uart.c:92
IRQ_ERROR
@ IRQ_ERROR
Definition: irq.h:63
HW_ERR_TX_CHAN_DMA_UNKNOWN_ERROR
@ HW_ERR_TX_CHAN_DMA_UNKNOWN_ERROR
Definition: uart_extra.h:88
aducm_uart_init_param
Stores specific parameter needed to initialize the UART driver for the ADuCM3029 platform.
Definition: uart_extra.h:172
aducm_uart_desc::uart_handler
ADI_UART_HANDLE uart_handler
Definition: uart.c:94
BD_115200
@ BD_115200
Definition: uart_extra.h:154
op_desc::pending
uint32_t pending
Definition: uart.c:84
UART_PS
@ UART_PS
Definition: uart_extra.h:65
uart_extra.h
Header file of UART driver for ADuCM302x.
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.
Definition: uart.c:402
error.h
Error codes definition.
BD_38400
@ BD_38400
Definition: uart_extra.h:150
callback_desc
Structure describing a callback to be registered.
Definition: irq.h:110
UART_BAUD
UART_BAUD
Values for baud_rate in uart_init_param The values are only valid if the ADuCM3029 runs at 26MHz....
Definition: uart_extra.h:144
trng_remove
void trng_remove(struct trng_desc *desc)
Free resources allocated in descriptor.
Definition: trng.c:137
HW_ERR_RX_CHAN_DMA_BUS_FAULT
@ HW_ERR_RX_CHAN_DMA_BUS_FAULT
Definition: uart_extra.h:78
trng_fill_buffer
int32_t trng_fill_buffer(struct trng_desc *desc, uint8_t *buff, uint32_t len)
Fill buffer with random numbers.
Definition: trng.c:152
BD_1500000
@ BD_1500000
Definition: uart_extra.h:164
callback_desc::callback
void(* callback)(void *ctx, uint32_t event, void *extra)
Definition: irq.h:117
HW_ERR_OVERRUN
@ HW_ERR_OVERRUN
Definition: uart_extra.h:74
baud_rates_26MHz
const struct baud_desc baud_rates_26MHz[BAUDS_NB]
Definition: uart.c:131
BD_1000000
@ BD_1000000
Definition: uart_extra.h:162
xil_uart_init_param
Structure holding the initialization parameters for Xilinx platform specific UART parameters.
Definition: uart_extra.h:73
WAITING_FOR_CALLBACK
@ WAITING_FOR_CALLBACK
Definition: uart_extra.h:68
uart_remove
int32_t uart_remove(struct uart_desc *desc)
Free the resources allocated by uart_init()
Definition: uart.c:509
uart_write
int32_t uart_write(struct uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
Write data to UART. Blocking function.
Definition: uart.c:318
UART_BUFF_LENGTH
#define UART_BUFF_LENGTH
Definition: uart_extra.h:51
UART_ONE_AND_HALF_TWO_STOPBITS
@ UART_ONE_AND_HALF_TWO_STOPBITS
Definition: uart_extra.h:134
UART_WORDLEN_8BITS
@ UART_WORDLEN_8BITS
Definition: uart_extra.h:103
UART_PL
@ UART_PL
Definition: uart_extra.h:63
irq_desc
Structure for Interrupt Request descriptor.
uart_desc::baud_rate
uint32_t baud_rate
Definition: uart.h:124
uart_desc::callback
void(* callback)(void *callback_ctx, uint32_t event, void *extra)
Definition: uart.h:126
xil_uart_init_param::irq_desc
struct irq_ctrl_desc * irq_desc
Definition: uart_extra.h:79
baud_desc::div_c
uint16_t div_c
Definition: uart.c:69
irq.h
Header file of IRQ interface.
op_desc::buff
uint8_t * buff
Definition: uart.c:82
baud_desc::div_n
uint16_t div_n
Definition: uart.c:65
UART_EVEN_PARITY_STICKY
@ UART_EVEN_PARITY_STICKY
Definition: uart_extra.h:120
xil_uart_desc::instance
void * instance
Definition: uart_extra.h:104
baud_desc::baud_rate
uint32_t baud_rate
Definition: uart.c:63
xil_uart_desc::fifo
struct fifo_element * fifo
Definition: uart_extra.h:94
uart_desc
Stucture holding the UART descriptor.
Definition: uart.h:120
BAD_INPUT_PARAMETERS
@ BAD_INPUT_PARAMETERS
Definition: uart_extra.h:66
trng_desc::dev
ADI_RNG_HANDLE dev
Definition: trng.c:75
baud_desc::osr
uint8_t osr
Definition: uart.c:71
aducm_uart_desc::adi_uart_buffer_offset
uint32_t adi_uart_buffer_offset
Definition: uart.c:108
UART_ERROR
UART_ERROR
Values returned by uart_get_errors. Multiple values can be set.
Definition: uart_extra.h:59
BAUDS_NB
#define BAUDS_NB
Definition: uart.c:121
aducm_uart_init_param::word_length
enum UART_WORDLEN word_length
Definition: uart_extra.h:178
NULL
#define NULL
Definition: wrapper.h:64
fifo_element::len
uint32_t len
Definition: fifo.h:62
NUM_UART_DEVICES
#define NUM_UART_DEVICES
Definition: uart.c:127
op_desc::is_nonblocking
bool is_nonblocking
Definition: uart.c:80
SUCCESS
#define SUCCESS
Definition: error.h:52
UART_ODD_PARITY
@ UART_ODD_PARITY
Definition: uart_extra.h:114
aducm_uart_desc::errors
enum UART_ERROR errors
Definition: uart.c:96
UART_NO_PARITY
@ UART_NO_PARITY
Definition: uart_extra.h:112
irq_register_callback
int32_t irq_register_callback(struct irq_ctrl_desc *desc, uint32_t irq_id, struct callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: irq.c:82
aducm_uart_desc::adi_uart_buffer
uint8_t * adi_uart_buffer
Definition: uart.c:103
trng_init_param
Init parameter for TRNG.
Definition: trng.h:64
UNUSED_PARAM
#define UNUSED_PARAM(x)
Definition: util.h:115
HW_ERR_TX_CHAN_DMA_INVALID_DESCR
@ HW_ERR_TX_CHAN_DMA_INVALID_DESCR
Definition: uart_extra.h:84
xil_uart_desc::fifo_read_offset
uint32_t fifo_read_offset
Definition: uart_extra.h:96
MAX_BYTES
#define MAX_BYTES
Definition: uart.c:119
op_desc
It stores the state of a operation.
Definition: uart.c:78
aducm_uart_desc::callback_enabled
bool callback_enabled
Definition: uart.c:98
uart_init_param
Structure holding the parameters for UART initialization.
Definition: uart.h:101
fifo_insert
int32_t fifo_insert(struct fifo_element **p_fifo, char *buff, uint32_t len)
baud_desc::div_m
uint8_t div_m
Definition: uart.c:67
uart_init_param::baud_rate
uint32_t baud_rate
Definition: uart.h:105
HW_ERR_FRAMING
@ HW_ERR_FRAMING
Definition: uart_extra.h:70
aducm_uart_desc::write_desc
struct op_desc write_desc
Definition: uart.c:110
fifo_element::data
char * data
Definition: fifo.h:60
uart_desc::device_id
uint8_t device_id
Definition: uart.h:122
trng_init
int32_t trng_init(struct trng_desc **desc, struct trng_init_param *param)
Initialize descriptor.
Definition: trng.c:117
TRNG_CNT_VAL
#define TRNG_CNT_VAL
Definition: trng.c:56
aducm_uart_init_param::stop_bits
enum UART_STOPBITS stop_bits
Definition: uart_extra.h:176
xil_uart_desc::irq_id
uint32_t irq_id
Definition: uart_extra.h:90
UART_EVEN_PARITY
@ UART_EVEN_PARITY
Definition: uart_extra.h:116
irq_disable
int32_t irq_disable(struct irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: irq.c:150
util.h
Implementation of utility functions.
UART_ODD_PARITY_STICKY
@ UART_ODD_PARITY_STICKY
Definition: uart_extra.h:118
FAILURE
#define FAILURE
Definition: error.h:56
BD_57600
@ BD_57600
Definition: uart_extra.h:152
aducm_uart_init_param::parity
enum UART_PARITY parity
Definition: uart_extra.h:174
uart_extra.h
uart_desc::callback_ctx
void * callback_ctx
Definition: uart.h:129