Bug in readRegister() – Incorrect register byte count in readRegisters call
Description
While working with the TMAG5273 sensor on the Raspberry Pi Pico using your library, I encountered a communication issue which I traced back to the readRegister() function.
Problem
The current implementation reads 2 bytes from a register instead of the expected 1 byte, which leads to incorrect behavior on devices with strict I2C read handling like the Pi Pico.
uint8_t TMAG5273::readRegister(uint8_t regAddress)
{
uint8_t regVal = 0;
readRegisters(regAddress, ®Val, 2); // <-- Incorrect byte count
return regVal;
}
Fix
uint8_t TMAG5273::readRegister(uint8_t regAddress)
{
uint8_t regVal = 0;
readRegisters(regAddress, ®Val, 1); // <-- Should read only 1 byte
return regVal;
}
Impact
- Causes data corruption or bus errors on microcontrollers with strict I2C behavior
- Verified specifically on Raspberry Pi Pico (RP2040)
Please consider updating the library accordingly. Let me know if a pull request is preferred—I’d be happy to submit one.
Bug in
readRegister()– Incorrect register byte count inreadRegisterscallDescription
While working with the TMAG5273 sensor on the Raspberry Pi Pico using your library, I encountered a communication issue which I traced back to the
readRegister()function.Problem
The current implementation reads 2 bytes from a register instead of the expected 1 byte, which leads to incorrect behavior on devices with strict I2C read handling like the Pi Pico.
Fix
Impact
Please consider updating the library accordingly. Let me know if a pull request is preferred—I’d be happy to submit one.