


- -- LuaTools需要PROJECT和VERSION这两个信息
- PROJECT = "helloworld"
- VERSION = "1.0.0"
-
- -- 引入必要的库文件(lua编写), 内部库不需要require
- sys = require("sys")
- local rc522 = require "rc522"
- log.info("main", "hello world")
-
- print(_VERSION)
-
- sys.taskInit(function()
- spi_rc522 = spi.setup(2,nil,0,0,8,100000,spi.MSB,1,1)
- -- spi_rc522 = spi.setup(0,nil,0,0,8,100000)
- rc522.init(2,6,7)
- wdata={0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
- while 1 do
- rc522.write_datablock(8,wdata)
- for i=0,63 do
- local a,b = rc522.read_datablock(i)
- if a then
- print("read",i,b:toHex())
- end
- end
- sys.wait(500)
-
-
- end
- end)
-
- -- 用户代码已结束---------------------------------------------
- -- 结尾总是这一句
- sys.run()
- -- sys.run()之后后面不要加任何语句!!!!!

