Page 1 of 1
I2C.SLAVE callback
Posted: Tue Jun 12, 2018 1:11 am
by OutoftheBOTS_
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.
Re: I2C.SLAVE callback
Posted: Wed Jun 13, 2018 2:09 am
by jickster
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.
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.
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?
Re: I2C.SLAVE callback
Posted: Wed Jun 13, 2018 3:08 am
by OutoftheBOTS_
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