Tiva Driver Lib
i2c.h
1 //*****************************************************************************
2 //
3 // i2c.h - Prototypes for the I2C Driver.
4 //
5 // Copyright (c) 2005-2013 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 1.1 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_I2C_H__
41 #define __DRIVERLIB_I2C_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Defines for the API.
57 //
58 //*****************************************************************************
59 
60 //*****************************************************************************
61 //
62 // Interrupt defines.
63 //
64 //*****************************************************************************
65 #define I2C_INT_MASTER 0x00000001
66 #define I2C_INT_SLAVE 0x00000002
67 
68 //*****************************************************************************
69 //
70 // I2C Master commands.
71 //
72 //*****************************************************************************
73 #define I2C_MASTER_CMD_SINGLE_SEND \
74  0x00000007
75 #define I2C_MASTER_CMD_SINGLE_RECEIVE \
76  0x00000007
77 #define I2C_MASTER_CMD_BURST_SEND_START \
78  0x00000003
79 #define I2C_MASTER_CMD_BURST_SEND_CONT \
80  0x00000001
81 #define I2C_MASTER_CMD_BURST_SEND_FINISH \
82  0x00000005
83 #define I2C_MASTER_CMD_BURST_SEND_STOP \
84  0x00000004
85 #define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP \
86  0x00000004
87 #define I2C_MASTER_CMD_BURST_RECEIVE_START \
88  0x0000000b
89 #define I2C_MASTER_CMD_BURST_RECEIVE_CONT \
90  0x00000009
91 #define I2C_MASTER_CMD_BURST_RECEIVE_FINISH \
92  0x00000005
93 #define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP \
94  0x00000004
95 #define I2C_MASTER_CMD_QUICK_COMMAND \
96  0x00000027
97 #define I2C_MASTER_CMD_HS_MASTER_CODE_SEND \
98  0x00000013
99 
100 //*****************************************************************************
101 //
102 // I2C Master error status.
103 //
104 //*****************************************************************************
105 #define I2C_MASTER_ERR_NONE 0
106 #define I2C_MASTER_ERR_ADDR_ACK 0x00000004
107 #define I2C_MASTER_ERR_DATA_ACK 0x00000008
108 #define I2C_MASTER_ERR_ARB_LOST 0x00000010
109 #define I2C_MASTER_ERR_CLK_TOUT 0x00000080
110 
111 //*****************************************************************************
112 //
113 // I2C Slave action requests
114 //
115 //*****************************************************************************
116 #define I2C_SLAVE_ACT_NONE 0
117 #define I2C_SLAVE_ACT_RREQ 0x00000001 // Master has sent data
118 #define I2C_SLAVE_ACT_TREQ 0x00000002 // Master has requested data
119 #define I2C_SLAVE_ACT_RREQ_FBR 0x00000005 // Master has sent first byte
120 #define I2C_SLAVE_ACT_OWN2SEL 0x00000008 // Master requested secondary slave
121 #define I2C_SLAVE_ACT_QCMD 0x00000010 // Master has sent a Quick Command
122 #define I2C_SLAVE_ACT_QCMD_DATA 0x00000020 // Master Quick Command value
123 
124 //*****************************************************************************
125 //
126 // Miscellaneous I2C driver definitions.
127 //
128 //*****************************************************************************
129 #define I2C_MASTER_MAX_RETRIES 1000 // Number of retries
130 
131 //*****************************************************************************
132 //
133 // I2C Master interrupts.
134 //
135 //*****************************************************************************
136 #define I2C_MASTER_INT_TIMEOUT 0x00000002 // Clock Timeout Interrupt
137 #define I2C_MASTER_INT_DATA 0x00000001 // Data Interrupt
138 
139 //*****************************************************************************
140 //
141 // I2C Slave interrupts.
142 //
143 //*****************************************************************************
144 #define I2C_SLAVE_INT_STOP 0x00000004 // Stop Condition Interrupt
145 #define I2C_SLAVE_INT_START 0x00000002 // Start Condition Interrupt
146 #define I2C_SLAVE_INT_DATA 0x00000001 // Data Interrupt
147 
148 //*****************************************************************************
149 //
150 // Prototypes for the APIs.
151 //
152 //*****************************************************************************
153 extern void I2CIntRegister(uint32_t ui32Base, void(pfnHandler)(void));
154 extern void I2CIntUnregister(uint32_t ui32Base);
155 extern bool I2CMasterBusBusy(uint32_t ui32Base);
156 extern bool I2CMasterBusy(uint32_t ui32Base);
157 extern void I2CMasterControl(uint32_t ui32Base, uint32_t ui32Cmd);
158 extern uint32_t I2CMasterDataGet(uint32_t ui32Base);
159 extern void I2CMasterDataPut(uint32_t ui32Base, uint8_t ui8Data);
160 extern void I2CMasterDisable(uint32_t ui32Base);
161 extern void I2CMasterEnable(uint32_t ui32Base);
162 extern uint32_t I2CMasterErr(uint32_t ui32Base);
163 extern void I2CMasterInitExpClk(uint32_t ui32Base, uint32_t ui32I2CClk,
164  bool bFast);
165 extern void I2CMasterIntClear(uint32_t ui32Base);
166 extern void I2CMasterIntDisable(uint32_t ui32Base);
167 extern void I2CMasterIntEnable(uint32_t ui32Base);
168 extern bool I2CMasterIntStatus(uint32_t ui32Base, bool bMasked);
169 extern void I2CMasterIntEnableEx(uint32_t ui32Base,
170  uint32_t ui32IntFlags);
171 extern void I2CMasterIntDisableEx(uint32_t ui32Base,
172  uint32_t ui32IntFlags);
173 extern uint32_t I2CMasterIntStatusEx(uint32_t ui32Base,
174  bool bMasked);
175 extern void I2CMasterIntClearEx(uint32_t ui32Base,
176  uint32_t ui32IntFlags);
177 extern void I2CMasterTimeoutSet(uint32_t ui32Base, uint32_t ui32Value);
178 extern void I2CSlaveACKOverride(uint32_t ui32Base, bool bEnable);
179 extern void I2CSlaveACKValueSet(uint32_t ui32Base, bool bACK);
180 extern uint32_t I2CMasterLineStateGet(uint32_t ui32Base);
181 extern void I2CMasterSlaveAddrSet(uint32_t ui32Base,
182  uint8_t ui8SlaveAddr,
183  bool bReceive);
184 extern uint32_t I2CSlaveDataGet(uint32_t ui32Base);
185 extern void I2CSlaveDataPut(uint32_t ui32Base, uint8_t ui8Data);
186 extern void I2CSlaveDisable(uint32_t ui32Base);
187 extern void I2CSlaveEnable(uint32_t ui32Base);
188 extern void I2CSlaveInit(uint32_t ui32Base, uint8_t ui8SlaveAddr);
189 extern void I2CSlaveAddressSet(uint32_t ui32Base, uint8_t ui8AddrNum,
190  uint8_t ui8SlaveAddr);
191 extern void I2CSlaveIntClear(uint32_t ui32Base);
192 extern void I2CSlaveIntDisable(uint32_t ui32Base);
193 extern void I2CSlaveIntEnable(uint32_t ui32Base);
194 extern void I2CSlaveIntClearEx(uint32_t ui32Base, uint32_t ui32IntFlags);
195 extern void I2CSlaveIntDisableEx(uint32_t ui32Base,
196  uint32_t ui32IntFlags);
197 extern void I2CSlaveIntEnableEx(uint32_t ui32Base, uint32_t ui32IntFlags);
198 extern bool I2CSlaveIntStatus(uint32_t ui32Base, bool bMasked);
199 extern uint32_t I2CSlaveIntStatusEx(uint32_t ui32Base,
200  bool bMasked);
201 extern uint32_t I2CSlaveStatus(uint32_t ui32Base);
202 
203 //*****************************************************************************
204 //
205 // Mark the end of the C bindings section for C++ compilers.
206 //
207 //*****************************************************************************
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif // __DRIVERLIB_I2C_H__
bool I2CMasterBusy(uint32_t ui32Base)
Definition: i2c.c:1147
void I2CSlaveAddressSet(uint32_t ui32Base, uint8_t ui8AddrNum, uint8_t ui8SlaveAddr)
Definition: i2c.c:283
void I2CMasterEnable(uint32_t ui32Base)
Definition: i2c.c:329
bool I2CMasterIntStatus(uint32_t ui32Base, bool bMasked)
Definition: i2c.c:776
bool I2CMasterBusBusy(uint32_t ui32Base)
Definition: i2c.c:1182
void I2CMasterIntDisable(uint32_t ui32Base)
Definition: i2c.c:657
void I2CMasterDisable(uint32_t ui32Base)
Definition: i2c.c:384
void I2CSlaveDataPut(uint32_t ui32Base, uint8_t ui8Data)
Definition: i2c.c:1523
uint32_t I2CSlaveStatus(uint32_t ui32Base)
Definition: i2c.c:1497
void I2CSlaveIntEnableEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:632
void I2CMasterDataPut(uint32_t ui32Base, uint8_t ui8Data)
Definition: i2c.c:1319
void I2CSlaveIntClear(uint32_t ui32Base)
Definition: i2c.c:1017
void I2CSlaveACKValueSet(uint32_t ui32Base, bool bACK)
Definition: i2c.c:1443
void I2CMasterSlaveAddrSet(uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
Definition: i2c.c:1088
void I2CMasterInitExpClk(uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast)
Definition: i2c.c:178
uint32_t I2CMasterIntStatusEx(uint32_t ui32Base, bool bMasked)
Definition: i2c.c:814
void I2CSlaveInit(uint32_t ui32Base, uint8_t ui8SlaveAddr)
Definition: i2c.c:245
void I2CSlaveIntEnable(uint32_t ui32Base)
Definition: i2c.c:594
void I2CMasterIntClear(uint32_t ui32Base)
Definition: i2c.c:934
uint32_t I2CSlaveIntStatusEx(uint32_t ui32Base, bool bMasked)
Definition: i2c.c:890
void I2CSlaveDisable(uint32_t ui32Base)
Definition: i2c.c:409
void I2CMasterTimeoutSet(uint32_t ui32Base, uint32_t ui32Value)
Definition: i2c.c:1378
void I2CMasterIntEnableEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:569
void I2CSlaveIntDisable(uint32_t ui32Base)
Definition: i2c.c:714
void I2CMasterIntEnable(uint32_t ui32Base)
Definition: i2c.c:532
void I2CMasterControl(uint32_t ui32Base, uint32_t ui32Cmd)
Definition: i2c.c:1230
uint32_t I2CMasterLineStateGet(uint32_t ui32Base)
Definition: i2c.c:1120
bool I2CSlaveIntStatus(uint32_t ui32Base, bool bMasked)
Definition: i2c.c:852
uint32_t I2CMasterErr(uint32_t ui32Base)
Definition: i2c.c:1270
uint32_t I2CSlaveDataGet(uint32_t ui32Base)
Definition: i2c.c:1549
uint32_t I2CMasterDataGet(uint32_t ui32Base)
Definition: i2c.c:1345
void I2CSlaveEnable(uint32_t ui32Base)
Definition: i2c.c:354
void I2CMasterIntDisableEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:689
void I2CMasterIntClearEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:981
void I2CSlaveACKOverride(uint32_t ui32Base, bool bEnable)
Definition: i2c.c:1408
void I2CIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: i2c.c:449
void I2CSlaveIntClearEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:1057
void I2CSlaveIntDisableEx(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: i2c.c:746
void I2CIntUnregister(uint32_t ui32Base)
Definition: i2c.c:493