From a38631cd175cf82256ded433bd41954c416be683 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Thu, 21 Jul 2022 11:10:36 -0400 Subject: [PATCH] documentation --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 71a8469..1da0cc8 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,32 @@ via parameters. This Program is subject to the terms of the Mozilla Public License, v.2.0. A copy of this license may be found in the file `COPYING`. You can obtain one at https://mozilla.org/MPL/2.0/. + +## Tests + +Go into `tests` and run `make`. To rerun tests, run `make clean` followed +by `make`. + +The test for each mode generates a `.vcd` file which you may view using +[GTKWave][1]. You can use this to gauge which SPI mode is appropriate for +your device. + +[1]: https://gtkwave.sourceforge.net/ + +## SPI Modes + +Modes are denoted by `modePH`, where `P` is the polarity (0 for normal, +1 for inverted) and `H` for phase: + +* `H = 0` means the device reads on a rising edge and writes on a falling + edge. +* `H = 1` means the device reads on a falling edge and writes on a rising + edge. + +Although these modules support all SPI modes, they are labeled slightly +differently from other SPI modes. The phase factor is denoted in terms +of falling and rising edges, not in terms of leading and trailing edges. +This means that polarity also flips the phase term, so a mode 3 device +is a mode 10 device. Devices with regular clock polarity are unaffected, +so a mode 0 device is a mode 00 device, and a mode 1 device is a mode +01 device.