Hi,
can someone cast an eye over my picaxe conversion code and see if I,m getting this right? It will be for a BMP085 I2C pressure sensor I have on order.
and I think it converts to :
The datasheet for the sensor is here :
http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf
Cheers
T.
can someone cast an eye over my picaxe conversion code and see if I,m getting this right? It will be for a BMP085 I2C pressure sensor I have on order.
Code:
long bmp085ReadTemp(void)
{
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(BMP085_W); // write 0xEE
i2cWaitForComplete();
i2cSendByte(0xF4); // write register address
i2cWaitForComplete();
i2cSendByte(0x2E); // write register data for temp
i2cWaitForComplete();
i2cSendStop();
delay_ms(10); // max time is 4.5ms
return (long) bmp085ReadShort(0xF6);
}
short bmp085ReadShort(unsigned char address)
{
char msb, lsb;
short data;
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(BMP085_W); // write 0xEE
i2cWaitForComplete();
i2cSendByte(address); // write register address
i2cWaitForComplete();
i2cSendStart();
i2cSendByte(BMP085_R); // write 0xEF
i2cWaitForComplete();
i2cReceiveByte(TRUE);
i2cWaitForComplete();
msb = i2cGetReceivedByte(); // Get MSB result
i2cWaitForComplete();
i2cReceiveByte(FALSE);
i2cWaitForComplete();
lsb = i2cGetReceivedByte(); // Get LSB result
i2cWaitForComplete();
i2cSendStop();
data = msb << 8;
data |= lsb;
return data;
}
Code:
hi2csetup i2cmaster, 101110, i2cslow_8, i2cbyte ; set up bmp085 i2c device
.
.
.
readtemp:
;word read returned in b3,b2 (w1)
hi2cout $F4,($2E)
hi2cin $F6,(b3,b2)
return
http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf
Cheers
T.