baudrate :SCK
时钟频率。
bits :每次发送数据的长度。
parity :校验方式。
stop :停止位的长度。
关闭串口总线。
读取字符,如果指定读 n 个字节,那么最多读取 n 个字节,否则就会读取尽可能多的数据。 返回值:一个包含读入数据的字节对象。如果如果超时则返回 None
。
将 buf
中的数据写入总线。 返回值:写入的字节数,如果超时则返回 None
。
func为串口回调函数
例子
from machine import uart
def func(obj)
print(a.read)
a = UART(1, 115200) # init with given baudrate
a.init(115200, bits=8, parity=None, stop=1) # init with given parameters
a.read() # read all available characters
a.write('abc') # write the 3 characters
a.uart_callback(func)