mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 23:33:34 +08:00
mpu9250:Add modify checked register api
Provide an API for the mag to use read-modify-write
This commit is contained in:
committed by
Lorenz Meier
parent
ef67b75057
commit
270dd5282a
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user