SPI
— 串行外设接口总线协议(master side)¶
使用示例::(python)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # coding=utf-8
# This is a sample Python script.
from driver import SPI
print("-------------------spi test--------------------")
spi = SPI()
spi.open("SPI0")
readBuf = bytearray(3)
writeBuf = bytearray([0x9f])
print(writeBuf)
print(readBuf)
value = spi.sendRecv(writeBuf, readBuf)
print(value)
print(writeBuf)
print(readBuf)
spi.close()
print("-------------------spi test--------------------")
|
配置信息::(json)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # coding=utf-8
# This is a sample cjson file.
{
"version": "1.0.0",
"io": {
"SPI0": {
"type": "SPI",
"port": 0,
"mode": "master",
"freq": 2000000
}
},
"debugLevel": "DEBUG"
}
|