linux 嵌入式 开发 lua 调试 i2c 脚本 i2c 总线

#!mntruntoolsloranprint("-- Test i2c tools --")local tmpnillocal detect_busfunction(bus) for chip0

#!/mnt/run/tools/loran

print("-- Test i2c tools --")
local tmp = nil
local detect_bus = function(bus) 

for chip = 0x0, 0x7F do
  tmp = driver.i2cdev(bus, chip)
  if tmp:init() == 0 then
	if tmp:read_byte() >= 0 then
  		print(string.format("find i2c chip device %x ack: %d", chip,tmp:read_byte()))
  	        tmp:release()
       end
  end
end
end

for bus = 0,1 do
   bus = "/dev/i2c-"..bus
   print("detect bus: "..bus)
   detect_bus(bus)
end

发布者:admin,转转请注明出处:http://www.yc00.com/web/1738080095a4022197.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信