A pin mode for the Serial Wombat 8B or SW18AB chips which allows SPI communication over I2C.
This pin mode allows the Serial Wombat 8B or SW18AB to send and receive SPI data over I2C. This pin mode is good for low to moderate bandwidth SPI devices due to the overhead of the I2C bus. Suggested applications include shfit registers, low speed ADC, and LED current drivers. This pin mode is intended as a much more efficient alternative to bit-banging SPI using pin high and low I2C commands.
This pin mode is assigned to the clock pin. Additonal pins can be assigned as MOSI, MISO and CS pins.
The clock speed is not configurable, and is about 250kHz on the SW8B.
Unlike other pin modes, all functionality of this pin mode occurs during the I2C communcation handling instead of the 1mS pin update. This is not a problem for the SW8B because it only has to service 6 or less other pins every 1mS, but for the 18AB can be problematic if many other pins are in use as the time to bit-bang the SPI transaction may cause frame overflows. For the 8B up to 5 SPI bytes can be transferred per I2C transaction, but for the 18AB only 1 byte can be transferred by default to minimize the chance of frame overflows.
SPI modes 0, 1, and 3 are supported. Mode 2 is not a commonly used mode, and is left out to reduce the flash space required by the pin mode.
If a chip select pin is specified the chip select is set low before the SPI transaction. The chip select can be configured to stay low or go high after completion of the SPI transaction allowing for long transactions.
This pin mode is designed to function similarly to the Arduino SPIClass with similar interfaces. Unlike Arduino there are no interupt based options, the clock speed is fixed, and the bitOrder is ignored (always MSB first).