Skip to content

Commit

Permalink
mgos_i2c_setbits_reg_w endianness bug - byte are exchanged each time …
Browse files Browse the repository at this point in the history
…the function is called on little-endian cpus
  • Loading branch information
mac-michael committed Jan 9, 2020
1 parent 4bf5e87 commit 749b01c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/mgos_i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ bool mgos_i2c_setbits_reg_w(struct mgos_i2c *i2c, uint16_t addr, uint8_t reg,
new = old | (((1 << bitlen) - 1) << bitoffset);
new &= ~(((1 << bitlen) - 1) << bitoffset);
new |= (value) << bitoffset;
d[0] = new << 8;
d[1] = new & 0xFF;

return mgos_i2c_write_reg_n(i2c, addr, reg, 2, (uint8_t *) &new);

return mgos_i2c_write_reg_w(i2c, addr, reg, new);
}

bool mgos_i2c_getbits_reg_w(struct mgos_i2c *i2c, uint16_t addr, uint8_t reg,
Expand Down

0 comments on commit 749b01c

Please sign in to comment.