CircuitsSim.SPI.SPIDevice protocol (circuits_sim v0.1.2)

View Source

A protocol for SPI devices

Summary

Types

t()

All the types that implement this protocol.

Functions

Handle an user message

Return the internal state as ASCII art

Transfer data

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

handle_message(dev, message)

@spec handle_message(t(), any()) :: {any(), t()}

Handle an user message

User messages are used to modify the state of the simulated device outside of SPI. This can be used to simulate real world changes like temperature changes affecting a simulated temperature sensor. Another use is as a hook for getting internal state.

render(dev)

@spec render(t()) :: IO.ANSI.ansidata()

Return the internal state as ASCII art

transfer(dev, count)

@spec transfer(t(), binary()) :: {binary(), t()}

Transfer data