Skip to content

Commit

Permalink
Fixes to LSM303 DATA_READY Signal detection and configuration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
finneyj committed Sep 13, 2018
1 parent 129726e commit d3d6428
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inc/drivers/MicroBitCompass.h
Expand Up @@ -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();

/**
*
Expand Down
4 changes: 2 additions & 2 deletions source/drivers/LSM303Magnetometer.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d3d6428

Please sign in to comment.