From 89b2cfc1dd4e733e98e2b8d25094724ff34f155b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 25 Mar 2018 19:09:05 +0200 Subject: [PATCH] I2C --- README.md | 1 + UNIT_I2C.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 UNIT_I2C.md diff --git a/README.md b/README.md index 6018633..6a258c9 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,5 @@ This repository specifies the control protocol implemented by [gex-core](https:/ - [UNIT_DI.md](UNIT_DI.md) - Digital Input - [UNIT_NEOPIXEL.md](UNIT_NEOPIXEL.md) - NeoPixel driver - [UNIT_SIPO.md](UNIT_SIPO.md) - Multi-cast Shift Register Driver +- [UNIT_I2C.md](UNIT_I2C.md) - I2C master diff --git a/UNIT_I2C.md b/UNIT_I2C.md new file mode 100644 index 0000000..4e53de0 --- /dev/null +++ b/UNIT_I2C.md @@ -0,0 +1,46 @@ +# I2C master + +## Commands + +### WRITE (0x00) + +*Request:* +- u16 - slave address +- u8[] - bytes to write + +### READ (0x01) + +*Request:* +- u16 - slave address +- u16 - number of bytes to read + +*Response:* +- u8[] - received bytes + +### READ_REG (0x02) + +Read a register value. First writes the register number, then reads a number of bytes. +For devices implementing auto-increment, the register width field can be used to read +multiple registers at once. + +*Request:* +- u16 - address +- u8 - register number +- u16 - register width (number of bytes to read) + +*Response:* +- u8[] - received bytes + +### WRITE_REG (0x03) + +Write a register; first writes the register number, then (in the same transaction) +the data. If the device supports it, can write multiple registers at once. + +*Request:* +- u16 - address +- u8 - register number +- u8[] - bytes to write + +## Events + +*No events defined for this unit type.*