ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_i2c_data.c
1 /*
2  *****************************************************************************
3  * @file: adi_i2c_data.c
4  * @brief: Data declaration for I2C Device Driver
5  *****************************************************************************
6 
7 Copyright (c) 2016 Analog Devices, Inc.
8 
9 All rights reserved.
10 
11 Redistribution and use in source and binary forms, with or without modification,
12 are permitted provided that the following conditions are met:
13  - Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  - Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  - Modified versions of the software must be coni2ccuously marked as such.
19  - This software is licensed solely and exclusively for use with processors
20  manufactured by or for Analog Devices, Inc.
21  - This software may not be combined or merged with other code in any manner
22  that would cause the software to become subject to terms and conditions
23  which differ from those listed here.
24  - Neither the name of Analog Devices, Inc. nor the names of its
25  contributors may be used to endorse or promote products derived
26  from this software without specific prior written permission.
27  - The use of this software may or may not infringe the patent rights of one
28  or more patent holders. This license does not release you from the
29  requirement that you obtain separate licenses from these patent holders
30  to use this software.
31 
32 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS"
33 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-
34 INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE
36 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
37 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF
38 CLAIMS OF INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF
39 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
41 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 POSSIBILITY OF SUCH DAMAGE.
44 
45 *****************************************************************************/
46 
47 #ifndef ADI_I2C_DATA_C
48 #define ADI_I2C_DATA_C
49 
52 #include "adi_i2c_def.h"
53 #include "adi_i2c_config.h"
54 
55 
56 /* Stores the information about the specific device */
57 static ADI_I2C_DEVICE_INFO i2c_device_info [ADI_I2C_NUM_INSTANCES] =
58 {
59  /* fixed instance data for the singular I2C0 controller */
60  {
61  I2C_MST_EVT_IRQn, /* pio interrupt number */
62  (ADI_I2C_TypeDef *)pADI_I2C0, /* i2c controller pointer */
63  NULL, /* pointer to user config data */
64  NULL /* i2c device handle (user mem) */
65  },
66 
67  /* no other i2c instances at this time */
68 };
69 
70 /* build I2C Application configuration array */
71 static ADI_I2C_CONFIG gConfigInfo[ADI_I2C_NUM_INSTANCES] =
72 {
73  /* the one-and-only (so far) instance data for I2C, I2C0... */
74  {
75  /**** I2C_MCTL Master Control register *** */
76  (
77  /* note: Master IENMTX and IENMRX (transmit and receive interrupts) are managed dynamically */
78  ( ADI_I2C_CFG_MCTL_MXMITDEC << BITP_I2C_MCTL_MXMITDEC ) |
79  ( ADI_I2C_CFG_MCTL_IENCMP << BITP_I2C_MCTL_IENCMP ) |
80  ( ADI_I2C_CFG_MCTL_IENACK << BITP_I2C_MCTL_IENACK ) |
81  ( ADI_I2C_CFG_MCTL_IENALOST << BITP_I2C_MCTL_IENALOST ) |
82  ( ADI_I2C_CFG_MCTL_STRETCHSCL << BITP_I2C_MCTL_STRETCHSCL ) |
83  ( ADI_I2C_CFG_MCTL_LOOPBACK << BITP_I2C_MCTL_LOOPBACK ) |
84  ( ADI_I2C_CFG_MCTL_COMPLETE << BITP_I2C_MCTL_COMPLETE ) |
85  ( ADI_I2C_CFG_MCTL_MASEN << BITP_I2C_MCTL_MASEN )
86  ),
87 
88  /**** I2C_DIV Clock Divider register *** */
89  (
90  ( ADI_I2C_CFG_DIV_HIGH << BITP_I2C_DIV_HIGH ) |
91  ( ADI_I2C_CFG_DIV_LOW << BITP_I2C_DIV_LOW )
92  ),
93 
94  /**** I2C_SHCTL Shared Control register *** */
95  (
96  ( ADI_I2C_CFG_SHCTL_RST << BITP_I2C_TCTL_FILTEROFF )
97  ),
98 
99  /**** I2C_TCTL Timing control register *** */
100  (
101  ( ADI_I2C_CFG_TCTL_FILTEROFF << BITP_I2C_SHCTL_RST ) |
102  ( ADI_I2C_CFG_TCTL_THDATIN << BITP_I2C_TCTL_THDATIN )
103  ),
104 
105  /**** I2C_ASTRETCH Master Clock Stretch register *** */
106  (
107  ( ADI_I2C_CFG_ASTRETCH_MST << BITP_I2C_ASTRETCH_SCL_MST )
108  ),
109 
110  /**** Target Slave configuration value (not a register) *** */
111  (
113  ),
114  }
115 };
116 
120 #endif /* ADI_I2C_DATA_C */
#define ADI_I2C_CFG_MCTL_COMPLETE
#define ADI_I2C_CFG_MCTL_STRETCHSCL
#define ADI_I2C_CFG_ASTRETCH_MST
#define ADI_I2C_CFG_TCTL_FILTEROFF
#define ADI_I2C_CFG_SHCTL_RST
#define ADI_I2C_CFG_MCTL_IENCMP
#define ADI_I2C_CFG_MCTL_MXMITDEC
#define ADI_I2C_CFG_SLAVE_ADDRESS
#define ADI_I2C_CFG_DIV_HIGH
#define ADI_I2C_CFG_MCTL_IENALOST
#define ADI_I2C_CFG_MCTL_MASEN
#define ADI_I2C_CFG_MCTL_IENACK
#define ADI_I2C_CFG_MCTL_LOOPBACK
#define ADI_I2C_CFG_TCTL_THDATIN
#define ADI_I2C_CFG_DIV_LOW