Package comm
Class I2C

Public Constructor I2C

I2C(int address)

Throws:

I2C(int address, boolean slave_mode)

Throws:

I2C(int address, int frequency)

Throws:

I2C(int address, int frequency, boolean slave_mode)

Throws:

_INSERT_METHOD_SIGNATURE_HERE_

Description:

The iLCD panelJoC board might be used as I2C-master or I2C-slave device. An instance of this class represents either an externel slave device with the iLCD-controllerJoC board automatically set as master or the iLCD-controllerJoC board as slave device used with an external master.

constructor I2C(int addr):

constructor I2C(int addr, boolean slave_mode):

Parameter Range Description
addr 0 ... 127 target slave device address
[slave_mode] true/false I2C-mode of iLCD controllerJoC (default: false)

If slave_mode is omitted or false, the addr parameter is used to set up the address for a specific I2C slave device to be addressed by the iLCD-controllerJoC board in master mode.

If slave_mode is true, the iLCD-controllerJoC board will be used in slave mode controlled by an external master via the address addr.

Note

constructor I2C(int addr, int freq):

constructor I2C(int addr, int freq, boolean slave_mode):

Parameter Range Description
addr 0 ... 127 target slave device address
freq 0 ... 400000 I2C bus frequency in Hz
[slave_mode] true/false I2C-mode of iLCD controllerJoC (default: false)

This constructor is used to adjust the frequency for the I2C-bus.

If slave_mode is omitted or false, the addr parameter is used to set up the address for a specific I2C slave device to be addressed by the iLCD-controllerJoC board in master mode.

If slave_mode is true, the iLCD-controllerJoC board will be used in slave mode controlled by an external master via the address addr.

Notes

Example

The following code shows how to create an instance of the I2C class.

   import comm.I2C;

   ...

   I2C i2c;

   ...

   i2c = new I2C(0x40);

The comm package must be imported in order to use the I2C class. A new variable with the I2C data type must be created in the next step. Afterwards, a new instance of the I2C class is created with an automatically assigned frequnecy of 100kHz.

See also:

SPI
UART