1 //*****************************************************************************
3 // i2c.h - Prototypes for the I2C Driver.
5 // Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
7 // Software License Agreement
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
10 // exclusively on LMI's Stellaris Family of microcontroller products.
12 // The software is owned by LMI and/or its suppliers, and is protected under
13 // applicable copyright laws. All rights are reserved. Any use in violation
14 // of the foregoing restrictions may subject the user to criminal sanctions
15 // under applicable laws, as well as to civil liability for the breach of the
16 // terms and conditions of this license.
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
24 // This is part of revision 991 of the Stellaris Driver Library.
26 //*****************************************************************************
36 //*****************************************************************************
38 // Defines for the API.
40 //*****************************************************************************
41 //*****************************************************************************
45 //*****************************************************************************
46 #define I2C_INT_MASTER 0x00000001
47 #define I2C_INT_SLAVE 0x00000002
49 //*****************************************************************************
51 // I2C Master commands.
53 //*****************************************************************************
54 #define I2C_MASTER_CMD_SINGLE_SEND \
55 (I2C_MASTER_CS_STOP | I2C_MASTER_CS_START | I2C_MASTER_CS_RUN)
56 #define I2C_MASTER_CMD_SINGLE_RECEIVE \
57 (I2C_MASTER_CS_STOP | I2C_MASTER_CS_START | I2C_MASTER_CS_RUN)
58 #define I2C_MASTER_CMD_BURST_SEND_START \
59 (I2C_MASTER_CS_START | I2C_MASTER_CS_RUN)
60 #define I2C_MASTER_CMD_BURST_SEND_CONT \
62 #define I2C_MASTER_CMD_BURST_SEND_FINISH \
63 (I2C_MASTER_CS_STOP | I2C_MASTER_CS_RUN)
64 #define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP \
66 #define I2C_MASTER_CMD_BURST_RECEIVE_START \
67 (I2C_MASTER_CS_ACK | I2C_MASTER_CS_START | I2C_MASTER_CS_RUN)
68 #define I2C_MASTER_CMD_BURST_RECEIVE_CONT \
69 (I2C_MASTER_CS_ACK | I2C_MASTER_CS_RUN)
70 #define I2C_MASTER_CMD_BURST_RECEIVE_FINISH \
71 (I2C_MASTER_CS_STOP | I2C_MASTER_CS_RUN)
72 #define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP \
73 (I2C_MASTER_CS_STOP | I2C_MASTER_CS_RUN)
75 //*****************************************************************************
77 // I2C Master error status.
79 //*****************************************************************************
80 #define I2C_MASTER_ERR_NONE 0
81 #define I2C_MASTER_ERR_ADDR_ACK 0x00000004
82 #define I2C_MASTER_ERR_DATA_ACK 0x00000008
83 #define I2C_MASTER_ERR_ARB_LOST 0x00000010
85 //*****************************************************************************
87 // I2C Slave action requests
89 //*****************************************************************************
90 #define I2C_SLAVE_ACT_NONE 0
91 #define I2C_SLAVE_ACT_RREQ 0x00000001 // Master has sent data
92 #define I2C_SLAVE_ACT_TREQ 0x00000002 // Master has requested data
94 //*****************************************************************************
95 // Miscellaneous I2C driver definitions.
96 //*****************************************************************************
97 #define I2C_MASTER_MAX_RETRIES 1000 // Number of retries
99 //*****************************************************************************
101 // Prototypes for the APIs.
103 //*****************************************************************************
104 extern void I2CIntRegister(unsigned long ulBase, void(fnHandler)(void));
105 extern void I2CIntUnregister(unsigned long ulBase);
106 extern tBoolean I2CMasterBusBusy(unsigned long ulBase);
107 extern tBoolean I2CMasterBusy(unsigned long ulBase);
108 extern void I2CMasterControl(unsigned long ulBase, unsigned long ulCmd);
109 extern unsigned long I2CMasterDataGet(unsigned long ulBase);
110 extern void I2CMasterDataPut(unsigned long ulBase, unsigned char ucData);
111 extern void I2CMasterDisable(unsigned long ulBase);
112 extern void I2CMasterEnable(unsigned long ulBase);
113 extern unsigned long I2CMasterErr(unsigned long ulBase);
114 extern void I2CMasterInit(unsigned long ulBase, tBoolean bFast);
115 extern void I2CMasterIntClear(unsigned long ulBase);
116 extern void I2CMasterIntDisable(unsigned long ulBase);
117 extern void I2CMasterIntEnable(unsigned long ulBase);
118 extern tBoolean I2CMasterIntStatus(unsigned long ulBase, tBoolean bMasked);
119 extern void I2CMasterSlaveAddrSet(unsigned long ulBase,
120 unsigned char ucSlaveAddr,
122 extern unsigned long I2CSlaveDataGet(unsigned long ulBase);
123 extern void I2CSlaveDataPut(unsigned long ulBase, unsigned char ucData);
124 extern void I2CSlaveDisable(unsigned long ulBase);
125 extern void I2CSlaveEnable(unsigned long ulBase);
126 extern void I2CSlaveInit(unsigned long ulBase, unsigned char ucSlaveAddr);
127 extern void I2CSlaveIntClear(unsigned long ulBase);
128 extern void I2CSlaveIntDisable(unsigned long ulBase);
129 extern void I2CSlaveIntEnable(unsigned long ulBase);
130 extern tBoolean I2CSlaveIntStatus(unsigned long ulBase, tBoolean bMasked);
131 extern unsigned long I2CSlaveStatus(unsigned long ulBase);
132 extern void I2CMasterInitExpClk(unsigned long ulBase, unsigned long ulI2CClk,