Skip to main content

Module script

Module script 

Source
Expand description

Scripted buses: a part’s side of the conversation, for tests with nothing plugged in.

A driver is the sequence of transfers its datasheet prescribes: read this register, write that one, wait, read the result. I2cScript holds that sequence as I2cSteps, checks every transfer the driver makes against the next step, and answers with the bytes the part would have sent. A step can also fail on purpose, so the error path is tested too. PinScript and DelayLog do the same for a GPIO line and a delay: the levels the driver set and the time it waited are kept for the test to assert against the datasheet’s timing.

block_on runs the future a driver’s read or apply returns to completion, so a test of a scripted driver needs no executor.

Structs§

DelayLog
A delay that records every wait instead of sleeping.
I2cScript
An I2C bus that plays a script of transfers and replies.
PinScript
A GPIO line that records the levels it is driven to and answers reads from a script.
SpiScript
An SPI device that plays a script of transfers and replies.

Enums§

I2cStep
One transfer a scripted I2C part expects, and what it answers.
ScriptError
What a scripted I2C part refused.
SpiScriptError
What a scripted SPI part refused.
SpiStep
One transfer a scripted SPI part expects, and what it answers.
SpiTransfer
One operation of an SPI transaction, as the driver issued it.
Transfer
One operation of a transaction, as the driver issued it.

Functions§

block_on
Runs a future to completion by polling it, for futures that never wait on I/O.