Add and update I2C topics (#602)
* Add and update I2C topics * Throw in some edits for the serial buffer apis * Add an example to serial read buffer
This commit is contained in:
committed by
Peli de Halleux
parent
f2f097a9ed
commit
985ad3d8e3
@@ -1,39 +1,40 @@
|
||||
# I2C Read Number
|
||||
|
||||
Read one number from the specified 7-bit I2C address, in the specified
|
||||
number format.
|
||||
Read one number from an I2C address using a specified number format.
|
||||
|
||||
```sig
|
||||
pins.i2cReadNumber(0, NumberFormat.Int8LE, false);
|
||||
```
|
||||
|
||||
### ~hint
|
||||
**Simulator**
|
||||
|
||||
This function needs real hardware to work with. It's not supported in the simulator.
|
||||
|
||||
### ~
|
||||
|
||||
## Parameters
|
||||
|
||||
* ``address``: the 7-bit I2C address from which to read the number.
|
||||
* ``format``: the number format. Formats include
|
||||
**Int8LE**, **UInt8LE**, **Int16LE**, **UInt16LE**, **Int32LE**,
|
||||
**Int8BE**, **UInt8BE**, **Int16BE**, **UInt16BE**, and
|
||||
**Int32BE**.
|
||||
* **Int** stands for "integer", and **UInt** stands for "unsigned integer".
|
||||
* **LE** stands for "little-endian" and **BE** stands for "big-endian".
|
||||
* The number in each format name stands for the number of bits in the format.
|
||||
* ``repeated`` repeated start, true - don't send stop at end
|
||||
* **address**: the 7-bit I2C address of the device you want to read a number from.
|
||||
* **format**: the [NumberFormat](/types/buffer/number-format) of the number value to read.
|
||||
* **repeated**: repeated start, true - don't send stop at end.
|
||||
* **repeated**: if `true`, a [repeated start condition](http://www.i2c-bus.org/repeated-start-condition/) is set to help make sure the number is read from the device with out an interruption. If set to `false` (the default), the number is read without setting a start condition more than once.
|
||||
|
||||
## Returns
|
||||
|
||||
* a number from the device with the [NumberFormat](/types/buffer/number-format) you asked for.
|
||||
|
||||
## Example
|
||||
|
||||
The following example reads a number in big-endian, 16-bit, unsigned integer
|
||||
format from the 7-bit I2C address `32`.
|
||||
|
||||
Read a number from the device at a 7-bit I2C address as a 16-bit number. The `16`, big-endian, and integer chosen for the format.
|
||||
|
||||
```blocks
|
||||
pins.i2cReadNumber(32, NumberFormat.UInt16BE, false);
|
||||
```
|
||||
|
||||
### ~hint
|
||||
|
||||
This function is not supported in the simulator.
|
||||
|
||||
### ~
|
||||
|
||||
## See also
|
||||
|
||||
[I2C](https://en.wikipedia.org/wiki/I%C2%B2C)
|
||||
[What's I2C?](http://www.i2c-bus.org/), [number format](/types/buffer/number-format)
|
||||
|
||||
Reference in New Issue
Block a user