Fixes to LSM303 DATA_READY Signal detection and configuration

Updates to LSM303 magnetometer driver to:
  - Configure for a clean DATA_READY signal, disabling all other interrupt
    sources
  - Correct the interrupt polarity

Updates to MicroBitCompass to:
  - Define configure() as virtual, to enable applicaiton uses to correclty
    configure all magnetometers for update period.
This commit is contained in:
Joe Finney 2018-09-13 12:58:28 +01:00
parent 129726e669
commit d3d64283a7
2 changed files with 3 additions and 3 deletions

View file

@ -196,7 +196,7 @@ class MicroBitCompass : public MicroBitComponent
*
* @return MICROBIT_OK on success, MICROBIT_I2C_ERROR if the compass could not be configured.
*/
int configure();
virtual int configure();
/**
*

View file

@ -68,7 +68,7 @@ int LSM303Magnetometer::configure()
return MICROBIT_I2C_ERROR;
// Enable Data Ready interrupt, with buffering of data to avoid race conditions.
result = i2c.writeRegister(address, LSM303_CFG_REG_C_M, 0x41);
result = i2c.writeRegister(address, LSM303_CFG_REG_C_M, 0x01);
if (result != MICROBIT_OK)
return MICROBIT_I2C_ERROR;
@ -115,7 +115,7 @@ int LSM303Magnetometer::requestUpdate()
}
// Poll interrupt line from device (ACTIVE LO)
if(!int1.getDigitalValue())
if(int1.getDigitalValue())
{
uint8_t data[6];
int result;