kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Power-up BMX055 magnetometer before trying to read the ID, not tested
rodzic
03544ae16a
commit
a20c55358d
|
@ -17,9 +17,9 @@ class BMX055_ACC
|
|||
uint8_t ID; // 0x58 for BMP280, 0x60 for BME280
|
||||
|
||||
public:
|
||||
uint8_t Error; // error on the I2C bus (0=no error)
|
||||
uint8_t Error; // error on the I2C bus (0=no error)
|
||||
|
||||
uint8_t CheckID(void) // check ID
|
||||
uint8_t CheckID(void) // check ID
|
||||
{ ADDR=0;
|
||||
Error=I2C_Read(Bus, ADDR0, REG_ID, ID);
|
||||
if( (!Error) && (ID==0xFA) ) { ADDR=ADDR0; return 0; }
|
||||
|
@ -42,9 +42,9 @@ class BMX055_GYR
|
|||
uint8_t ID; // 0x58 for BMP280, 0x60 for BME280
|
||||
|
||||
public:
|
||||
uint8_t Error; // error on the I2C bus (0=no error)
|
||||
uint8_t Error; // error on the I2C bus (0=no error)
|
||||
|
||||
uint8_t CheckID(void) // check ID
|
||||
uint8_t CheckID(void) // check ID
|
||||
{ ADDR=0;
|
||||
Error=I2C_Read(Bus, ADDR0, REG_ID, ID);
|
||||
if( (!Error) && (ID==0x0F) ) { ADDR=ADDR0; return 0; }
|
||||
|
@ -61,7 +61,8 @@ class BMX055_MAG
|
|||
static const uint8_t ADDR2 = 0x12;
|
||||
static const uint8_t ADDR3 = 0x13;
|
||||
|
||||
static const uint8_t REG_ID = 0x32;
|
||||
static const uint8_t REG_ID = 0x40;
|
||||
static const uint8_t REG_PWR = 0x4B;
|
||||
|
||||
public:
|
||||
uint8_t Bus; // which I2C bus
|
||||
|
@ -71,15 +72,19 @@ class BMX055_MAG
|
|||
public:
|
||||
uint8_t Error; // error on the I2C bus (0=no error)
|
||||
|
||||
uint8_t CheckID(void) // check ID
|
||||
uint8_t CheckID(void) // power-up and check ID
|
||||
{ ADDR=0;
|
||||
Error=I2C_Read(Bus, ADDR0, REG_ID, ID);
|
||||
Error=I2C_Write(Bus, ADDR0, REG_PWR, 0x03);
|
||||
if(!Error) Error=I2C_Read(Bus, ADDR0, REG_ID, ID);
|
||||
if( (!Error) && (ID==0x32) ) { ADDR=ADDR0; return 0; }
|
||||
Error=I2C_Read(Bus, ADDR1, REG_ID, ID);
|
||||
Error=I2C_Write(Bus, ADDR1, REG_PWR, 0x03);
|
||||
if(!Error) Error=I2C_Read(Bus, ADDR1, REG_ID, ID);
|
||||
if( (!Error) && (ID==0x32) ) { ADDR=ADDR1; return 0; }
|
||||
Error=I2C_Read(Bus, ADDR2, REG_ID, ID);
|
||||
Error=I2C_Write(Bus, ADDR2, REG_PWR, 0x03);
|
||||
if(!Error) Error=I2C_Read(Bus, ADDR2, REG_ID, ID);
|
||||
if( (!Error) && (ID==0x32) ) { ADDR=ADDR2; return 0; }
|
||||
Error=I2C_Read(Bus, ADDR3, REG_ID, ID);
|
||||
Error=I2C_Write(Bus, ADDR3, REG_PWR, 0x03);
|
||||
if(!Error) Error=I2C_Read(Bus, ADDR3, REG_ID, ID);
|
||||
if( (!Error) && (ID==0x32) ) { ADDR=ADDR3; return 0; }
|
||||
return 1; } // 0 => no error and correct ID
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ static uint8_t InitIMU(void)
|
|||
{ MAG.Bus=BARO_I2C;
|
||||
ACC.Bus=BARO_I2C;
|
||||
GYR.Bus=BARO_I2C;
|
||||
uint8_t Err = MAG.CheckID(); Err<<=1;
|
||||
if(!Err) Err |= ACC.CheckID(); Err<<=1;
|
||||
if(!Err) Err |= GYR.CheckID();
|
||||
uint8_t Err = MAG.CheckID(); // Err<<=1;
|
||||
// if(!Err) Err |= ACC.CheckID(); Err<<=1;
|
||||
// if(!Err) Err |= GYR.CheckID();
|
||||
return Err; }
|
||||
|
||||
static void ProcIMU(void)
|
||||
|
|
Ładowanie…
Reference in New Issue