stm32: f0 do not send empty write on read

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
Timofey Titovets 2025-07-08 21:23:27 +02:00 committed by KevinOConnor
parent 1931b11001
commit 119d007058

View File

@ -224,6 +224,7 @@ 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;
if (reg_len) {
// Send start, address, reg // Send start, address, reg
i2c->CR2 = (I2C_CR2_START | config.addr | i2c->CR2 = (I2C_CR2_START | config.addr |
(reg_len << I2C_CR2_NBYTES_Pos)); (reg_len << I2C_CR2_NBYTES_Pos));
@ -234,6 +235,7 @@ i2c_read(struct i2c_config config, uint8_t reg_len, uint8_t *reg
i2c->TXDR = *reg++; 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 |