PythonExtra/tests/pyb/i2c.py
David P f365025c9c stm32: Replace master/slave with controller/peripheral in I2C and SPI.
Replace "master" with "controller" and "slave" with "peripheral" in
comments, errors, and debug messages.

Add CONTROLLER and PERIPHERAL constants to pyb.SPI and pyb.I2C classes;
retain MASTER and SLAVE constants for backward compatiblity.
2021-07-18 11:23:41 +10:00

17 lines
288 B
Python

import pyb
from pyb import I2C
# test we can correctly create by id
for bus in (-1, 0, 1):
try:
I2C(bus)
print("I2C", bus)
except ValueError:
print("ValueError", bus)
i2c = I2C(1)
i2c.init(I2C.CONTROLLER, baudrate=400000)
print(i2c.scan())
i2c.deinit()