I have the test programs where both MCUs are using Arduino but I wanted to see if I could convert the test programs to Circuitpython. The Master was easy, but I have not figured out where to start on the slave program. The master code is:
- Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
i2c = busio.I2C(board.SCL, board.SDA)
cmd = ['A', 'B', 'C', 'D']
i = 0
while True:
time.sleep(1)
while not i2c.try_lock():
pass
i2c.writeto(0x09, cmd[i])
print("byte written = ", cmd[i])
i = i + 1
if (i > 3): i=0
result = bytearray(5)
i2c.readfrom_into(0x09, result)
print("results sent back = ", result)
i2c.unlock()
The slave program basically hangs out on the I2C bus and when it gets a one byte "cmd" it replies with "hello". Both programs print to the console what they are doing so I can observe the behavior. I'm looking for the similar routine where the slave establishes it's address and just waits for a request. Not seeing that in Circuitpython.