1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/stm32f1: fix i2c read for N=2 bytes

This commit is contained in:
Thomas Eichinger 2014-10-24 14:42:36 +02:00
parent 414be5257d
commit ede33a6364

View File

@ -161,7 +161,7 @@ int i2c_read_bytes(i2c_t dev, uint8_t address, char *data, int length)
DEBUG("Send Slave address and wait for ADDR == 1\n"); DEBUG("Send Slave address and wait for ADDR == 1\n");
_start(i2c, address, I2C_FLAG_READ); _start(i2c, address, I2C_FLAG_READ);
DEBUG("Set POS bit\n"); DEBUG("Set POS bit\n");
i2c->CR1 |= I2C_CR1_POS; i2c->CR1 |= (I2C_CR1_POS | I2C_CR1_ACK);
DEBUG("Crit block: Clear ADDR bit and clear ACK flag\n"); DEBUG("Crit block: Clear ADDR bit and clear ACK flag\n");
state = disableIRQ(); state = disableIRQ();
_clear_addr(i2c); _clear_addr(i2c);
@ -211,7 +211,7 @@ int i2c_read_bytes(i2c_t dev, uint8_t address, char *data, int length)
i2c->CR1 |= (I2C_CR1_STOP); i2c->CR1 |= (I2C_CR1_STOP);
restoreIRQ(state); restoreIRQ(state);
DEBUG("Read N-1 byte\n") DEBUG("Read N-1 byte\n");
data[i++] = (char)i2c->DR; data[i++] = (char)i2c->DR;
while (!(i2c->SR1 & I2C_SR1_RXNE)); while (!(i2c->SR1 & I2C_SR1_RXNE));