rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.5k stars 1.26k forks source link

I2C2 Issue - same response from sensor #858

Closed shayne243 closed 8 months ago

shayne243 commented 3 years ago

I'm using an Atlas RGB sensor connected to an STM32 board running maple 14.0.0 using I2C2. After issuing a command to the sensor using write(), I receive the expected response. However, with every successive command that I issue, I receive the same initial response despite changing the command.

For instance, if I send a command to return the device information, it does that successfully. Then, if I send a command to take a reading, it responds with the device information instead of the reading. This happens for any command I send after that.

I am sure it is not a problem with the sensor itself as I have tested it using the STMArduino core instead of maple and it worked fine as well as on an Arduino UNO.

The issue seems to be in the implementation of Wire.h / WireBase.h.

dewhisna commented 3 years ago

Try switching to WireSlave.h to pull in the alternate library and see if it makes a difference. WireSlave was designed as a replacement for Wire, only able to do both master and slave operations instead of master only. If it works, then the issue may be in the Wire library itself rather than the underlying low-level code.

shayne243 commented 3 years ago

Yes that worked. I switched to Wire_slave.h and that fixed it.

stevstrong commented 8 months ago

Seems to be resolved, so I will close this.