Skip to content

Latest commit

 

History

History
150 lines (150 loc) · 7.17 KB

imports.md

File metadata and controls

150 lines (150 loc) · 7.17 KB

Import interface wasi:i2c/[email protected]

Inter-Integrated Circuit (I²C) API that is based upon hello-embedded and embedded-hal.


Types

type address

u16

An address value, in either 7-bit or 10-bit form, depending on the device.

enum no-acknowledge-source

No-acknowledge error source.

In cases where it is possible, a device should indicate if a no acknowledge response was received to an address versus a no acknowledge to a data byte. Where it is not possible to differentiate, Unknown should be indicated.

Enum Cases
  • address

    The device did not acknowledge its address. The device may be missing.

  • data

    The device did not acknowledge the data. It may not be ready to process requests at the moment.

  • unknown

    Either the device did not acknowledge its address or the data, but it is unknown which.

variant error-code

Operation errors.

Variant Cases
  • bus

    Bus error occurred. e.g. A START or a STOP condition is detected and is not located after a multiple of 9 SCL clock pulses.

  • arbitration-loss

    The arbitration was lost, e.g. electrical problems with the clock signal.

  • no-acknowledge: no-acknowledge-source

    A bus operation was not acknowledged, e.g. due to the addressed device not being available on the bus or the device not being ready to process requests at the moment.

  • overrun

    The peripheral receive buffer was overrun.

  • other

    A different error occurred.

variant operation

An operation used by the transaction method.

Variant Cases
  • read: u64

    Read the give number of bytes.

  • write: list<u8>

    Write the given bytes.

resource i2c


Functions

[method]i2c.transaction: func

Execute the provided operations on the I²C bus.

Params
Return values

[method]i2c.read: func

Reads len bytes from address address.

Params
Return values

[method]i2c.write: func

Writes bytes to target with address address.

Params
Return values

[method]i2c.write-read: func

Writes bytes to address address and then reads read-len bytes in a single transaction.

Params
Return values

Import interface wasi:i2c/[email protected]

Delays.


Types

resource delay

Delay with up to nanosecond precision.

Functions

[method]delay.delay-ns: func

Pauses execution for at minimum ns nanoseconds. Pause can be longer if the implementation requires it due to precision/timing issues.

Params
  • self: borrow<delay>
  • ns: u32