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

Commit c21b9fe

Browse files
authored
Merge pull request #209 from brianjjones/master
[I2C] Adding the doc file
2 parents 97e5e7e + b51608d commit c21b9fe

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

docs/i2c.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Zephyr.js API for I2C
2+
========================
3+
4+
* [Introduction](#introduction)
5+
* [Web IDL](#web-idl)
6+
* [API Documentation](#api-documentation)
7+
* [Sample Apps](#sample-apps)
8+
9+
Introduction
10+
------------
11+
The I2C API supports the I2C protocol, which allows multiple slave chips to
12+
communicate with one or more master chips. Each I2C bus has two signals - SDA
13+
and SCL. SDA is the data signal and SCL is the clock signal.
14+
15+
Web IDL
16+
-------
17+
This IDL provides an overview of the interface; see below for documentation of
18+
specific API functions.
19+
20+
```javascript
21+
// require returns a I2C object
22+
// var i2c = require('i2c');
23+
24+
[NoInterfaceObject]
25+
interface I2C {
26+
I2CBus open(I2CInit init);
27+
};
28+
29+
dictionary I2CInit {
30+
octet bus;
31+
I2CBusSpeed speed;
32+
};
33+
34+
[NoInterfaceObject]
35+
interface I2CBus {
36+
// has all the properties of I2CInit as read-only attributes
37+
write(octet device, Buffer data);
38+
};
39+
```
40+
41+
API Documentation
42+
-----------------
43+
### I2C.open
44+
45+
`I2CBus open(I2CInit init);`
46+
47+
The `init` object lets you set the I2C bus you wish to use and the speed you
48+
want to operate at. Speed options are 10, 100, 400, 1000, and 34000. Speed is
49+
measured in kbs.
50+
51+
### I2CBus.write
52+
53+
`void write(octet device, Buffer data);`
54+
55+
Writes the data to the given device address. The first byte of data typically
56+
contains the register you want to write the data to. This will vary from device
57+
to device.
58+
59+
Sample Apps
60+
-----------
61+
* [I2C sample](../samples/I2C.js)

0 commit comments

Comments
 (0)