最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

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

业界 admin 6浏览 0评论
#!/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

#!/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

发布评论

评论列表 (0)

  1. 暂无评论