summaryrefslogtreecommitdiffstatshomepage
path: root/tests/ports/stm32/i2c.py
blob: 7e7fd25040880c4c9a5b8e11156161aeb6ff5c94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
try:
    from pyb import I2C
except ImportError:
    print("SKIP")
    raise SystemExit

# 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()