* VL530LX

* VL53L0X

* Updates

* License

* Lint
This commit is contained in:
Otto Winter
2019-10-20 17:56:57 +02:00
committed by GitHub
parent 16f42a3d03
commit 9a152e588e
8 changed files with 656 additions and 0 deletions
+20
View File
@@ -134,6 +134,24 @@ class I2CComponent : public Component {
extern uint8_t next_i2c_bus_num_;
#endif
class I2CDevice;
class I2CRegister {
public:
I2CRegister(I2CDevice *parent, uint8_t a_register) : parent_(parent), register_(a_register) {}
I2CRegister &operator=(uint8_t value);
I2CRegister &operator=(const std::vector<uint8_t> &value);
I2CRegister &operator&=(uint8_t value);
I2CRegister &operator|=(uint8_t value);
uint8_t get();
protected:
I2CDevice *parent_;
uint8_t register_;
};
/** All components doing communication on the I2C bus should subclass I2CDevice.
*
* This class stores 1. the address of the i2c device and has a helper function to allow
@@ -153,6 +171,8 @@ class I2CDevice {
/// Manually set the parent i2c bus for this device.
void set_i2c_parent(I2CComponent *parent);
I2CRegister reg(uint8_t a_register) { return {this, a_register}; }
/** Read len amount of bytes from a register into data. Optionally with a conversion time after
* writing the register value to the bus.
*