1# use accelerometer to test i2c bus 2 3import pyb 4from pyb import I2C 5 6if not hasattr(pyb, "Accel"): 7 print("SKIP") 8 raise SystemExit 9 10accel_addr = 76 11 12pyb.Accel() # this will init the MMA for us 13 14i2c = I2C(1, I2C.MASTER, baudrate=400000) 15 16print(i2c.scan()) 17print(i2c.is_ready(accel_addr)) 18 19print(i2c.mem_read(1, accel_addr, 7, timeout=500)) 20i2c.mem_write(0, accel_addr, 0, timeout=500) 21 22i2c.send(7, addr=accel_addr) 23i2c.recv(1, addr=accel_addr) 24