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