i2c

This module provides access to all I2C GPIO expansion pins via a 32 bit bus. The expansion module has 2 ports and each port has 2 banks which are 8 bits wide. These are mapped onto a single 32 bit value that can be read and written. http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE] I2CBUS is an integer or an I2C bus name ADDRESS is an integer (0x03 - 0x77) MODE is one of: c (byte, no value) b (byte data, default) w (word data) i (I2C block data) s (SMBus block data) E.g. Switch on watchdog led => DIR:0=out: i2cset -y 1 0x21 0x0 0xBF i2cset -y 1 0x21 0x12 0x40 Close Valve 0 DIR:0=out: i2cset -y 1 0x20 0x1 0xFE i2cset -y 1 0x20 0x13 0x1 Switch On Heater DIR:0=out: i2cset -y 1 0x21 0x0 0xFD i2cset -y 1 0x21 0x12 0x2 chip data value pin Flow 7 0x21 0x13 0x80 31 In Flow 6 0x21 0x13 0x40 30 In Flow 5 0x21 0x13 0x20 29 In Flow 4 0x21 0x13 0x10 28 In Flow 3 0x21 0x13 0x8 27 In Heater(was Flow 2)0x21 0x13 0x4 26 In Flow 1 0x21 0x13 0x2 25 In Flow 0 0x21 0x13 0x1 24 In chip data value pin Watchdog Halt 0x21 0x12 0x80 23 In Watchdog LED 0x21 0x12 0x40 22 Out 1 = On //Heater 0x21 0x12 0x20 21 Out 1 = On //Heater 0x21 0x12 0x10 16 Out 1 = On //Heater 0x21 0x12 0x02 17 Out 1 = On Relay ? 0x20 0x13 0x80 15 Out Relay ? 0x20 0x13 0x40 14 Out Relay ? 0x20 0x13 0x20 13 Out Pump 0 0x20 0x13 0x10 12 Out 0 = On Valve 6 0x20 0x13 0x8 11 Out 0 = Open Valve 4 0x20 0x13 0x4 10 Out 0 = Open Valve 2 0x20 0x13 0x2 9 Out 0 = Open valve 0 0x20 0x13 0x1 8 Out 0 = Open Valve 1 0x20 0x12 0x80 7 Out 0 = Open Valve 3 0x20 0x12 0x40 6 Out 0 = Open Valve 5 0x20 0x12 0x20 5 Out 0 = Open Valve 7 0x20 0x12 0x10 4 Out 0 = Open Pump 1 0x20 0x12 0x8 3 Out Relay ? 0x20 0x12 0x4 2 Out Relay ? 0x20 0x12 0x2 1 Out Relay ? 0x20 0x12 0x1 0 Out
Author:
  • Dave Leitch
Author:
  • Dave Leitch

Requires

Members

setDir static

Set direction of a single bit

I2C inner

Raspi I2C is part of the Raspi.js suite that provides access to the hardware I2C on pins 3 (SDA0) and 5 (SCL0).

Methods

init() static

Initialise an individual bit.

init() static

Initialise an individual bit. {number, dir, value} bitInfo

readBit(bit) static

Read any single bit
Arguments:
  1. bit (number)  Bit number [0:31]

readBit(bit) static

Read any single bit
Arguments:
  1. bit (number)  Bit number [0:31]

setDir(bit, value) static

Set direction of a single bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  DIR_INPUT | DIR_OUTPUT

toggleBit(n) static

Toggle any bit
Arguments:
  1. n (number)  Bit number [0:31]

toggleBit(bit) static

Toggle any bit
Arguments:
  1. bit (number)  Bit number [0:31]

writeBit(bit, value) static

Set or clear any bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  0 or 1

writeBit(bit, value) static

Set or clear any bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  0 or 1

getBit(byte, bit) inner

Arguments:
  1. byte (Number)
  2. bit (Number)

getBit(byte, bit) inner

Arguments:
  1. byte (Number)
  2. bit (Number)

writeReg(data, bit, value) inner

