1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

cpu/stm32: Fix 16 bit reg endianess for i2c_1

Since i2c_1 i2c_write_regs is cpu specific reg endianess must be swapped there
Change reg from little endian to big endian
This commit is contained in:
MrKevinWeiss 2019-08-16 15:04:13 +02:00
parent 3e753834e7
commit b0c05431f7

View File

@ -37,6 +37,7 @@
#include "cpu.h"
#include "mutex.h"
#include "byteorder.h"
#include "cpu_conf_stm32_common.h"
@ -169,6 +170,10 @@ int i2c_write_regs(i2c_t dev, uint16_t addr, uint16_t reg,
if (i2c->ISR & I2C_ISR_BUSY) {
return -EAGAIN;
}
/* Handle endianess of register if 16 bit */
if (flags & I2C_REG16) {
reg = htons(reg); /* Make sure register is in big-endian on I2C bus */
}
/* First set ADDR and register with no stop */
/* No RELOAD should be set so repeated start is valid */
int ret = _write(i2c, addr, &reg, (flags & I2C_REG16) ? 2 : 1,