I2c optimization and features (#321)

* custom delay
* Update comment
* add bus control status, add some missing include & fixed display output on sh1104 (#319)
* add some missing include
* Fixed display on SH1106
* Fix comment, add force sytem, rework flag, 16 bits data transfert
* Update all library with new I2C API
* custom delay
* Update comment, add bus control status
* fix i2c read + fix ds3231 temp + fix ssd1306 send
This commit is contained in:
Zaltora 2017-03-21 07:41:47 +01:00 committed by Ruslan V. Uss
parent 1575bac0c7
commit 813477aa8a
19 changed files with 418 additions and 335 deletions

View file

@ -54,14 +54,13 @@ static hmc5883l_operating_mode_t current_mode;
static inline void write_register(uint8_t reg, uint8_t val)
{
uint8_t buf[2] = { reg, val };
i2c_slave_write(ADDR, buf, 2);
i2c_slave_write(ADDR, &reg, &val, 1);
}
static inline uint8_t read_register(uint8_t reg)
{
uint8_t res;
i2c_slave_read(ADDR, reg, &res, 1);
i2c_slave_read(ADDR, &reg, &res, 1);
return res;
}
@ -82,7 +81,8 @@ bool hmc5883l_init()
uint32_t hmc5883l_get_id()
{
uint32_t res = 0;
i2c_slave_read(ADDR, REG_ID_A, (uint8_t *)&res, 3);
uint8_t reg = REG_ID_A;
i2c_slave_read(ADDR, &reg, (uint8_t *)&res, 3);
return res;
}
@ -164,7 +164,8 @@ bool hmc5883l_get_raw_data(hmc5883l_raw_data_t *data)
}
}
uint8_t buf[6];
i2c_slave_read(ADDR, REG_DX_H, buf, 6);
uint8_t reg = REG_DX_H;
i2c_slave_read(ADDR, &reg, buf, 6);
data->x = ((int16_t)buf[REG_DX_H - REG_DX_H] << 8) | buf[REG_DX_L - REG_DX_H];
data->y = ((int16_t)buf[REG_DY_H - REG_DX_H] << 8) | buf[REG_DY_L - REG_DX_H];
data->z = ((int16_t)buf[REG_DZ_H - REG_DX_H] << 8) | buf[REG_DZ_L - REG_DX_H];