]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_LM3S811_KEIL/LuminaryCode/src/i2c.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / CORTEX_LM3S811_KEIL / LuminaryCode / src / i2c.h
1 //*****************************************************************************\r
2 //\r
3 // i2c.h - Prototypes for the I2C Driver.\r
4 //\r
5 // Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.\r
6 //\r
7 // Software License Agreement\r
8 //\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
11 //\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
17 //\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
23 //\r
24 // This is part of revision 816 of the Stellaris Driver Library.\r
25 //\r
26 //*****************************************************************************\r
27 \r
28 #ifndef __I2C_H__\r
29 #define __I2C_H__\r
30 \r
31 #ifdef __cplusplus\r
32 extern "C"\r
33 {\r
34 #endif\r
35 \r
36 //*****************************************************************************\r
37 //\r
38 // Defines for the API.\r
39 //\r
40 //*****************************************************************************\r
41 //*****************************************************************************\r
42 //\r
43 // Interrupt defines.\r
44 //\r
45 //*****************************************************************************\r
46 #define I2C_INT_MASTER          0x00000001\r
47 #define I2C_INT_SLAVE           0x00000002\r
48 \r
49 //*****************************************************************************\r
50 //\r
51 // I2C Master commands.\r
52 //\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
61             (I2C_MASTER_CS_RUN)\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
74 \r
75 //*****************************************************************************\r
76 //\r
77 // I2C Master error status.\r
78 //\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
84 \r
85 //*****************************************************************************\r
86 //\r
87 // I2C Slave action requests\r
88 //\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
93 \r
94 //*****************************************************************************\r
95 // Miscellaneous I2C driver definitions.\r
96 //*****************************************************************************\r
97 #define I2C_MASTER_MAX_RETRIES 1000        // Number of retries\r
98 \r
99 //*****************************************************************************\r
100 //\r
101 // Prototypes for the APIs.\r
102 //\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
132 \r
133 #ifdef __cplusplus\r
134 }\r
135 #endif\r
136 \r
137 #endif // __I2C_H__\r