From ba4bc2bf967273dcf4995e90c687ef05354d9a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 25 Mar 2018 19:29:26 +0200 Subject: [PATCH] SPI --- README.md | 3 ++- UNIT_SPI.md | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 UNIT_SPI.md diff --git a/README.md b/README.md index 6a258c9..6187a0c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This repository specifies the control protocol implemented by [gex-core](https:/ - [UNIT_DO.md](UNIT_DO.md) - Digital Output - [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_SIPO.md](UNIT_SIPO.md) - Shift Register Driver with multicast support - [UNIT_I2C.md](UNIT_I2C.md) - I2C master +- [UNIT_SPI.md](UNIT_SPI.md) - SPI master up to 16 slaves and multicast support diff --git a/UNIT_SPI.md b/UNIT_SPI.md new file mode 100644 index 0000000..c76cf57 --- /dev/null +++ b/UNIT_SPI.md @@ -0,0 +1,40 @@ +# SPI master + +- Can drive shift registers or communicate with any SPI based devices. +- Configurable speed, polarity and phase +- Up to 16 slave select signals +- Supports multicast (write to multiple slaves at once) + +*NOTE:* To use Multicast with bi-directionally connected devices, the MISO pins should be +connected through protection resistors to prevent a short circuit on signal collision. + +## Commands + +### QUERY (0x00) + +Write and read some bytes. + +The write and read sections can overlap if needed; some devices use this +to report a status word while the command is being written. 0x00 is output on MOSI while collecting a response. + +If the overlap is not desired (first write, then read), set the number of discarded +bytes equal to the number of written bytes. + +*Request:* +- u8 - slave number 0-16 +- u16 - number of discarded MISO bytes before collecting the response +- u16 - response length (bytes) +- u8[] - bytes to write + +*Response:* +- u8[] - received bytes + +### MULTICAST (0x01) + +*Request:* +- u16 - slaves (packed) +- u8[] - bytes to write + +## Events + +*No events defined for this unit type.*