i2c-ftdi-d2xx
v0.6.9
Published
i2c protocol implementation with ftdi-d2xx on standard boards that features no level translators on SDA and SCL
Downloads
565
Readme
Installation
npm install --save i2c-ftdi-d2xx
Basic Usage
const ftdi = require("i2c-ftdi-d2xx");
const devices = await ftdi.list();
await ftdi.open({serial_number: devices[0]});
const SLAVE = ANY_NUMBER;
const TARGET = ANY_NUMBER;
const DATA = ANY_NUMBER;
let res;
res = await read({slave: SLAVE, target: TARGET});
res = await write({slave: SLAVE, target: TARGET, data: DATA});
ftdi.close()
Burst usage
const ftdi = require("i2c-ftdi-d2xx");
const devices = await ftdi.list();
await ftdi.open({serial_number: devices[0]});
const SLAVE = ANY_NUMBER;
const TARGET = ANY_NUMBER;
const N = ANY_NUMBER;
const DATA = [ANY_NUMBER, ANY_NUMBER];
let res;
res = await read({slave: SLAVE, target: TARGET, n:N});
res = await write({slave: SLAVE, target: TARGET, data: DATA});
ftdi.close()
Field/Register Based Usage
const ftdi = require("i2c-ftdi-d2xx");
const devices = await ftdi.list();
await ftdi.open({serial_number: devices[0]});
await ftdi.setRegisterMap({registerMap: VALID_REGISTER_MAP})
const SLAVE = ANY_NUMBER;
const TARGET_REGISTER = VALID_REGISTER_NAME;
const TARGET_FIELD = VALID_FIELD_NAME;
const DATA = ANY_NUMBER;
let res;
res = await read({slave: SLAVE, target: TARGET_REGISTER});
res = await write({slave: SLAVE, target: TARGET_REGISTER, data: DATA});
res = await read({slave: SLAVE, target: TARGET_FIELD});
res = await write({slave: SLAVE, target: TARGET_FIELD, data: DATA});
ftdi.close()
Advanced Usage
const ftdi = require("i2c-ftdi-d2xx");
const devices = await ftdi.list();
await ftdi.open({serial_number: devices[0]});
const SLAVE = ANY_NUMBER;
const READ_TARGET = [ANY_NUMBER, VALID_REGISTER_NAME, VALID_FIELD_NAME];
const WRITE_TARGET = {ANY_NUMBER: ANY_NUMBER, VALID_REGISTER_NAME: ANY_NUMBER, VALID_FIELD_NAME: ANY_NUMBER};
await ftdi.setRegisterMap({registerMap: VALID_REGISTER_MAP})
let res;
res = await read({slave: SLAVE, target: READ_TARGET});
res = await write({slave: SLAVE, target: WRITE_TARGET});
ftdi.close()
License
Distributed under the TheUnlicense License. See LICENSE.txt
for more information.
Development
TODO
Publish
npm version patch|minor|major npm login npm publish