Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

[I2C] Adding the doc file #209

Merged
merged 1 commit into from
Sep 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions docs/i2c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Zephyr.js API for I2C
========================

* [Introduction](#introduction)
* [Web IDL](#web-idl)
* [API Documentation](#api-documentation)
* [Sample Apps](#sample-apps)

Introduction
------------
The I2C API supports the I2C protocol, which allows multiple slave chips to
communicate with one or more master chips. Each I2C bus has two signals - SDA
and SCL. SDA is the data signal and SCL is the clock signal.

Web IDL
-------
This IDL provides an overview of the interface; see below for documentation of
specific API functions.

```javascript
// require returns a I2C object
// var i2c = require('i2c');

[NoInterfaceObject]
interface I2C {
I2CBus open(I2CInit init);
};

dictionary I2CInit {
octet bus;
I2CBusSpeed speed;
};

[NoInterfaceObject]
interface I2CBus {
// has all the properties of I2CInit as read-only attributes
write(octet device, Buffer data);
};
```

API Documentation
-----------------
### I2C.open

`I2CBus open(I2CInit init);`

The `init` object lets you set the I2C bus you wish to use and the speed you
want to operate at. Speed options are 10, 100, 400, 1000, and 34000. Speed is
measured in kbs.

### I2CBus.write

`void write(octet device, Buffer data);`

Writes the data to the given device address. The first byte of data typically
contains the register you want to write the data to. This will vary from device
to device.

Sample Apps
-----------
* [I2C sample](../samples/I2C.js)