mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-09-08 16:07:51 -06:00
stm32: f0 do not send empty write on read
Some checks failed
Build test / build (push) Has been cancelled
Some checks failed
Build test / build (push) Has been cancelled
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
parent
1931b11001
commit
119d007058
1 changed files with 11 additions and 9 deletions
|
@ -224,16 +224,18 @@ i2c_read(struct i2c_config config, uint8_t reg_len, uint8_t *reg
|
||||||
uint8_t *write_orig = reg;
|
uint8_t *write_orig = reg;
|
||||||
uint8_t *read_orig = read;
|
uint8_t *read_orig = read;
|
||||||
|
|
||||||
// Send start, address, reg
|
if (reg_len) {
|
||||||
i2c->CR2 = (I2C_CR2_START | config.addr |
|
// Send start, address, reg
|
||||||
(reg_len << I2C_CR2_NBYTES_Pos));
|
i2c->CR2 = (I2C_CR2_START | config.addr |
|
||||||
while (reg_len--) {
|
(reg_len << I2C_CR2_NBYTES_Pos));
|
||||||
ret = i2c_wait(i2c, I2C_ISR_TXIS, timeout);
|
while (reg_len--) {
|
||||||
if (ret != I2C_BUS_SUCCESS)
|
ret = i2c_wait(i2c, I2C_ISR_TXIS, timeout);
|
||||||
goto abrt;
|
if (ret != I2C_BUS_SUCCESS)
|
||||||
i2c->TXDR = *reg++;
|
goto abrt;
|
||||||
|
i2c->TXDR = *reg++;
|
||||||
|
}
|
||||||
|
i2c_wait(i2c, I2C_ISR_TC, timeout);
|
||||||
}
|
}
|
||||||
i2c_wait(i2c, I2C_ISR_TC, timeout);
|
|
||||||
|
|
||||||
// send restart, read data
|
// send restart, read data
|
||||||
i2c->CR2 = (I2C_CR2_START | I2C_CR2_RD_WRN | config.addr |
|
i2c->CR2 = (I2C_CR2_START | I2C_CR2_RD_WRN | config.addr |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue