summaryrefslogtreecommitdiffstatshomepage
path: root/tests/pyb/i2c.py
blob: c968843273a59a8587b0d17e9aa93beee83ecb56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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()