no-OS
aducm3029_uart.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef ADUCM3029_UART_H_
35 #define ADUCM3029_UART_H_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 
41 #include <drivers/uart/adi_uart.h>
42 #include <stdbool.h>
43 #include <stdint.h>
44 #include "no_os_error.h"
45 #include "no_os_irq.h"
46 #include "no_os_uart.h"
47 
49 #define NO_OS_UART_MAX_BYTES 1024u
50 
51 /******************************************************************************/
52 /*************************** Types Declarations *******************************/
53 /******************************************************************************/
54 
59 enum UART_ERROR {
61  NO_ERR = 0x00,
72  HW_ERR_PARITY = 0x20,
89 };
90 
99  uint32_t baud_rate;
101  uint16_t div_n;
103  uint8_t div_m;
105  uint16_t div_c;
107  uint8_t osr;
108 };
109 
118  uint8_t *buff;
120  uint32_t pending;
121 };
122 
130  ADI_UART_HANDLE uart_handler;
139  uint8_t *adi_uart_buffer;
153 };
154 
158 extern const struct no_os_uart_platform_ops aducm_uart_ops;
159 
160 #endif /* ADUCM3029_UART_H_ */
NO_OS_UART_MAX_BYTES
#define NO_OS_UART_MAX_BYTES
Definition: aducm3029_uart.h:49
no_os_aducm_uart_desc::read_desc
struct no_os_op_desc read_desc
Definition: aducm3029_uart.h:148
no_os_alloc.h
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:82
no_os_uart_platform_ops
Structure holding UART function pointers that point to the platform specific function.
Definition: no_os_uart.h:155
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:64
no_os_aducm_uart_desc::rx_callback
struct no_os_callback_desc rx_callback
Definition: aducm3029_uart.h:152
no_os_callback_desc
Structure describing a callback to be registered.
Definition: no_os_irq.h:142
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:92
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:130
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:157
no_os_uart_desc::baud_rate
uint32_t baud_rate
Definition: no_os_uart.h:144
no_os_op_desc
It stores the state of a operation.
Definition: aducm3029_uart.h:114
uart_rx_callback
void uart_rx_callback(void *context)
Definition: aducm3029_uart.c:84
no_os_op_desc::buff
uint8_t * buff
Definition: aducm3029_uart.h:118
no_os_baud_desc::baud_rate
uint32_t baud_rate
Definition: aducm3029_uart.h:99
no_os_aducm_uart_desc::adi_uart_buffer
uint8_t * adi_uart_buffer
Definition: aducm3029_uart.h:139
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
no_os_uart_desc::device_id
uint8_t device_id
Definition: no_os_uart.h:138
HW_ERR_RX_CHAN_DMA_BUS_FAULT
@ HW_ERR_RX_CHAN_DMA_BUS_FAULT
Definition: aducm3029_uart.h:78
no_os_callback_desc::peripheral
enum no_os_irq_peripheral peripheral
Definition: no_os_irq.h:150
no_os_op_desc::is_nonblocking
bool is_nonblocking
Definition: aducm3029_uart.h:116
baud_rates_26MHz
const struct no_os_baud_desc baud_rates_26MHz[NO_OS_BAUDS_NB]
Definition: aducm3029_uart.c:61
no_os_aducm_uart_desc::callback_enabled
bool callback_enabled
Definition: aducm3029_uart.h:134
no_os_aducm_uart_desc::errors
enum UART_ERROR errors
Definition: aducm3029_uart.h:132
HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
@ HW_ERR_RX_CHAN_DMA_UNKNOWN_ERROR
Definition: aducm3029_uart.h:86
aducm_uart_ops
const struct no_os_uart_platform_ops aducm_uart_ops
aducm3029 platform specific UART platform ops structure
Definition: aducm3029_uart.c:501
lf256fifo_read
int lf256fifo_read(struct lf256fifo *, uint8_t *)
no_os_min
#define no_os_min(x, y)
Definition: no_os_util.h:59
no_os_uart_desc
Stucture holding the UART descriptor.
Definition: no_os_uart.h:134
no_os_error.h
Error codes definition.
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:551
no_os_uart_desc::extra
void * extra
Definition: no_os_uart.h:147
BAD_INPUT_PARAMETERS
@ BAD_INPUT_PARAMETERS
Definition: aducm3029_uart.h:66
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:146
WAITING_FOR_CALLBACK
@ WAITING_FOR_CALLBACK
Definition: aducm3029_uart.h:68
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:112
NO_ERR
@ NO_ERR
Definition: aducm3029_uart.h:61
UART_ERROR
UART_ERROR
Values returned by no_os_uart_get_errors. Multiple values can be set.
Definition: aducm3029_uart.h:59
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:111
no_os_uart_desc::rx_fifo
struct lf256fifo * rx_fifo
Definition: no_os_uart.h:142
lf256fifo_write
int lf256fifo_write(struct lf256fifo *, uint8_t)
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:97
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:45
no_os_callback_desc::handle
void * handle
Definition: no_os_irq.h:152
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:144
no_os_aducm_uart_desc::adi_uart_buffer_offset
uint32_t adi_uart_buffer_offset
Definition: aducm3029_uart.h:144
no_os_baud_desc::div_m
uint8_t div_m
Definition: aducm3029_uart.h:103
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:107
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:120
no_os_callback_desc::event
enum no_os_irq_event event
Definition: no_os_irq.h:148
NO_OS_UART_PAR_EVEN
@ NO_OS_UART_PAR_EVEN
Definition: no_os_uart.h:85
no_os_aducm_uart_desc::write_desc
struct no_os_op_desc write_desc
Definition: aducm3029_uart.h:146
no_os_baud_desc::div_n
uint16_t div_n
Definition: aducm3029_uart.h:101
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:170
no_os_uart_desc::irq_id
uint32_t irq_id
Definition: no_os_uart.h:140
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
HW_ERR_PARITY
@ HW_ERR_PARITY
Definition: aducm3029_uart.h:72
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:80
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:107
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:86
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:71
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:50
no_os_aducm_uart_desc::nvic
struct no_os_irq_ctrl_desc * nvic
Definition: aducm3029_uart.h:150
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:181
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:501
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:88
NO_OS_NUM_UART_DEVICES
#define NO_OS_NUM_UART_DEVICES
Definition: aducm3029_uart.c:57
no_os_baud_desc::div_c
uint16_t div_c
Definition: aducm3029_uart.h:105
HW_ERR_OVERRUN
@ HW_ERR_OVERRUN
Definition: aducm3029_uart.h:74
no_os_util.h
Header file of utility functions.
NO_OS_BAUDS_NB
#define NO_OS_BAUDS_NB
Definition: aducm3029_uart.c:51
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:198
BREAK_INTERRUPT
@ BREAK_INTERRUPT
Definition: aducm3029_uart.h:76
HW_ERR_TX_CHAN_DMA_INVALID_DESCR
@ HW_ERR_TX_CHAN_DMA_INVALID_DESCR
Definition: aducm3029_uart.h:84
no_os_irq_ctrl_desc
Definition: no_os_irq.h:123
no_os_aducm_uart_desc
Stores specific parameter needed by the UART driver for internal operations.
Definition: aducm3029_uart.h:128
NO_OS_UART_CS_8
@ NO_OS_UART_CS_8
Definition: no_os_uart.h:66
HW_ERR_FRAMING
@ HW_ERR_FRAMING
Definition: aducm3029_uart.h:70