SPI Bus

SPI device behaviour is emulated using the temu_SpiBus2. An old temu_SpiBus exists but should not be used for new models.

SpiBus2Interface

Transmissions are performed through the temu_SpiBus2Iface interface.

Connecting

Connecting a master to the bus works as with any other model. For slave devices a special procedure is required. The temu_SpiBus2Iface provides connect and disconnect function which register a slave device with it’s corresponding chip number chipNum. This number is used to relate the chipSelect raising and lowering to a specific device. When connecting or disconnecting a device the slave’s connected or disconnected functions will be called respectively. The slaves should use these to store the interface reference to the temu_SpiBus2. Minimal implementations might look like this:

void
connected(temu_Object *Obj, uint8_t chipNum, temu_SpiBus2IfaceRef Device)
{
  SPICTRL *spi = reinterpret_cast<SPICTRL *>(Obj);
  spi->Super.ChipNum = chipNum;
  spi->Bus = Device;
}

void
disconnected(temu_Object *Obj, uint8_t chipNum)
{
  SPICTRL *spi = reinterpret_cast<SPICTRL *>(Obj);
  spi->Bus.Iface = nullptr;
  spi->Bus.Obj = nullptr;
}

Transmitting

A transmissions starts with the master raising the chip select signal of a slave using the raiseChipSelect function of the interface. This may be done by the SPI Controller or through any other means such as an IO pin model which raises and lowers the chip select signal. Using the transfer function of the bus allows the master to initiate the transfer of data to the currently selected slave. The contents of the temu_SpiTransaction being transferred allow for the modeling of various SPI transmission setups.

Unresolved include directive in modules/buses/pages/spi.adoc - include::partial$auto-BusModels-meta-SPIBus2.adoc[]

Unresolved include directive in modules/buses/pages/spi.adoc - include::partial$auto-BusModels-SPIBus2.adoc[]

Limitations

Only one chip select signal may be active at the same time.