Lua library for I2C for FlashAir.
Tested on FlashAir W-04 v4.00.03.
SlibI2C.lua -- Copy to somewhere in Lua's search path.
command | description |
---|---|
res = I2C:setup( frq ) | I2C interfase setup frq: Clock frequency(kHz). 45 or 100 or 189 or 400 |
res = I2C:print( sadr, str ) | I2C print data sadr: target address (7bit) str: strings for write res: Same as return value of fa.i2c() |
res = I2C:write( sadr, d1, d2, ... ) | I2C write data sadr: target address (7bit) d1, d2, ... : data for write res: Same as return value of fa.i2c() |
res, str = I2C:scan( sadr, len ) | I2C read string sadr: target address (7bit) len: length res: Same as return value of fa.i2c() str: strings |
res, d1, d2, ... = I2C:read( sadr, len ) | I2C read data sadr: target address (7bit) len: length res: Same as return value of fa.i2c() d1, d2, ... : numbers |
ret, tbl = I2C:readt( sadr, len ) | I2C read table sadr: target address (7bit) len: length res: Same as return value of fa.i2c() tbl: table of numbers |
res, str = I2C:wscan( sadr, adr, len ) | I2C read string after write address sadr: target address (7bit) adr: address len: length res: Same as return value of fa.i2c() str: strings |
res, d1, d2, ... = I2C:wread( sadr, adr, len ) | I2C read data after write adr sadr: target address (7bit) adr: address len: length res: Same as return value of fa.i2c() d1, d2, ... : numbers |
ret, tbl = I2C:wreadt( sadr, adr, len ) | I2C read table after write address sadr: target address (7bit) adr: address len: length res: Same as return value of fa.i2c() tbl: table of numbers |
res = I2C:setpio( dat ) | I2C set pio dat: write data res: Same as return value of fa.i2c() |
res, data, ctrl = I2C:getpio() | I2C get pio res, data, ctrl: Same as return value of fa.i2c() |
res, sadr = I2C:sascan( adrTbl, idAdr, id ) or res, sadr = I2C:sascan( adrTbl, idAdr, id, tryCount, waitTime ) |
I2C target address scan adrTbl: target address table idAdr: ID address id: ID data tryCount: Try count (nil for 5) waitTime: wait time[ms] (nil for 1) res: Same as return value of fa.i2c() sadr: target address or 0xFF at I2C error |