mpu9250:Add modify checked register api

Provide an API for the mag to use read-modify-write
This commit is contained in:
David Sidrane
2017-07-08 15:37:46 +02:00
committed by Lorenz Meier
parent ef67b75057
commit 270dd5282a
2 changed files with 22 additions and 0 deletions
+11
View File
@@ -1013,6 +1013,17 @@ MPU9250::modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
write_reg(reg, val);
}
void
MPU9250::modify_checked_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
{
uint8_t val;
val = read_reg(reg);
val &= ~clearbits;
val |= setbits;
write_checked_reg(reg, val);
}
void
MPU9250::write_checked_reg(unsigned reg, uint8_t value)
{
+11
View File
@@ -462,6 +462,17 @@ private:
*/
void write_checked_reg(unsigned reg, uint8_t value);
/**
* Modify a checked register in the mpu
*
* Bits are cleared before bits are set.
*
* @param reg The register to modify.
* @param clearbits Bits in the register to clear.
* @param setbits Bits in the register to set.
*/
void modify_checked_reg(unsigned reg, uint8_t clearbits, uint8_t setbits);
/**
* Set the mpu measurement range.
*