admin 管理员组

文章数量: 887021

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

本文标签: 总线 嵌入式 脚本 Linux i2c