diff --git a/Si4703/main.c b/Si4703/main.c index 42b9653..e17555e 100644 --- a/Si4703/main.c +++ b/Si4703/main.c @@ -95,7 +95,7 @@ void Si4703_Read(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,Si4703_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 // Si4703 read start from r0Ah register @@ -121,7 +121,7 @@ void Si4703_Write(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,Si4703_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 for (i = 2; i < 8; i++) { diff --git a/bmp180/bmp180.c b/bmp180/bmp180.c index 9acccc8..2567dbc 100644 --- a/bmp180/bmp180.c +++ b/bmp180/bmp180.c @@ -40,7 +40,7 @@ void BMP180_Reset() { uint8_t BMP180_WriteReg(uint8_t reg, uint8_t value) { I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address @@ -56,13 +56,13 @@ uint8_t BMP180_ReadReg(uint8_t reg) { uint8_t value; I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) @@ -80,13 +80,13 @@ void BMP180_ReadCalibration(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_PROM_START_ADDR); // Send calibration first register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 for (i = 0; i < BMP180_PROM_DATA_LEN-1; i++) { @@ -119,13 +119,13 @@ uint16_t BMP180_Read_UT(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_ADC_OUT_MSB_REG); // Send ADC MSB register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) @@ -168,13 +168,13 @@ uint32_t BMP180_Read_PT(uint8_t oss) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_ADC_OUT_MSB_REG); // Send ADC MSB register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) diff --git a/lm75/lm75.c b/lm75/lm75.c index c44c488..288993c 100644 --- a/lm75/lm75.c +++ b/lm75/lm75.c @@ -40,13 +40,13 @@ uint16_t LM75_ReadReg(uint8_t reg) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledgment I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) @@ -63,7 +63,7 @@ uint16_t LM75_ReadReg(uint8_t reg) { void LM75_WriteReg(uint8_t reg, uint16_t value) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledgment I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address @@ -81,13 +81,13 @@ uint8_t LM75_ReadConf(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledgment I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,LM75_REG_CONF); // Send register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 I2C_AcknowledgeConfig(I2C_PORT,DISABLE); // Disable I2C acknowledgment @@ -102,7 +102,7 @@ uint8_t LM75_ReadConf(void) { void LM75_WriteConf(uint8_t value) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledgment I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,LM75_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,LM75_REG_CONF); // Send register address diff --git a/tea5767/main.c b/tea5767/main.c index c34d21f..8028ea2 100644 --- a/tea5767/main.c +++ b/tea5767/main.c @@ -102,7 +102,7 @@ void TEA5767_write(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,TEA5767_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 @@ -120,7 +120,7 @@ void TEA5767_read(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,TEA5767_ADDR,I2C_Direction_Receiver); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 diff --git a/weather-console/bmp180.c b/weather-console/bmp180.c index 9acccc8..2567dbc 100644 --- a/weather-console/bmp180.c +++ b/weather-console/bmp180.c @@ -40,7 +40,7 @@ void BMP180_Reset() { uint8_t BMP180_WriteReg(uint8_t reg, uint8_t value) { I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address @@ -56,13 +56,13 @@ uint8_t BMP180_ReadReg(uint8_t reg) { uint8_t value; I2C_GenerateSTART(I2C_PORT,ENABLE); - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,reg); // Send register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) @@ -80,13 +80,13 @@ void BMP180_ReadCalibration(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_PROM_START_ADDR); // Send calibration first register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 for (i = 0; i < BMP180_PROM_DATA_LEN-1; i++) { @@ -119,13 +119,13 @@ uint16_t BMP180_Read_UT(void) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_ADC_OUT_MSB_REG); // Send ADC MSB register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave) @@ -168,13 +168,13 @@ uint32_t BMP180_Read_PT(uint8_t oss) { I2C_AcknowledgeConfig(I2C_PORT,ENABLE); // Enable I2C acknowledge I2C_GenerateSTART(I2C_PORT,ENABLE); // Send START condition - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Transmitter); // Send slave address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); // Wait for EV6 I2C_SendData(I2C_PORT,BMP180_ADC_OUT_MSB_REG); // Send ADC MSB register address while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_TRANSMITTED)); // Wait for EV8 I2C_GenerateSTART(I2C_PORT,ENABLE); // Send repeated START condition (aka Re-START) - while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)); // Wait for EV5 + while (I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_MODE_SELECT)==ERROR); // Wait for EV5 I2C_Send7bitAddress(I2C_PORT,BMP180_ADDR,I2C_Direction_Receiver); // Send slave address for READ while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); // Wait for EV6 while (!I2C_CheckEvent(I2C_PORT,I2C_EVENT_MASTER_BYTE_RECEIVED)); // Wait for EV7 (Byte received from slave)