|
使用I2C:
- from pyb import I2C
- i2c = I2C(1) # create on bus 1
- i2c = I2C(1, I2C.MASTER) # create and init as a master
- i2c.init(I2C.MASTER, baudrate=20000) # init as a master
- i2c.init(I2C.SLAVE, addr=0x42) # init as a slave with given address
- i2c.deinit() # turn off the peripheral
复制代码- i2c.send('abc') # send 3 bytes
- i2c.send(0x42) # send a single byte, given by the number
- data = i2c.recv(3) # receive 3 bytes
复制代码
内嵌汇编
- @micropython.asm_thumb
- def fun():
- movw(r0, 42)
复制代码
点亮LED
- @micropython.asm_thumb
- def led_on():
- movwt(r0, stm.GPIOA)
- movw(r1, 1 << 13)
- strh(r1, [r0, stm.GPIO_BSRRL])
复制代码
|
|