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_alloc.h
no_os_uart_init_param::parity
enum no_os_uart_parity parity
Definition: no_os_uart.h:128
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:161
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:148
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:98
lf256fifo_init
int lf256fifo_init(struct lf256fifo **)
no_os_uart_init_param::size
enum no_os_uart_size size
Definition: no_os_uart.h:126
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:163
no_os_uart_desc::baud_rate
uint32_t baud_rate
Definition: no_os_uart.h:150
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:90
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_aducm_uart_desc::adi_uart_buffer
uint8_t * adi_uart_buffer
Definition: aducm3029_uart.h:145
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:60
no_os_uart_desc::device_id
uint8_t device_id
Definition: no_os_uart.h:144
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:156
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:67
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:507
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_uart_desc
Stucture holding the UART descriptor.
Definition: no_os_uart.h:140
no_os_error.h
Error codes definition.
no_os_uart_init_param::asynchronous_rx
bool asynchronous_rx
Definition: no_os_uart.h:122
aducm_irq_ops
const struct no_os_irq_platform_ops aducm_irq_ops
Aducm3029 platform specific IRQ platform ops structure.
Definition: aducm3029_irq.c:557
no_os_uart_desc::extra
void * extra
Definition: no_os_uart.h:153
BAD_INPUT_PARAMETERS
@ BAD_INPUT_PARAMETERS
Definition: aducm3029_uart.h:72
no_os_callback_desc::ctx
void * ctx
Definition: no_os_irq.h:152
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:118
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
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:117
no_os_uart_desc::rx_fifo
struct lf256fifo * rx_fifo
Definition: no_os_uart.h:148
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: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:158
no_os_callback_desc::callback
void(* callback)(void *context)
Definition: no_os_irq.h:150
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:124
no_os_baud_desc::osr
uint8_t osr
Definition: aducm3029_uart.h:113
no_os_uart_init_param::stop
enum no_os_uart_stop stop
Definition: no_os_uart.h:130
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:154
NO_OS_UART_PAR_EVEN
@ NO_OS_UART_PAR_EVEN
Definition: no_os_uart.h:91
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:176
no_os_uart_desc::irq_id
uint32_t irq_id
Definition: no_os_uart.h:146
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:75
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:116
HW_ERR_TX_CHAN_DMA_BUS_FAULT
@ HW_ERR_TX_CHAN_DMA_BUS_FAULT
Definition: aducm3029_uart.h:86
no_os_irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: no_os_irq.h:113
NO_OS_UART_PAR_NO
@ NO_OS_UART_PAR_NO
Definition: no_os_uart.h:83
NO_OS_UART_IRQ
@ NO_OS_UART_IRQ
Definition: no_os_irq.h:92
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:77
no_os_uart_init_param::device_id
uint8_t device_id
Definition: no_os_uart.h:118
NO_OS_CLK_FREQ
#define NO_OS_CLK_FREQ
Definition: aducm3029_uart.c:56
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:187
NO_OS_UART_PAR_ODD
@ NO_OS_UART_PAR_ODD
Definition: no_os_uart.h:89
aducm_uart_ops
const struct no_os_uart_platform_ops aducm_uart_ops
aducm3029 platform specific UART platform ops structure
Definition: aducm3029_uart.c:507
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:63
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:57
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:204
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:129
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:72
HW_ERR_FRAMING
@ HW_ERR_FRAMING
Definition: aducm3029_uart.h:76