Write a bit into the register | @param {Number} bankAddr
Arguments:
  1. data (Number)
  2. bit (Number)
  3. value (Number)

writeReg(currentByte, bit, value) inner

Write a bit into the register | @param {Number} bankAddr
Arguments:
  1. currentByte (Number)
  2. bit (Number)
  3. value (Number)
This module provides access to all I2C GPIO expansion pins via a 32 bit bus. The expansion module has 2 ports and each port has 2 banks which are 8 bits wide. These are mapped onto a single 32 bit value that can be read and written. http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE] I2CBUS is an integer or an I2C bus name ADDRESS is an integer (0x03 - 0x77) MODE is one of: c (byte, no value) b (byte data, default) w (word data) i (I2C block data) s (SMBus block data) BANK0: IO_DIR_A @ 0x0 IO_DIR_B @ 0x1 BANK1: IO_DIR_A @ 0x0 IO_DIR_B @ 0x10 E.g. Switch on watchdog led => DIR:0=out: i2cset -y 1 0x21 0x0 0xBF i2cset -y 1 0x21 0x12 0x40 Close Valve 0 DIR:0=out: i2cset -y 1 0x20 0x1 0xFE i2cset -y 1 0x20 0x13 0x1 Switch On Heater DIR:0=out: i2cset -y 1 0x21 0x0 0xFD i2cset -y 1 0x21 0x12 0x2 chip data bit pin same as defs Valve Ferment(2)0x20 0x13 7 15 no,4 Hood 0x20 0x13 6 14 no,13 Pump? 0x20 0x13 5 13 no,12 Valve MashIn(7) 0x20 0x13 3 11 yes Relay 5 0x20 0x13 2 10 Valve ChillIn(3)0x20 0x13 1 9 yes Chill Pump 0x20 0x13 0 8 yes Relay 4 0x20 0x12 6 6` Valve Kettle In 0x20 0x12 5 5 yes Relay 8 0x20 0x12 4 4` Pump1? 0x20 0x12 3 3 yes Heater 0x20 0x12 2 2 yes Flow 3 0x21 0x13 0x8 27 In Flow 1 0x21 0x13 0x2 25 In Flow 0 0x21 0x13 0x1 24 In Watchdog Halt 0x21 0x12 0x80 23 In(1) Watchdog LED 0x21 0x12 0x40 22 Out(0) 1 = On
Author:
  • Dave Leitch
Author:
  • Dave Leitch

Requires

Members

setDir static

Set direction of a single bit

I2C inner

Raspi I2C is part of the Raspi.js suite that provides access to the hardware I2C on pins 3 (SDA0) and 5 (SCL0).

Methods

init() static

Initialise an individual bit.

init() static

Initialise an individual bit. {number, dir, value} bitInfo

readBit(bit) static

Read any single bit
Arguments:
  1. bit (number)  Bit number [0:31]

readBit(bit) static

Read any single bit
Arguments:
  1. bit (number)  Bit number [0:31]

setDir(bit, value) static

Set direction of a single bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  DIR_INPUT | DIR_OUTPUT

toggleBit(n) static

Toggle any bit
Arguments:
  1. n (number)  Bit number [0:31]

toggleBit(bit) static

Toggle any bit
Arguments:
  1. bit (number)  Bit number [0:31]

writeBit(bit, value) static

Set or clear any bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  0 or 1

writeBit(bit, value) static

Set or clear any bit
Arguments:
  1. bit (number)  Bit number [0:31]
  2. value (number)  0 or 1

getBit(byte, bit) inner

Arguments:
  1. byte (Number)
  2. bit (Number)

getBit(byte, bit) inner

Arguments:
  1. byte (Number)
  2. bit (Number)

writeReg(data, bit, value) inner

Write a bit into the register | @param {Number} bankAddr
Arguments:
  1. data (Number)
  2. bit (Number)
  3. value (Number)

writeReg(currentByte, bit, value) inner

Write a bit into the register | @param {Number} bankAddr
Arguments:
  1. currentByte (Number)
  2. bit (Number)
  3. value (Number)