mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 19:03:33 +08:00
fxos8701cq + fxas21002c: add support for I2C
This commit is contained in:
@@ -170,11 +170,11 @@ AK09916::check_id()
|
||||
return (AK09916_DEVICE_ID_A == deviceid);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
AK09916::write_reg(uint8_t reg, uint8_t value)
|
||||
{
|
||||
const uint8_t cmd[2] = { reg, value};
|
||||
transfer(cmd, 2, nullptr, 0);
|
||||
return transfer(cmd, 2, nullptr, 0);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -105,7 +105,7 @@ protected:
|
||||
|
||||
uint8_t read_reg(uint8_t reg);
|
||||
void read_block(uint8_t reg, uint8_t *val, uint8_t count);
|
||||
void write_reg(uint8_t reg, uint8_t value);
|
||||
int write_reg(uint8_t reg, uint8_t value);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -233,13 +233,13 @@ uint8_t LSM303AGR::read_reg(unsigned reg)
|
||||
return cmd[1];
|
||||
}
|
||||
|
||||
void LSM303AGR::write_reg(unsigned reg, uint8_t value)
|
||||
int LSM303AGR::write_reg(unsigned reg, uint8_t value)
|
||||
{
|
||||
uint8_t cmd[2];
|
||||
cmd[0] = reg | DIR_WRITE;
|
||||
cmd[1] = value;
|
||||
|
||||
transfer(cmd, nullptr, sizeof(cmd));
|
||||
return transfer(cmd, nullptr, sizeof(cmd));
|
||||
}
|
||||
|
||||
void LSM303AGR::start()
|
||||
|
||||
@@ -152,13 +152,14 @@ private:
|
||||
* @param The register to read.
|
||||
* @return The value that was read.
|
||||
*/
|
||||
uint8_t read_reg(unsigned reg);
|
||||
uint8_t read_reg(unsigned reg) override;
|
||||
|
||||
/**
|
||||
* Write a register in the LSM303AGR
|
||||
*
|
||||
* @param reg The register to write.
|
||||
* @param value The new value to write.
|
||||
* @return OK on success, negative errno otherwise.
|
||||
*/
|
||||
void write_reg(unsigned reg, uint8_t value);
|
||||
int write_reg(unsigned reg, uint8_t value) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user