35 #ifdef __BUILD_WITH_EXAMPLE__
36 #include "lpc17xx_libcfg.h"
67 static I2C_CFG_T i2cdat[3];
69 static uint32_t I2C_MasterComplete[3];
70 static uint32_t I2C_SlaveComplete[3];
72 static uint32_t I2C_MonitorBufferIndex;
92 static void I2C_SetClock (
LPC_I2C_TypeDef *I2Cx, uint32_t target_clock);
199 *retdat = (uint8_t) (I2Cx->
I2DAT & I2C_I2DAT_BITMASK);
212 static void I2C_SetClock (
LPC_I2C_TypeDef *I2Cx, uint32_t target_clock)
233 I2Cx->
I2SCLH = (uint32_t)(temp / 2);
288 I2C_SetClock(I2Cx, clockrate);
412 tmp = I2C_getNum(I2Cx);
417 txrx_setup->
status = returnCode;
425 if (i2cdat[tmp].dir == 0){
500 else if (i2cdat[tmp].dir == 1){
594 I2C_MasterComplete[tmp] =
TRUE;
617 tmp = I2C_getNum(I2Cx);
622 txrx_setup->
status = returnCode;
744 I2C_SlaveComplete[tmp] =
TRUE;
780 txdat = (uint8_t *) TransferCfg->
tx_data;
781 rxdat = (uint8_t *) TransferCfg->
rx_data;
793 txdat = (uint8_t *) TransferCfg->
tx_data;
794 rxdat = (uint8_t *) TransferCfg->
rx_data;
801 CodeStatus = I2C_Start(I2Cx);
807 TransferCfg->
status = CodeStatus;
818 CodeStatus = I2C_SendByte(I2Cx, (TransferCfg->
sl_addr7bit << 1));
833 CodeStatus = I2C_SendByte(I2Cx, *txdat);
854 CodeStatus = I2C_Start(I2Cx);
860 TransferCfg->
status = CodeStatus;
872 CodeStatus = I2C_SendByte(I2Cx, ((TransferCfg->
sl_addr7bit << 1) | 0x01));
894 CodeStatus = I2C_GetByte(I2Cx, &tmp, 1);
899 TransferCfg->
status = CodeStatus;
907 CodeStatus = I2C_GetByte(I2Cx, &tmp, 0);
912 TransferCfg->
status = CodeStatus;
936 tmp = I2C_getNum(I2Cx);
937 i2cdat[tmp].txrx_setup = (uint32_t) TransferCfg;
988 uint32_t CodeStatus = 0;
994 txdat = (uint8_t *) TransferCfg->
tx_data;
995 rxdat = (uint8_t *) TransferCfg->
rx_data;
1050 *rxdat++ = (uint8_t)I2Cx->
I2DAT;
1093 I2Cx->
I2DAT = *txdat++;
1120 }
else if (time_en){
1140 TransferCfg->
status = CodeStatus;
1146 tmp = I2C_getNum(I2Cx);
1147 i2cdat[tmp].txrx_setup = (uint32_t) TransferCfg;
1149 i2cdat[tmp].dir = 1;
1181 tmp = (((uint32_t)(OwnSlaveAddrConfigStruct->
SlaveAddr_7bit << 1)) \
1235 I2Cx->
MMCTRL |= MonitorCfgType;
1271 I2C_MonitorBufferIndex = 0;
1317 buffer[I2C_MonitorBufferIndex] = (uint8_t)(I2Cx->
I2DATA_BUFFER);
1318 I2C_MonitorBufferIndex++;
1319 if(I2C_MonitorBufferIndex >= size)
1337 uint32_t retval, tmp;
1338 tmp = I2C_getNum(I2Cx);
1339 retval = I2C_MasterComplete[tmp];
1340 I2C_MasterComplete[tmp] =
FALSE;
1354 uint32_t retval, tmp;
1355 tmp = I2C_getNum(I2Cx);
1356 retval = I2C_SlaveComplete[tmp];
1357 I2C_SlaveComplete[tmp] =
FALSE;