1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Small fixes. BMP085 drivers still not working.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@246 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2010-03-04 15:41:21 +00:00 committed by gussy
parent 6d67d2dab2
commit 792406510c
2 changed files with 13 additions and 14 deletions

View File

@ -202,7 +202,7 @@ void PIOS_BMP085_GetValues(uint16_t *Pressure, uint16_t *Altitude, uint16_t *Tem
*/
int32_t PIOS_BMP085_Read(uint16_t address, uint8_t *buffer, uint8_t len)
{
/* Try to get the IIC peripheral */
/* Try to get the I2C peripheral */
if(PIOS_I2C_LockDevice(I2C_Non_Blocking) < 0) {
/* Request a retry */
return -2;
@ -210,16 +210,15 @@ int32_t PIOS_BMP085_Read(uint16_t address, uint8_t *buffer, uint8_t len)
/* Send I2C address and EEPROM address */
/* To avoid issues with litte/big endian: copy address into temporary buffer */
uint8_t addr_buffer[2] = {(uint8_t)(address>>8), (uint8_t)address};
uint8_t addr_buffer[2] = {(uint8_t)(address >> 8), (uint8_t)address};
int32_t error = PIOS_I2C_Transfer(I2C_Write_WithoutStop, BMP085_I2C_ADDR, addr_buffer, 2);
if(!error) {
error = PIOS_I2C_TransferWait();
}
/* Now receive byte(s) */
if(!error) {
error = PIOS_I2C_Transfer(I2C_Read, BMP085_I2C_ADDR, buffer, len);
error = PIOS_I2C_Transfer(I2C_Read, (BMP085_I2C_ADDR + 1), buffer, len);
}
if(!error) {
error = PIOS_I2C_TransferWait();
@ -262,7 +261,7 @@ int32_t PIOS_BMP085_Write(uint16_t address, uint8_t *buffer, uint8_t len)
WriteBuffer[i+2] = buffer[i];
}
int32_t error = PIOS_I2C_Transfer(I2C_Write, BMP085_I2C_ADDR, WriteBuffer, len+2);
int32_t error = PIOS_I2C_Transfer(I2C_Write, BMP085_I2C_ADDR, WriteBuffer, len + 2);
if(!error) {
error = PIOS_I2C_TransferWait();

View File

@ -27,15 +27,15 @@
#define PIOS_BMP085_H
/* BMP085 Addresses */
#define BMP085_I2C_ADDR (0xEF >> 1)
#define BMP085_CALIB_ADDR 0xAA
#define BMP085_CALIB_LEN 22
#define BMP085_CTRL_ADDR 0xF4
#define BMP085_OVERSAMPLING 0
#define BMP085_PRES_ADDR (0x34 + (BMP085_OVERSAMPLING << 6))
#define BMP085_TEMP_ADDR 0x2E
#define BMP085_ADC_MSB 0xF6
#define BMP085_ADC_LSB 0xF7
#define BMP085_I2C_ADDR 0xEE
#define BMP085_CALIB_ADDR 0xAA
#define BMP085_CALIB_LEN 22
#define BMP085_CTRL_ADDR 0xF4
#define BMP085_OVERSAMPLING 0
#define BMP085_PRES_ADDR (0x34 + (BMP085_OVERSAMPLING << 6))
#define BMP085_TEMP_ADDR 0x2E
#define BMP085_ADC_MSB 0xF6
#define BMP085_ADC_LSB 0xF7
#define BMP085_P0 101325
/* Local Types */