1 //*****************************************************************************
\r
3 // i2c.h - Prototypes for the I2C Driver.
\r
5 // Copyright (c) 2005-2008 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. You may not combine
\r
14 // this software with "viral" open-source software in order to form a larger
\r
15 // program. Any use in violation of the foregoing restrictions may subject
\r
16 // the user to criminal sanctions under applicable laws, as well as to civil
\r
17 // liability for the breach of the terms and conditions of this license.
\r
19 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
20 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
22 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
23 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
25 // This is part of revision 2523 of the Stellaris Peripheral Driver Library.
\r
27 //*****************************************************************************
\r
32 //*****************************************************************************
\r
34 // If building with a C++ compiler, make all of the definitions in this header
\r
35 // have a C binding.
\r
37 //*****************************************************************************
\r
43 //*****************************************************************************
\r
45 // Defines for the API.
\r
47 //*****************************************************************************
\r
49 //*****************************************************************************
\r
51 // Interrupt defines.
\r
53 //*****************************************************************************
\r
54 #define I2C_INT_MASTER 0x00000001
\r
55 #define I2C_INT_SLAVE 0x00000002
\r
57 //*****************************************************************************
\r
59 // I2C Master commands.
\r
61 //*****************************************************************************
\r
62 #define I2C_MASTER_CMD_SINGLE_SEND 0x00000007
\r
63 #define I2C_MASTER_CMD_SINGLE_RECEIVE 0x00000007
\r
64 #define I2C_MASTER_CMD_BURST_SEND_START 0x00000003
\r
65 #define I2C_MASTER_CMD_BURST_SEND_CONT 0x00000001
\r
66 #define I2C_MASTER_CMD_BURST_SEND_FINISH 0x00000005
\r
67 #define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP 0x00000004
\r
68 #define I2C_MASTER_CMD_BURST_RECEIVE_START 0x0000000b
\r
69 #define I2C_MASTER_CMD_BURST_RECEIVE_CONT 0x00000009
\r
70 #define I2C_MASTER_CMD_BURST_RECEIVE_FINISH 0x00000005
\r
71 #define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP 0x00000005
\r
73 //*****************************************************************************
\r
75 // I2C Master error status.
\r
77 //*****************************************************************************
\r
78 #define I2C_MASTER_ERR_NONE 0
\r
79 #define I2C_MASTER_ERR_ADDR_ACK 0x00000004
\r
80 #define I2C_MASTER_ERR_DATA_ACK 0x00000008
\r
81 #define I2C_MASTER_ERR_ARB_LOST 0x00000010
\r
83 //*****************************************************************************
\r
85 // I2C Slave action requests
\r
87 //*****************************************************************************
\r
88 #define I2C_SLAVE_ACT_NONE 0
\r
89 #define I2C_SLAVE_ACT_RREQ 0x00000001 // Master has sent data
\r
90 #define I2C_SLAVE_ACT_TREQ 0x00000002 // Master has requested data
\r
91 #define I2C_SLAVE_ACT_RREQ_FBR 0x00000005 // Master has sent first byte
\r
93 //*****************************************************************************
\r
95 // Miscellaneous I2C driver definitions.
\r
97 //*****************************************************************************
\r
98 #define I2C_MASTER_MAX_RETRIES 1000 // Number of retries
\r
100 //*****************************************************************************
\r
102 // Prototypes for the APIs.
\r
104 //*****************************************************************************
\r
105 extern void I2CIntRegister(unsigned long ulBase, void(fnHandler)(void));
\r
106 extern void I2CIntUnregister(unsigned long ulBase);
\r
107 extern tBoolean I2CMasterBusBusy(unsigned long ulBase);
\r
108 extern tBoolean I2CMasterBusy(unsigned long ulBase);
\r
109 extern void I2CMasterControl(unsigned long ulBase, unsigned long ulCmd);
\r
110 extern unsigned long I2CMasterDataGet(unsigned long ulBase);
\r
111 extern void I2CMasterDataPut(unsigned long ulBase, unsigned char ucData);
\r
112 extern void I2CMasterDisable(unsigned long ulBase);
\r
113 extern void I2CMasterEnable(unsigned long ulBase);
\r
114 extern unsigned long I2CMasterErr(unsigned long ulBase);
\r
115 extern void I2CMasterInitExpClk(unsigned long ulBase, unsigned long ulI2CClk,
\r
117 extern void I2CMasterIntClear(unsigned long ulBase);
\r
118 extern void I2CMasterIntDisable(unsigned long ulBase);
\r
119 extern void I2CMasterIntEnable(unsigned long ulBase);
\r
120 extern tBoolean I2CMasterIntStatus(unsigned long ulBase, tBoolean bMasked);
\r
121 extern void I2CMasterSlaveAddrSet(unsigned long ulBase,
\r
122 unsigned char ucSlaveAddr,
\r
123 tBoolean bReceive);
\r
124 extern unsigned long I2CSlaveDataGet(unsigned long ulBase);
\r
125 extern void I2CSlaveDataPut(unsigned long ulBase, unsigned char ucData);
\r
126 extern void I2CSlaveDisable(unsigned long ulBase);
\r
127 extern void I2CSlaveEnable(unsigned long ulBase);
\r
128 extern void I2CSlaveInit(unsigned long ulBase, unsigned char ucSlaveAddr);
\r
129 extern void I2CSlaveIntClear(unsigned long ulBase);
\r
130 extern void I2CSlaveIntDisable(unsigned long ulBase);
\r
131 extern void I2CSlaveIntEnable(unsigned long ulBase);
\r
132 extern tBoolean I2CSlaveIntStatus(unsigned long ulBase, tBoolean bMasked);
\r
133 extern unsigned long I2CSlaveStatus(unsigned long ulBase);
\r
135 //*****************************************************************************
\r
137 // Several I2C APIs have been renamed, with the original function name being
\r
138 // deprecated. These defines provide backward compatibility.
\r
140 //*****************************************************************************
\r
142 #include "sysctl.h"
\r
143 #define I2CMasterInit(a, b) \
\r
144 I2CMasterInitExpClk(a, SysCtlClockGet(), b)
\r
147 //*****************************************************************************
\r
149 // Mark the end of the C bindings section for C++ compilers.
\r
151 //*****************************************************************************
\r
156 #endif // __I2C_H__
\r