34 #elif( defined NANO54415 ) 35 #include <multichanneli2c.h> 38 #warning I2C features not supported for this platform 46 #define I2C_LOW_ADDR_LIMIT (0x07) 47 #define I2C_HIGH_ADDR_LIMIT (0x78) 49 #define I2C_MAX_BUF_SIZE (64) // Size allocated to input and output buffers in slave mode I2C 50 #define I2C_SLAVE_TX_TERM_CHAR (0) // Terminating char to be sent when Slave TX buffer is empty 51 #define NB_FACTORY_I2C_ERR_VALUE (0) // Error value if there is a failure to extract webpage form data 55 #define I2C_RX_TX_TIMEOUT (5) // Ticks allowed before timeout of a single byte transmission 56 #define I2C_START_TIMEOUT (20) // Ticks allowed before timeout when attempting start on I2C bus 58 #define MAX_WRITE_LEN (128) 59 #define MAX_READ_LEN (128) 61 #define MAX_BUFFER_LEN ((MAX_WRITE_LEN > MAX_READ_LEN)? MAX_WRITE_LEN*2 : MAX_READ_LEN*2) 62 #define MAX_I2C_DEVICES (128) 65 #define I2C_OK ( 0 ) // Last instruction terminated correctly 66 #define I2C_NEXT_WRITE_OK ( 1 ) // I2C bus is OK for a write 67 #define I2C_NEXT_READ_OK ( 2 ) // I2C bus is OK for a read 68 #define I2C_MASTER_OK ( 3 ) // I2C finished transmission but still owns but (need to stop or restart) 69 #define I2C_TIMEOUT ( 4 ) // A timeout occurred while trying communicate on I2C bus 70 #define I2C_BUS_NOT_AVAIL ( 5 ) // A timeout occurred while trying gain I2C bus control 71 #define I2C_NOT_READY ( 6 ) // A read or write was attempted before I2C ready or during a slave transmission 72 #define I2C_LOST_ARB ( 7 ) // Lost arbitration during start 73 #define I2C_LOST_ARB_ADD ( 8 ) // Lost arbitration and then winner addressed our slave address 74 #define I2C_NO_LINK_RX_ACK ( 9 ) // We are in Master TX mode and received no ACK from slave device, possibly during start 79 #define SB70LC_DIVIDER_COUNT (35) 82 struct ModuleI2CAddress_Struct
84 unsigned char byteAddress;
85 unsigned char asciiAddress[3];
95 struct I2CParam_Struct
98 char asciiData[MAX_BUFFER_LEN];
100 unsigned char byteAddress;
101 unsigned char byteData;
102 unsigned char byteBuffer[MAX_BUFFER_LEN];
107 struct I2CWebFuncs_Struct
109 I2CParam_Struct WriteReadByteParams;
110 I2CParam_Struct WriteReadBufferParams;
111 I2CParam_Struct WriteByteParams;
112 I2CParam_Struct ReadByteParams;
113 I2CParam_Struct WriteBufferParams;
114 I2CParam_Struct ReadBufferParams;
118 struct SerialParams_Struct
121 unsigned char buf[3];
122 unsigned char byteData;
123 unsigned char length;
125 unsigned char byteToWrite;
126 unsigned char commBuffer[MAX_BUFFER_LEN];
129 struct I2CBusStatus_Struct
132 const char* statusMsgs[12];
139 #if ( defined MCF5270 || defined MCF5234 || defined MCF5208 ) 140 void InitI2C(
unsigned char slave_Addr = 0x08,
unsigned char freqdiv = 0x16 );
141 #elif ( defined MCF5213 || defined MCF5282 ) 142 void InitI2C(
unsigned char slave_Addr = 0x08,
unsigned char freqdiv = 0x15 );
143 #elif ( defined MCF52234 ) 144 void InitI2C(
unsigned char slave_Addr = 0x08,
unsigned char freqdiv = 0x37 );
145 #elif (defined MCF5441X) 146 void InitI2C (
unsigned char slave_Addr = 0x08,
unsigned char freqdiv = 0x3C );
148 #error Multi_I2CInit declaration missing for defined platform 152 unsigned char Ascii2Byte(
char* buf );
153 unsigned char I2CReadBuffer(
unsigned char addr,
unsigned char *buf,
int num,
bool stop =
true);
154 unsigned char I2CReadByte(
unsigned char address,
unsigned char *val);
155 unsigned char I2CStopBus();
156 int I2CScan(
bool* discovered,
unsigned char slaveAddress,
unsigned char ic = 0x16);
158 unsigned char I2CWriteBuffer(
unsigned char address,
unsigned char *buf,
int num,
bool stop);
159 unsigned char I2CWriteByte(
unsigned char address,
unsigned char val,
unsigned long ticksToWait = 5);
160 unsigned char I2CWriteReadBuffer(
unsigned char address,
unsigned char writeVal,
unsigned char *readBuffer,
int length);
161 unsigned char I2CWriteReadByte(
unsigned char address,
unsigned char &data,
unsigned char *buffer);
167 #endif // __cplusplus 168 #endif // _I2CFUNCS_H_