|
|
@@ -18,15 +18,44 @@ log.info("spi1",spi.SPI_1)
|
|
|
log.info("testSpiFlash.init",result)
|
|
|
local s = string.fromHex("9f000000000000")
|
|
|
|
|
|
+--SPI收发字节
|
|
|
+-- function drv_spi_read_write_byte(txDat)
|
|
|
+-- -- local ret = spi.send_recv(spi.SPI_1,txDat)
|
|
|
+-- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,s):toHex())--收发读写
|
|
|
+-- end
|
|
|
+
|
|
|
+-- function SX126xWriteRegisters(address,buffer,size)
|
|
|
+-- local command = string.fromHex("0D071400000000")
|
|
|
+-- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,s):toHex())--收发读写
|
|
|
+-- -- drv_spi_read_write_byte(0x0D)
|
|
|
+-- -- drv_spi_read_write_byte(( address & 0xFF00 ) >> 8 );
|
|
|
+-- -- drv_spi_read_write_byte(address & 0x00FF );
|
|
|
+-- end
|
|
|
+
|
|
|
sys.taskInit(function ()
|
|
|
sys.wait(5000)
|
|
|
while true do
|
|
|
- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,s):toHex())--收发读写
|
|
|
+ log.info("send start")--收发读写
|
|
|
+ local command = string.fromHex("1D0740000000")
|
|
|
+ log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,command):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,string.fromHex("1D")):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,string.fromHex("07")):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,string.fromHex("40")):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,string.fromHex("00")):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,string.fromHex("00")):toHex())--收发读写
|
|
|
+ -- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0x0d)))--发数据
|
|
|
+ -- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0x07)))--发数据
|
|
|
+ -- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0x14)))--发数据
|
|
|
+ -- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0xff)))--发数据
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.recv(spi.SPI_1,2):toHex())--收数据
|
|
|
+
|
|
|
+ log.info("send end")--收发读写
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,s):toHex())--收发读写
|
|
|
|
|
|
- --下面方法和上面的等价
|
|
|
- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0x9f)))--发数据
|
|
|
- log.info("testSpiFlash.readFlashID",spi.recv(spi.SPI_1,6):toHex())--收数据
|
|
|
- sys.wait(200)
|
|
|
+ -- --下面方法和上面的等价
|
|
|
+ -- log.info("testSpiFlash.sendCommand",spi.send(spi.SPI_1,string.char(0x9f)))--发数据
|
|
|
+ -- log.info("testSpiFlash.readFlashID",spi.recv(spi.SPI_1,6):toHex())--收数据
|
|
|
+ sys.wait(2000)
|
|
|
end
|
|
|
spi.close(spi.SPI_1)
|
|
|
end)
|