OpenCores
URL https://opencores.org/ocsvn/xenie/xenie/trunk

Subversion Repositories xenie

[/] [xenie/] [trunk/] [examples/] [Eth_example/] [mb_fw/] [drivers/] [iic_v3_4/] [examples/] [xiic_selftest_example.c] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 DFC
/******************************************************************************
2
*
3
* Copyright (C) 2002 - 2014 Xilinx, Inc.  All rights reserved.
4
*
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:
11
*
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
14
*
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.
18
*
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
25
* SOFTWARE.
26
*
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.
30
*
31
******************************************************************************/
32
/******************************************************************************/
33
/**
34
* @file xiic_selftest_example.c
35
*
36
* This file contains a example for using the IIC hardware device and
37
* XIic driver.
38
*
39
* @note
40
*
41
* None
42
*
43
* <pre>
44
* MODIFICATION HISTORY:
45
*
46
* Ver   Who  Date        Changes
47
* ----- ---- -------- -----------------------------------------------
48
* 1.00a sv   05/09/05 Initial release for TestApp integration.
49
* 2.00a sdm  09/22/09 Updated to use the HAL APIs, replaced call to
50
*                     XIic_Initialize API with XIic_LookupConfig and
51
*                     XIic_CfgInitialize. Minor changes made as per
52
*                     coding guidelines.
53
* </pre>
54
*
55
*******************************************************************************/
56
 
57
#include "xparameters.h"
58
#include "xiic.h"
59
 
60
/************************** Constant Definitions ******************************/
61
 
62
/*
63
 * The following constants map to the XPAR parameters created in the
64
 * xparameters.h file. They are defined here such that a user can easily
65
 * change all the needed parameters in one place.
66
 */
67
#ifndef TESTAPP_GEN
68
#define IIC_DEVICE_ID      XPAR_IIC_0_DEVICE_ID
69
#endif
70
 
71
/**************************** Type Definitions ********************************/
72
 
73
 
74
/***************** Macros (Inline Functions) Definitions **********************/
75
 
76
 
77
/************************** Function Prototypes *******************************/
78
 
79
int IicSelfTestExample(u16 DeviceId);
80
 
81
/************************** Variable Definitions ******************************/
82
 
83
/*
84
 * The following are declared globally so they are zeroed and so they are
85
 * easily accessible from a debugger.
86
 */
87
XIic Iic; /* The driver instance for IIC Device */
88
 
89
 
90
/******************************************************************************/
91
/**
92
* Main function to call the example. This function is not included if the
93
* example is generated from the TestAppGen test tool.
94
*
95
* @param        None.
96
*
97
* @return       XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
98
*
99
* @note         None.
100
*
101
******************************************************************************/
102
#ifndef TESTAPP_GEN
103
int main(void)
104
{
105
        int Status;
106
 
107
        /*
108
         * Run the example, specify the device ID that is generated in
109
         * xparameters.h.
110
         */
111
        Status = IicSelfTestExample(IIC_DEVICE_ID);
112
        if (Status != XST_SUCCESS) {
113
                return XST_FAILURE;
114
        }
115
 
116
        return XST_SUCCESS;
117
 
118
}
119
#endif
120
 
121
/*****************************************************************************/
122
/**
123
*
124
* This function does a selftest on the IIC device and XIic driver as an
125
* example.
126
*
127
* @param        DeviceId is the XPAR_<IIC_instance>_DEVICE_ID value from
128
*               xparameters.h.
129
*
130
* @return       XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
131
*
132
* @note         None.
133
*
134
****************************************************************************/
135
int IicSelfTestExample(u16 DeviceId)
136
{
137
        int Status;
138
        XIic_Config *ConfigPtr; /* Pointer to configuration data */
139
 
140
        /*
141
         * Initialize the IIC driver so that it is ready to use.
142
         */
143
        ConfigPtr = XIic_LookupConfig(DeviceId);
144
        if (ConfigPtr == NULL) {
145
                return XST_FAILURE;
146
        }
147
 
148
        Status = XIic_CfgInitialize(&Iic, ConfigPtr, ConfigPtr->BaseAddress);
149
        if (Status != XST_SUCCESS) {
150
                return XST_FAILURE;
151
        }
152
 
153
 
154
        /*
155
         * Perform a self-test to ensure that the hardware was built
156
         * correctly.
157
         */
158
        Status = XIic_SelfTest(&Iic);
159
        if (Status != XST_SUCCESS) {
160
                return XST_FAILURE;
161
        }
162
 
163
        return XST_SUCCESS;
164
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.