|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
I2CDatagramConnection | This interface defines an I2C serial datagram connection. |
Class Summary | |
---|---|
I2CDatagram | Holder of data to be sent or received from I2CdatagramConnection. |
I2C (Inter Integrated Circuit) API. Provides standard GCF (Generic Connection Framework) API to communicate with I2C driven peripherals. I2C API is defined according to I2C BUS SPECIFICATION version 2.1, which is located at
I2C-BUS SPECIFICATION
The proposed I2C-bus connection consists of two main parts:I2C API concept illustrationThe I2CDatagramConnection is the top level manager of the device's I2C bus. Applications use Connector.open() to create a new I2C-bus connection.I2CDatagramConnection I2CDatagram The I2CDatagram encapsulates data and header. Application can obtain a new I2CDatagram by calling newDatagram() from an I2CdatagramConnection object. Once I2CDatagram has been created, application will be able to send and receive data using I2CDatagramConnection relevant methods.
// open I2C in single master mode - I2CDatagramConnection I2CBusOne = (I2CDatagramConnection)Connector.open("i2c://BUS1:"); byte[] buf = new String("data_to_eeprom").getBytes(); // create data to send to slave I2CDatagram eepromDatagram = (I2CDatagram)I2CBusOne.newDatagram(buf,buf.length,"i2c://0x22:0x56"); I2CBusOne.send(eepromDatagram); |
buf = new String("new_data_to_eeprom").getBytes(); // create more data to send eepromDatagram.setData(buf); eepromDatagram.setAddress("i2c://0x22:0x78"); // change the register memory location to write to I2CBusOne.send(eepromDatagram); |
buf = new String("data to sensor").getBytes(); // create data to send to other slave I2CDatagram sensorDatagram = (I2CDatagram)I2CBusOne.newDatagram(buf,buf.length,"i2c://0x33:0x56"); I2CBusOne.send(sensorDatagram); |
//request to receive data from remote device buf = new byte[64]; //Init the buffer for receiving new data eepromDatagram = (I2CDatagram)I2CBusOne.newDatagram(buf,buf.length,"i2c://0x33:0x56"); I2CBusOne.receive(eepromDatagram); |
I2CBusOne.close(); |
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |