summaryrefslogtreecommitdiff
path: root/include/asm-microblaze/arch-microblaze/xuartlite_l.h
blob: b381a0d7b61f8e3d9c5fec28ead2d547b62e8758 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/*****************************************************************************
*
*	XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
*	AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
*	SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,
*	OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
*	APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
*	THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
*	AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
*	FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY
*	WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
*	IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
*	REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
*	INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*	FOR A PARTICULAR PURPOSE.
*
*	(c) Copyright 2002 Xilinx Inc.
*	All rights reserved.
*
*****************************************************************************/
/****************************************************************************/
/**
*
* @file xuartlite_l.h
*
* This header file contains identifiers and low-level driver functions (or
* macros) that can be used to access the device.  High-level driver functions
* are defined in xuartlite.h.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver	Who  Date     Changes
* ----- ---- -------- -----------------------------------------------
* 1.00b rpm  04/25/02 First release
* </pre>
*
*****************************************************************************/

#ifndef XUARTLITE_L_H /* prevent circular inclusions */
#define XUARTLITE_L_H /* by using protection macros */

/***************************** Include Files ********************************/

#include "xbasic_types.h"
#include "xio.h"

/************************** Constant Definitions ****************************/

/* UART Lite register offsets */

#define XUL_RX_FIFO_OFFSET		0   /* receive FIFO, read only */
#define XUL_TX_FIFO_OFFSET		4   /* transmit FIFO, write only */
#define XUL_STATUS_REG_OFFSET		8   /* status register, read only */
#define XUL_CONTROL_REG_OFFSET		12  /* control register, write only */

/* control register bit positions */

#define XUL_CR_ENABLE_INTR		0x10	/* enable interrupt */
#define XUL_CR_FIFO_RX_RESET		0x02	/* reset receive FIFO */
#define XUL_CR_FIFO_TX_RESET		0x01	/* reset transmit FIFO */

/* status register bit positions */

#define XUL_SR_PARITY_ERROR		0x80
#define XUL_SR_FRAMING_ERROR		0x40
#define XUL_SR_OVERRUN_ERROR		0x20
#define XUL_SR_INTR_ENABLED		0x10	/* interrupt enabled */
#define XUL_SR_TX_FIFO_FULL		0x08	/* transmit FIFO full */
#define XUL_SR_TX_FIFO_EMPTY		0x04	/* transmit FIFO empty */
#define XUL_SR_RX_FIFO_FULL		0x02	/* receive FIFO full */
#define XUL_SR_RX_FIFO_VALID_DATA	0x01	/* data in receive FIFO */

/* the following constant specifies the size of the FIFOs, the size of the
 * FIFOs includes the transmitter and receiver such that it is the total number
 * of bytes that the UART can buffer
 */
#define XUL_FIFO_SIZE		    16

/* Stop bits are fixed at 1. Baud, parity, and data bits are fixed on a
 * per instance basis
 */
#define XUL_STOP_BITS		    1

/* Parity definitions
 */
#define XUL_PARITY_NONE		    0
#define XUL_PARITY_ODD		    1
#define XUL_PARITY_EVEN		    2

/**************************** Type Definitions ******************************/

/***************** Macros (Inline Functions) Definitions ********************/

/*****************************************************************************
*
* Low-level driver macros and functions. The list below provides signatures
* to help the user use the macros.
*
* void XUartLite_mSetControlReg(u32 BaseAddress, u32 Mask)
* u32 XUartLite_mGetControlReg(u32 BaseAddress)
* u32 XUartLite_mGetStatusReg(u32 BaseAddress)
*
* Xboolean XUartLite_mIsReceiveEmpty(u32 BaseAddress)
* Xboolean XUartLite_mIsTransmitFull(u32 BaseAddress)
* Xboolean XUartLite_mIsIntrEnabled(u32 BaseAddress)
*
* void XUartLite_mEnableIntr(u32 BaseAddress)
* void XUartLite_mDisableIntr(u32 BaseAddress)
*
* void XUartLite_SendByte(u32 BaseAddress, u8 Data);
* u8 XUartLite_RecvByte(u32 BaseAddress);
*
*****************************************************************************/

/****************************************************************************/
/**
*
* Set the contents of the control register. Use the XUL_CR_* constants defined
* above to create the bit-mask to be written to the register.
*
* @param    BaseAddress is the base address of the device
* @param    Mask is the 32-bit value to write to the control register
*
* @return   None.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mSetControlReg(BaseAddress, Mask) \
		    XIo_Out32((BaseAddress) + XUL_CONTROL_REG_OFFSET, (Mask))


/****************************************************************************/
/**
*
* Get the contents of the control register. Use the XUL_CR_* constants defined
* above to interpret the bit-mask returned.
*
* @param    BaseAddress is the	base address of the device
*
* @return   A 32-bit value representing the contents of the control register.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mGetControlReg(BaseAddress) \
		    XIo_In32((BaseAddress) + XUL_CONTROL_REG_OFFSET)


/****************************************************************************/
/**
*
* Get the contents of the status register. Use the XUL_SR_* constants defined
* above to interpret the bit-mask returned.
*
* @param    BaseAddress is the	base address of the device
*
* @return   A 32-bit value representing the contents of the status register.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mGetStatusReg(BaseAddress) \
		    XIo_In32((BaseAddress) + XUL_STATUS_REG_OFFSET)


/****************************************************************************/
/**
*
* Check to see if the receiver has data.
*
* @param    BaseAddress is the	base address of the device
*
* @return   XTRUE if the receiver is empty, XFALSE if there is data present.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mIsReceiveEmpty(BaseAddress) \
	  (!(XUartLite_mGetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA))


/****************************************************************************/
/**
*
* Check to see if the transmitter is full.
*
* @param    BaseAddress is the	base address of the device
*
* @return   XTRUE if the transmitter is full, XFALSE otherwise.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mIsTransmitFull(BaseAddress) \
		(XUartLite_mGetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL)


/****************************************************************************/
/**
*
* Check to see if the interrupt is enabled.
*
* @param    BaseAddress is the	base address of the device
*
* @return   XTRUE if the interrupt is enabled, XFALSE otherwise.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mIsIntrEnabled(BaseAddress) \
		(XUartLite_mGetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED)


/****************************************************************************/
/**
*
* Enable the device interrupt. Preserve the contents of the control register.
*
* @param    BaseAddress is the	base address of the device
*
* @return   None.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mEnableIntr(BaseAddress) \
	       XUartLite_mSetControlReg((BaseAddress), \
		   XUartLite_mGetControlReg((BaseAddress)) | XUL_CR_ENABLE_INTR)


/****************************************************************************/
/**
*
* Disable the device interrupt. Preserve the contents of the control register.
*
* @param    BaseAddress is the	base address of the device
*
* @return   None.
*
* @note	    None.
*
*****************************************************************************/
#define XUartLite_mDisableIntr(BaseAddress) \
	      XUartLite_mSetControlReg((BaseAddress), \
		  XUartLite_mGetControlReg((BaseAddress)) & ~XUL_CR_ENABLE_INTR)


/************************** Function Prototypes *****************************/

void XUartLite_SendByte(u32 BaseAddress, u8 Data);
u8 XUartLite_RecvByte(u32 BaseAddress);


#endif		  /* end of protection macro */