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
| Type | Name | Default | Description |
|---|---|---|---|
| I2cDevice | dev | ||
| Real | currentTime | ||
| Boolean | sclLevel | Logic level read on SCL (voltage thresholded on the Modelica side) | |
| Boolean | sdaLevel | Logic level read on SDA | |
| Real[Interfaces.I2C_DEV_MAX_VALUES] | valueIn | Quantities coming from the model, passed to the script's handlers (argument v) |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[Interfaces.I2C_DEV_MAX_VALUES] | valueOut | Quantities returned by outputs() (held between two calls) | |
| Boolean | sdaDriveLow | The peripheral pulls SDA to ground (acknowledge, or 0 bit of a byte read by the master) | |
| Boolean | busy | A phase addressed to this peripheral is in progress (icon activity indicator) | |
| Integer | eventSeq | Incremented at each completed write or read phase - trigger change(eventSeq) | |
| String | lastEvent | Summary of the last completed phase, e.g. "write 0x3E: 80 01" (log) | |
| String | line1 | First line returned by lines() (displays) | |
| String | line2 | Second line returned by lines() |