mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +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:
parent
6d67d2dab2
commit
792406510c
@ -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)
|
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) {
|
if(PIOS_I2C_LockDevice(I2C_Non_Blocking) < 0) {
|
||||||
/* Request a retry */
|
/* Request a retry */
|
||||||
return -2;
|
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 */
|
/* Send I2C address and EEPROM address */
|
||||||
/* To avoid issues with litte/big endian: copy address into temporary buffer */
|
/* 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);
|
int32_t error = PIOS_I2C_Transfer(I2C_Write_WithoutStop, BMP085_I2C_ADDR, addr_buffer, 2);
|
||||||
|
|
||||||
if(!error) {
|
if(!error) {
|
||||||
error = PIOS_I2C_TransferWait();
|
error = PIOS_I2C_TransferWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now receive byte(s) */
|
/* Now receive byte(s) */
|
||||||
if(!error) {
|
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) {
|
if(!error) {
|
||||||
error = PIOS_I2C_TransferWait();
|
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];
|
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) {
|
if(!error) {
|
||||||
error = PIOS_I2C_TransferWait();
|
error = PIOS_I2C_TransferWait();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#define PIOS_BMP085_H
|
#define PIOS_BMP085_H
|
||||||
|
|
||||||
/* BMP085 Addresses */
|
/* BMP085 Addresses */
|
||||||
#define BMP085_I2C_ADDR (0xEF >> 1)
|
#define BMP085_I2C_ADDR 0xEE
|
||||||
#define BMP085_CALIB_ADDR 0xAA
|
#define BMP085_CALIB_ADDR 0xAA
|
||||||
#define BMP085_CALIB_LEN 22
|
#define BMP085_CALIB_LEN 22
|
||||||
#define BMP085_CTRL_ADDR 0xF4
|
#define BMP085_CTRL_ADDR 0xF4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user