Pimoroni I2C: Add reg_write_uint16.

pull/931/head
Phil Howard 2023-07-25 12:19:12 +01:00
rodzic f1ea35fbbf
commit 6e71a62c65
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -40,6 +40,15 @@ namespace pimoroni {
i2c_write_blocking(i2c, address, buffer, 2, false);
}
void I2C::reg_write_uint16(uint8_t address, uint8_t reg, uint16_t value) {
uint8_t buffer[3] = {
reg,
(uint8_t)((value & 0xff00) >> 8),
(uint8_t)(value & 0x00ff)
};
i2c_write_blocking(i2c, address, buffer, 3, false);
}
uint8_t I2C::reg_read_uint8(uint8_t address, uint8_t reg) {
uint8_t value;
i2c_write_blocking(i2c, address, &reg, 1, false);

Wyświetl plik

@ -63,6 +63,7 @@ namespace pimoroni {
i2c_inst_t* pin_to_inst(uint pin);
void reg_write_uint8(uint8_t address, uint8_t reg, uint8_t value);
void reg_write_uint16(uint8_t address, uint8_t reg, uint16_t value);
uint8_t reg_read_uint8(uint8_t address, uint8_t reg);
uint16_t reg_read_uint16(uint8_t address, uint8_t reg);
int16_t reg_read_int16(uint8_t address, uint8_t reg);