EDF - OnePIC MCU
v1.1.0
|
00001 00011 /**************************************************************************** 00012 Section: PIC Configuration 00013 ***************************************************************************/ 00014 #ifndef _EDF_BUS_H 00015 #define _EDF_BUS_H 00016 00040 enum i2cState 00041 { 00042 I2C_IDLE, 00043 I2C_STARTING, 00044 I2C_XMITING, 00045 I2C_RECEIVEADDR, 00046 I2C_RESTARTING, 00047 I2C_RECEIVING, 00048 I2C_ACKING, 00049 I2C_STOPPING, 00050 I2C_STOP_IN_ENQ, 00051 I2C_ERRORS 00052 }; 00053 00081 struct trb 00082 { 00083 unsigned char addr; 00084 unsigned char txLen; 00085 unsigned char rxLen; 00086 const unsigned char *txBuf; 00087 unsigned char *rxBuf; 00088 unsigned char retries; 00089 volatile unsigned char status; 00090 struct trb *next; 00091 }; 00092 00108 struct i2cBus 00109 { 00110 enum i2cState mstate; 00111 unsigned char stopLock; 00112 unsigned char bufOffset; 00113 struct trb *req; 00114 struct trb **tail; 00115 }; 00116 00117 int i2cIdle(struct i2cBus *bus); 00118 void trbEnQ(struct i2cBus *bus, struct trb *req); 00119 void I2CInit (void); 00120 #if defined(__PIC32MX__) || defined(__PICC__) 00121 void ISR_i2c(void); 00122 #endif 00123 extern struct i2cBus bus1; 00124 #endif 00125