I am trying to use a STM32F board running MicroPython as a slave device.
There does seem to be some support for it in the pyb.I2C class but it doesn't seem to have a call back for when the master request.
Without a call back the master will just get a NACK.
I2C.SLAVE callback
Re: I2C.SLAVE callback
The ACK should be implemented in C-code: when the I2C peripheral sees its address on bus, it should respond - either by bitbanging or via a dedicated I2C peripheral - with an ACK.OutoftheBOTS_ wrote:I am trying to use a STM32F board running MicroPython as a slave device.
There does seem to be some support for it in the pyb.I2C class but it doesn't seem to have a call back for when the master request.
Without a call back the master will just get a NACK.
But you still have a point: there should be a callback to allow you to reply with the data you want to supply the master.
It’s possible that it was an oversight OR it was left out because the .py callback would be too slow to reply to master; is there a timeout between address+rw and data from slave?
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: I2C.SLAVE callback
I am having a little play also with the Loboris ESP32 port. he has added some I2C Slave stuff see https://github.com/loboris/MicroPython_ ... tabuf-addr
He has a i2c.setdata(buf, addr) I assume that you store data in the buffer and then when the master requests it the underlying C code and hardware peripheral responds. I haven't made it work though
He has a i2c.setdata(buf, addr) I assume that you store data in the buffer and then when the master requests it the underlying C code and hardware peripheral responds. I haven't made it work though