RTEMS 6.1-rc5
Loading...
Searching...
No Matches
uartlite_l.h
1/******************************************************************************
2* Copyright (C) 2002 - 2020 Xilinx, Inc. All rights reserved.
3* SPDX-License-Identifier: MIT
4******************************************************************************/
5
6/****************************************************************************/
36#ifndef XUARTLITE_L_H /* prevent circular inclusions */
37#define XUARTLITE_L_H /* by using protection macros */
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/***************************** Include Files ********************************/
44
45#ifndef __rtems__
46#include "xil_types.h"
47#include "xil_assert.h"
48#include "xil_io.h"
49#else
50#include <bsp/xil-compat.h>
51#endif /* __rtems__ */
52
53/*
54 * XPAR_XUARTLITE_USE_DCR_BRIDGE has to be set to 1 if the UartLite device is
55 * accessed through a DCR bus connected to a bridge.
56 */
57#define XPAR_XUARTLITE_USE_DCR_BRIDGE 0
58
59#if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0)
60#include "xio_dcr.h"
61#endif
62
63
64/************************** Constant Definitions ****************************/
65
66/* UART Lite register offsets */
67
68#if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0)
69#define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */
70#define XUL_TX_FIFO_OFFSET 1 /* transmit FIFO, write only */
71#define XUL_STATUS_REG_OFFSET 2 /* status register, read only */
72#define XUL_CONTROL_REG_OFFSET 3 /* control reg, write only */
73
74#else
75
76#define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */
77#define XUL_TX_FIFO_OFFSET 4 /* transmit FIFO, write only */
78#define XUL_STATUS_REG_OFFSET 8 /* status register, read only */
79#define XUL_CONTROL_REG_OFFSET 12 /* control reg, write only */
80
81#endif
82
83/* Control Register bit positions */
84
85#define XUL_CR_ENABLE_INTR 0x10 /* enable interrupt */
86#define XUL_CR_FIFO_RX_RESET 0x02 /* reset receive FIFO */
87#define XUL_CR_FIFO_TX_RESET 0x01 /* reset transmit FIFO */
88
89/* Status Register bit positions */
90
91#define XUL_SR_PARITY_ERROR 0x80
92#define XUL_SR_FRAMING_ERROR 0x40
93#define XUL_SR_OVERRUN_ERROR 0x20
94#define XUL_SR_INTR_ENABLED 0x10 /* interrupt enabled */
95#define XUL_SR_TX_FIFO_FULL 0x08 /* transmit FIFO full */
96#define XUL_SR_TX_FIFO_EMPTY 0x04 /* transmit FIFO empty */
97#define XUL_SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
98#define XUL_SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
99
100/* The following constant specifies the size of the Transmit/Receive FIFOs.
101 * The FIFO size is fixed to 16 in the Uartlite IP and the size is not
102 * configurable. This constant is not used in the driver.
103 */
104#define XUL_FIFO_SIZE 16
105
106/* Stop bits are fixed at 1. Baud, parity, and data bits are fixed on a
107 * per instance basis
108 */
109#define XUL_STOP_BITS 1
110
111/* Parity definitions
112 */
113#define XUL_PARITY_NONE 0
114#define XUL_PARITY_ODD 1
115#define XUL_PARITY_EVEN 2
116
117/**************************** Type Definitions ******************************/
118
119/***************** Macros (Inline Functions) Definitions ********************/
120
121/*
122 * Define the appropriate I/O access method to memory mapped I/O or DCR.
123 */
124#if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0)
125
126#define XUartLite_In32 XIo_DcrIn
127#define XUartLite_Out32 XIo_DcrOut
128
129#else
130
131#define XUartLite_In32 Xil_In32
132#define XUartLite_Out32 Xil_Out32
133
134#endif
135
136
137/****************************************************************************/
153#define XUartLite_WriteReg(BaseAddress, RegOffset, Data) \
154 XUartLite_Out32((BaseAddress) + (RegOffset), (u32)(Data))
155
156/****************************************************************************/
170#define XUartLite_ReadReg(BaseAddress, RegOffset) \
171 XUartLite_In32((BaseAddress) + (RegOffset))
172
173
174/****************************************************************************/
189#define XUartLite_SetControlReg(BaseAddress, Mask) \
190 XUartLite_WriteReg((BaseAddress), XUL_CONTROL_REG_OFFSET, (Mask))
191
192
193/****************************************************************************/
207#define XUartLite_GetStatusReg(BaseAddress) \
208 XUartLite_ReadReg((BaseAddress), XUL_STATUS_REG_OFFSET)
209
210
211/****************************************************************************/
224#define XUartLite_IsReceiveEmpty(BaseAddress) \
225 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA) != \
226 XUL_SR_RX_FIFO_VALID_DATA)
227
228#ifdef __rtems__
229/****************************************************************************/
242#define XUartLite_IsTransmitEmpty(BaseAddress) \
243 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_EMPTY) == \
244 XUL_SR_TX_FIFO_EMPTY)
245#endif /* __rtems__ */
246
247/****************************************************************************/
260#define XUartLite_IsTransmitFull(BaseAddress) \
261 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL) == \
262 XUL_SR_TX_FIFO_FULL)
263
264
265/****************************************************************************/
278#define XUartLite_IsIntrEnabled(BaseAddress) \
279 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED) == \
280 XUL_SR_INTR_ENABLED)
281
282
283/****************************************************************************/
298#define XUartLite_EnableIntr(BaseAddress) \
299 XUartLite_SetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)
300
301
302/****************************************************************************/
317#define XUartLite_DisableIntr(BaseAddress) \
318 XUartLite_SetControlReg((BaseAddress), 0)
319
320/************************** Function Prototypes *****************************/
321
322void XUartLite_SendByte(UINTPTR BaseAddress, u8 Data);
323u8 XUartLite_RecvByte(UINTPTR BaseAddress);
324
325#ifdef __cplusplus
326}
327#endif
328
329#endif /* end of protection macro */
330
331
u8 XUartLite_RecvByte(UINTPTR BaseAddress)
Definition: uartlite_l.c:92
void XUartLite_SendByte(UINTPTR BaseAddress, u8 Data)
Definition: uartlite_l.c:70