STM32G4 SMBUS goes into error state for some reason
I am using SMBus to communicate with a smart battery. After looking at the code, I decided against using the SMBUS middleware but to directly using the HAL_SMBUS_xxx calls. My STM32G491 is the host and sending read-word commands to the battery works just fine. The bit I'm confused about how to receive commands emitted by the battery itself.
I can see that the battery periodically emits a byte. The value is 0x12 and is by default NACKed. If I treat this value as the host's node address (i.e. 7-bit address 0x09) and set OwnAddress1 to 0x12, the byte is ACKed and another byte (0x14) appears on the bus about 25ms later, which is NACKed. There is another similar exchange about a second later. The error callback is called, apparently because of a timeout. The bus is now stuck in the state HAL_SMBUS_STATE_MASTER_BUSY_TX and I don't know how I'm supposed to clear this. Now sending further read-words commands fail because the bus is "busy".
I'm still looking into this but would appreciate any insight into what is going on. How do I correctly set up the SMBUS driver to receive the incoming command? What callback is supposed to be called? How do I reset the bus after an error is detected. I guess I'll have another look at the ST SMBUS "stack" now that I have the master-slave comms working properly, but this prospect does not fill me with joy.
