![]() |
|
|||
File indexing completed on 2025-05-11 08:23:49
0001 /****************************************************************************** 0002 * Copyright (C) 2002 - 2020 Xilinx, Inc. All rights reserved. 0003 * SPDX-License-Identifier: MIT 0004 ******************************************************************************/ 0005 0006 /****************************************************************************/ 0007 /** 0008 * 0009 * @file xuartlite_l.h 0010 * @addtogroup uartlite_v3_5 0011 * @{ 0012 * 0013 * This header file contains identifiers and low-level driver functions (or 0014 * macros) that can be used to access the device. High-level driver functions 0015 * are defined in xuartlite.h. 0016 * 0017 * <pre> 0018 * MODIFICATION HISTORY: 0019 * 0020 * Ver Who Date Changes 0021 * ----- ---- -------- ------------------------------------------------------- 0022 * 1.00b rpm 04/25/02 First release 0023 * 1.00b rpm 07/07/03 Removed references to XUartLite_GetControlReg macro 0024 * since the control register is write-only 0025 * 1.12a mta 03/21/07 Updated to new coding style 0026 * 1.13a sv 01/21/08 Updated driver to support access through DCR bus 0027 * 2.00a ktn 10/20/09 Updated to use HAL Processor APIs. The macros have been 0028 * renamed to remove _m from the name. 0029 * 3.2 sk 11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425. 0030 * Changed the prototypes of XUartLite_SendByte, 0031 * XUartLite_RecvByte APIs. 0032 * </pre> 0033 * 0034 *****************************************************************************/ 0035 0036 #ifndef XUARTLITE_L_H /* prevent circular inclusions */ 0037 #define XUARTLITE_L_H /* by using protection macros */ 0038 0039 #ifdef __cplusplus 0040 extern "C" { 0041 #endif 0042 0043 /***************************** Include Files ********************************/ 0044 0045 #ifndef __rtems__ 0046 #include "xil_types.h" 0047 #include "xil_assert.h" 0048 #include "xil_io.h" 0049 #else 0050 #include <bsp/xil-compat.h> 0051 #endif /* __rtems__ */ 0052 0053 /* 0054 * XPAR_XUARTLITE_USE_DCR_BRIDGE has to be set to 1 if the UartLite device is 0055 * accessed through a DCR bus connected to a bridge. 0056 */ 0057 #define XPAR_XUARTLITE_USE_DCR_BRIDGE 0 0058 0059 #if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0) 0060 #include "xio_dcr.h" 0061 #endif 0062 0063 0064 /************************** Constant Definitions ****************************/ 0065 0066 /* UART Lite register offsets */ 0067 0068 #if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0) 0069 #define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */ 0070 #define XUL_TX_FIFO_OFFSET 1 /* transmit FIFO, write only */ 0071 #define XUL_STATUS_REG_OFFSET 2 /* status register, read only */ 0072 #define XUL_CONTROL_REG_OFFSET 3 /* control reg, write only */ 0073 0074 #else 0075 0076 #define XUL_RX_FIFO_OFFSET 0 /* receive FIFO, read only */ 0077 #define XUL_TX_FIFO_OFFSET 4 /* transmit FIFO, write only */ 0078 #define XUL_STATUS_REG_OFFSET 8 /* status register, read only */ 0079 #define XUL_CONTROL_REG_OFFSET 12 /* control reg, write only */ 0080 0081 #endif 0082 0083 /* Control Register bit positions */ 0084 0085 #define XUL_CR_ENABLE_INTR 0x10 /* enable interrupt */ 0086 #define XUL_CR_FIFO_RX_RESET 0x02 /* reset receive FIFO */ 0087 #define XUL_CR_FIFO_TX_RESET 0x01 /* reset transmit FIFO */ 0088 0089 /* Status Register bit positions */ 0090 0091 #define XUL_SR_PARITY_ERROR 0x80 0092 #define XUL_SR_FRAMING_ERROR 0x40 0093 #define XUL_SR_OVERRUN_ERROR 0x20 0094 #define XUL_SR_INTR_ENABLED 0x10 /* interrupt enabled */ 0095 #define XUL_SR_TX_FIFO_FULL 0x08 /* transmit FIFO full */ 0096 #define XUL_SR_TX_FIFO_EMPTY 0x04 /* transmit FIFO empty */ 0097 #define XUL_SR_RX_FIFO_FULL 0x02 /* receive FIFO full */ 0098 #define XUL_SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */ 0099 0100 /* The following constant specifies the size of the Transmit/Receive FIFOs. 0101 * The FIFO size is fixed to 16 in the Uartlite IP and the size is not 0102 * configurable. This constant is not used in the driver. 0103 */ 0104 #define XUL_FIFO_SIZE 16 0105 0106 /* Stop bits are fixed at 1. Baud, parity, and data bits are fixed on a 0107 * per instance basis 0108 */ 0109 #define XUL_STOP_BITS 1 0110 0111 /* Parity definitions 0112 */ 0113 #define XUL_PARITY_NONE 0 0114 #define XUL_PARITY_ODD 1 0115 #define XUL_PARITY_EVEN 2 0116 0117 /**************************** Type Definitions ******************************/ 0118 0119 /***************** Macros (Inline Functions) Definitions ********************/ 0120 0121 /* 0122 * Define the appropriate I/O access method to memory mapped I/O or DCR. 0123 */ 0124 #if (XPAR_XUARTLITE_USE_DCR_BRIDGE != 0) 0125 0126 #define XUartLite_In32 XIo_DcrIn 0127 #define XUartLite_Out32 XIo_DcrOut 0128 0129 #else 0130 0131 #define XUartLite_In32 Xil_In32 0132 #define XUartLite_Out32 Xil_Out32 0133 0134 #endif 0135 0136 0137 /****************************************************************************/ 0138 /** 0139 * 0140 * Write a value to a UartLite register. A 32 bit write is performed. 0141 * 0142 * @param BaseAddress is the base address of the UartLite device. 0143 * @param RegOffset is the register offset from the base to write to. 0144 * @param Data is the data written to the register. 0145 * 0146 * @return None. 0147 * 0148 * @note C-style signature: 0149 * void XUartLite_WriteReg(u32 BaseAddress, u32 RegOffset, 0150 * u32 Data) 0151 * 0152 ****************************************************************************/ 0153 #define XUartLite_WriteReg(BaseAddress, RegOffset, Data) \ 0154 XUartLite_Out32((BaseAddress) + (RegOffset), (u32)(Data)) 0155 0156 /****************************************************************************/ 0157 /** 0158 * 0159 * Read a value from a UartLite register. A 32 bit read is performed. 0160 * 0161 * @param BaseAddress is the base address of the UartLite device. 0162 * @param RegOffset is the register offset from the base to read from. 0163 * 0164 * @return Data read from the register. 0165 * 0166 * @note C-style signature: 0167 * u32 XUartLite_ReadReg(u32 BaseAddress, u32 RegOffset) 0168 * 0169 ****************************************************************************/ 0170 #define XUartLite_ReadReg(BaseAddress, RegOffset) \ 0171 XUartLite_In32((BaseAddress) + (RegOffset)) 0172 0173 0174 /****************************************************************************/ 0175 /** 0176 * 0177 * Set the contents of the control register. Use the XUL_CR_* constants defined 0178 * above to create the bit-mask to be written to the register. 0179 * 0180 * @param BaseAddress is the base address of the device 0181 * @param Mask is the 32-bit value to write to the control register 0182 * 0183 * @return None. 0184 * 0185 * @note C-style Signature: 0186 * void XUartLite_SetControlReg(u32 BaseAddress, u32 Mask); 0187 * 0188 *****************************************************************************/ 0189 #define XUartLite_SetControlReg(BaseAddress, Mask) \ 0190 XUartLite_WriteReg((BaseAddress), XUL_CONTROL_REG_OFFSET, (Mask)) 0191 0192 0193 /****************************************************************************/ 0194 /** 0195 * 0196 * Get the contents of the status register. Use the XUL_SR_* constants defined 0197 * above to interpret the bit-mask returned. 0198 * 0199 * @param BaseAddress is the base address of the device 0200 * 0201 * @return A 32-bit value representing the contents of the status register. 0202 * 0203 * @note C-style Signature: 0204 * u32 XUartLite_GetStatusReg(u32 BaseAddress); 0205 * 0206 *****************************************************************************/ 0207 #define XUartLite_GetStatusReg(BaseAddress) \ 0208 XUartLite_ReadReg((BaseAddress), XUL_STATUS_REG_OFFSET) 0209 0210 0211 /****************************************************************************/ 0212 /** 0213 * 0214 * Check to see if the receiver has data. 0215 * 0216 * @param BaseAddress is the base address of the device 0217 * 0218 * @return TRUE if the receiver is empty, FALSE if there is data present. 0219 * 0220 * @note C-style Signature: 0221 * int XUartLite_IsReceiveEmpty(u32 BaseAddress); 0222 * 0223 *****************************************************************************/ 0224 #define XUartLite_IsReceiveEmpty(BaseAddress) \ 0225 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_RX_FIFO_VALID_DATA) != \ 0226 XUL_SR_RX_FIFO_VALID_DATA) 0227 0228 #ifdef __rtems__ 0229 /****************************************************************************/ 0230 /** 0231 * 0232 * Check to see if the transmitter is empty. 0233 * 0234 * @param BaseAddress is the base address of the device 0235 * 0236 * @return TRUE if the transmitter is empty, FALSE otherwise. 0237 * 0238 * @note C-style Signature: 0239 * int XUartLite_IsTransmitEmpty(u32 BaseAddress); 0240 * 0241 *****************************************************************************/ 0242 #define XUartLite_IsTransmitEmpty(BaseAddress) \ 0243 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_EMPTY) == \ 0244 XUL_SR_TX_FIFO_EMPTY) 0245 #endif /* __rtems__ */ 0246 0247 /****************************************************************************/ 0248 /** 0249 * 0250 * Check to see if the transmitter is full. 0251 * 0252 * @param BaseAddress is the base address of the device 0253 * 0254 * @return TRUE if the transmitter is full, FALSE otherwise. 0255 * 0256 * @note C-style Signature: 0257 * int XUartLite_IsTransmitFull(u32 BaseAddress); 0258 * 0259 *****************************************************************************/ 0260 #define XUartLite_IsTransmitFull(BaseAddress) \ 0261 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_TX_FIFO_FULL) == \ 0262 XUL_SR_TX_FIFO_FULL) 0263 0264 0265 /****************************************************************************/ 0266 /** 0267 * 0268 * Check to see if the interrupt is enabled. 0269 * 0270 * @param BaseAddress is the base address of the device 0271 * 0272 * @return TRUE if the interrupt is enabled, FALSE otherwise. 0273 * 0274 * @note C-style Signature: 0275 * int XUartLite_IsIntrEnabled(u32 BaseAddress); 0276 * 0277 *****************************************************************************/ 0278 #define XUartLite_IsIntrEnabled(BaseAddress) \ 0279 ((XUartLite_GetStatusReg((BaseAddress)) & XUL_SR_INTR_ENABLED) == \ 0280 XUL_SR_INTR_ENABLED) 0281 0282 0283 /****************************************************************************/ 0284 /** 0285 * 0286 * Enable the device interrupt. We cannot read the control register, so we 0287 * just write the enable interrupt bit and clear all others. Since the only 0288 * other ones are the FIFO reset bits, this works without side effects. 0289 * 0290 * @param BaseAddress is the base address of the device 0291 * 0292 * @return None. 0293 * 0294 * @note C-style Signature: 0295 * void XUartLite_EnableIntr(u32 BaseAddress); 0296 * 0297 *****************************************************************************/ 0298 #define XUartLite_EnableIntr(BaseAddress) \ 0299 XUartLite_SetControlReg((BaseAddress), XUL_CR_ENABLE_INTR) 0300 0301 0302 /****************************************************************************/ 0303 /** 0304 * 0305 * Disable the device interrupt. We cannot read the control register, so we 0306 * just clear all bits. Since the only other ones are the FIFO reset bits, 0307 * this works without side effects. 0308 * 0309 * @param BaseAddress is the base address of the device 0310 * 0311 * @return None. 0312 * 0313 * @note C-style Signature: 0314 * void XUartLite_DisableIntr(u32 BaseAddress); 0315 * 0316 *****************************************************************************/ 0317 #define XUartLite_DisableIntr(BaseAddress) \ 0318 XUartLite_SetControlReg((BaseAddress), 0) 0319 0320 /************************** Function Prototypes *****************************/ 0321 0322 void XUartLite_SendByte(UINTPTR BaseAddress, u8 Data); 0323 u8 XUartLite_RecvByte(UINTPTR BaseAddress); 0324 0325 #ifdef __cplusplus 0326 } 0327 #endif 0328 0329 #endif /* end of protection macro */ 0330 0331 0332 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |