1 /******************************************************************************
2 * Copyright (C) 2010 - 2020 Xilinx, Inc.  All rights reserved.
3 * SPDX-License-Identifier: MIT
4 ******************************************************************************/
5 
6 /*****************************************************************************/
7 /**
8 *
9 * @file xemacps_sinit.c
10 * @addtogroup emacps_v3_11
11 * @{
12 *
13 * This file contains lookup method by device ID when success, it returns
14 * pointer to config table to be used to initialize the device.
15 *
16 * <pre>
17 * MODIFICATION HISTORY:
18 *
19 * Ver   Who  Date     Changes
20 * ----- ---- -------- -------------------------------------------------------
21 * 1.00a wsy  01/10/10 New
22 * 3.00  kvn  02/13/15 Modified code for MISRA-C:2012 compliance.
23 * </pre>
24 *
25 ******************************************************************************/
26 
27 /***************************** Include Files *********************************/
28 
29 #include "xemacps.h"
30 #include "xparameters.h"
31 
32 /************************** Constant Definitions *****************************/
33 
34 
35 /**************************** Type Definitions *******************************/
36 
37 /*************************** Variable Definitions *****************************/
38 extern XEmacPs_Config XEmacPs_ConfigTable[XPAR_XEMACPS_NUM_INSTANCES];
39 
40 /***************** Macros (Inline Functions) Definitions *********************/
41 
42 
43 /************************** Function Prototypes ******************************/
44 
45 /*****************************************************************************/
46 /**
47 * Lookup the device configuration based on the unique device ID.  The table
48 * contains the configuration info for each device in the system.
49 *
50 * @param DeviceId is the unique device ID of the device being looked up.
51 *
52 * @return
53 * A pointer to the configuration table entry corresponding to the given
54 * device ID, or NULL if no match is found.
55 *
56 ******************************************************************************/
XEmacPs_LookupConfig(u16 DeviceId)57 XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId)
58 {
59     XEmacPs_Config *CfgPtr = NULL;
60     u32 i;
61 
62     for (i = 0U; i < (u32)XPAR_XEMACPS_NUM_INSTANCES; i++) {
63         if (XEmacPs_ConfigTable[i].DeviceId == DeviceId) {
64             CfgPtr = &XEmacPs_ConfigTable[i];
65             break;
66         }
67     }
68 
69     return (XEmacPs_Config *)(CfgPtr);
70 }
71 /** @} */
72