X-Git-Url: https://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=common%2FI2C%2FMAX44009.c;h=8ec682d5cef1ee0cf6011d6d465be84d58921737;hp=eabcda644457f09ec8469f10c8f589e4260e8d14;hb=6aa7a2df05f4f65bf6c7260487a470798a5ed1b1;hpb=43ec5c5d9f5cb2ce698dc6f6591cde81a059bcef diff --git a/common/I2C/MAX44009.c b/common/I2C/MAX44009.c index eabcda6..8ec682d 100644 --- a/common/I2C/MAX44009.c +++ b/common/I2C/MAX44009.c @@ -38,22 +38,22 @@ #include "USI_TWI_Master.h" #include "MAX44009.h" -double MAX44009getlux() { +double MAX44009getlux(uint8_t nr) { volatile uint8_t b1,b2; - + nr=(nr<<1)&0x02f; I2c_StartCondition(); - I2c_WriteByte(0b10010100); + I2c_WriteByte(0b10010100|nr); I2c_WriteByte(0x03); I2c_StartCondition(); - I2c_WriteByte (0b10010101); + I2c_WriteByte (0b10010101|nr); b1 =I2c_ReadByte(NO_ACK); I2c_StopCondition(); I2c_StartCondition(); - I2c_WriteByte(0b10010100); + I2c_WriteByte(0b10010100|nr); I2c_WriteByte(0x04); I2c_StartCondition(); - I2c_WriteByte (0b10010101); + I2c_WriteByte (0b10010101|nr); b2 =I2c_ReadByte(NO_ACK); I2c_StopCondition(); uint8_t exponent = (b1 & 0xF0) >> 4;// upper four bits of high byte register