1 /******************************************************************************
3 * Copyright (C) 2005 - 2014 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /****************************************************************************/
35 * @file xuartlite_sinit.c
37 * The implementation of the XUartLite component's static initialzation
41 * MODIFICATION HISTORY:
43 * Ver Who Date Changes
44 * ----- ---- -------- -----------------------------------------------
45 * 1.01a jvb 10/13/05 First release
46 * 2.00a ktn 10/20/09 Updated to use HAL Processor APIs.
49 *****************************************************************************/
51 /***************************** Include Files ********************************/
54 #include "xparameters.h"
55 #include "xuartlite_i.h"
57 /************************** Constant Definitions ****************************/
60 /**************************** Type Definitions ******************************/
63 /***************** Macros (Inline Functions) Definitions ********************/
66 /************************** Variable Definitions ****************************/
69 /************************** Function Prototypes *****************************/
71 /****************************************************************************
73 * Looks up the device configuration based on the unique device ID. The table
74 * UartliteConfigTable contains the configuration info for each device in the
77 * @param DeviceId is the unique device ID to match on.
79 * @return A pointer to the configuration data for the device, or
80 * NULL if no match was found.
84 ******************************************************************************/
85 XUartLite_Config *XUartLite_LookupConfig(u16 DeviceId)
87 XUartLite_Config *CfgPtr = NULL;
90 for (Index=0; Index < XPAR_XUARTLITE_NUM_INSTANCES; Index++) {
91 if (XUartLite_ConfigTable[Index].DeviceId == DeviceId) {
92 CfgPtr = &XUartLite_ConfigTable[Index];
100 /****************************************************************************/
103 * Initialize a XUartLite instance. The receive and transmit FIFOs of the
104 * UART are not flushed, so the user may want to flush them. The hardware
105 * device does not have any way to disable the receiver such that any valid
106 * data may be present in the receive FIFO. This function disables the UART
107 * interrupt. The baudrate and format of the data are fixed in the hardware
108 * at hardware build time.
110 * @param InstancePtr is a pointer to the XUartLite instance.
111 * @param DeviceId is the unique id of the device controlled by this
112 * XUartLite instance. Passing in a device id associates the
113 * generic XUartLite instance to a specific device, as chosen by
114 * the caller or application developer.
117 * - XST_SUCCESS if everything starts up as expected.
118 * - XST_DEVICE_NOT_FOUND if the device is not found in the
119 * configuration table.
123 *****************************************************************************/
124 int XUartLite_Initialize(XUartLite *InstancePtr, u16 DeviceId)
126 XUartLite_Config *ConfigPtr;
129 * Assert validates the input arguments
131 Xil_AssertNonvoid(InstancePtr != NULL);
134 * Lookup the device configuration in the configuration table. Use this
135 * configuration info when initializing this component.
137 ConfigPtr = XUartLite_LookupConfig(DeviceId);
139 if (ConfigPtr == (XUartLite_Config *)NULL) {
140 return XST_DEVICE_NOT_FOUND;
142 return XUartLite_CfgInitialize(InstancePtr, ConfigPtr,
143 ConfigPtr->RegBaseAddr);