impure functionI2cDevice_sync

Sync point of an I2C slave peripheral: interprets the SCL or SDA edge that just occurred, calls the script at the right moments, and returns the state of its SDA output

Information

impure: the function carries the state of the peripheral — like UartDevice_sync. It is only called from a when triggered by an edge of SCL or SDA, never during a trial evaluation of the solver.

Called again several times at the same instant with the same levels (Modelica event iterations), it does nothing: there is no new edge to interpret.

Inputs

TypeNameDefaultDescription
I2cDevicedev
RealcurrentTime
BooleansclLevelLogic level read on SCL (voltage thresholded on the Modelica side)
BooleansdaLevelLogic level read on SDA
Real[Interfaces.I2C_DEV_MAX_VALUES]valueInQuantities coming from the model, passed to the script's handlers (argument v)

Outputs

TypeNameDefaultDescription
Real[Interfaces.I2C_DEV_MAX_VALUES]valueOutQuantities returned by outputs() (held between two calls)
BooleansdaDriveLowThe peripheral pulls SDA to ground (acknowledge, or 0 bit of a byte read by the master)
BooleanbusyA phase addressed to this peripheral is in progress (icon activity indicator)
IntegereventSeqIncremented at each completed write or read phase - trigger change(eventSeq)
StringlastEventSummary of the last completed phase, e.g. "write 0x3E: 80 01" (log)
Stringline1First line returned by lines() (displays)
Stringline2Second line returned by lines()