I2C.SLAVE callback

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

I2C.SLAVE callback

Post by OutoftheBOTS_ » Tue Jun 12, 2018 1:11 am

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.

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: I2C.SLAVE callback

Post by jickster » Wed Jun 13, 2018 2:09 am

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?


OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: I2C.SLAVE callback

Post by OutoftheBOTS_ » Wed Jun 13, 2018 3:08 am

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

Post Reply