diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ad1997c..71aaf87 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,5 @@ jobs: name: Check ABI files are up-to-date runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: WebAssembly/wit-abi-up-to-date@v12 - with: - wit-abi-tag: wit-abi-0.10.0 + - uses: actions/checkout@v4 + - uses: WebAssembly/wit-abi-up-to-date@v19 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..4753095 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,8 @@ +Copyright © 2019-2023 the Contributors to the WASI Specification, published +by the [WebAssembly Community Group][cg] under the +[W3C Community Contributor License Agreement (CLA)][cla]. A human-readable +[summary][summary] is available. + +[cg]: https://www.w3.org/community/webassembly/ +[cla]: https://www.w3.org/community/about/agreements/cla/ +[summary]: https://www.w3.org/community/about/agreements/cla-deed/ diff --git a/README.md b/README.md index 733036b..2217b28 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,34 @@ -# [Example WASI proposal] - -This template can be used to start a new proposal, which can then be proposed in the WASI Subgroup meetings. - -The sections below are recommended. However, every proposal is different, and the community can help you flesh out the proposal, so don't block on having something filled in for each one of them. - -Thank you to the W3C Privacy CG for the [inspiration](https://github.com/privacycg/template)! - -# [Title] +# WASI I2C A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API. ### Current Phase -[Fill in the current phase, e.g. Phase 1] +wasi-i2c is currently in [Phase 1](https://github.com/WebAssembly/WASI/blob/main/Proposals.md#phase-1---feature-proposal-cg) ### Champions -- [Champion 1] -- [Champion 2] -- [etc.] - -### Phase 4 Advancement Criteria +- Friedrich Vandenberghe +- Merlijn Sebrechts +- Maximilian Seidler -TODO before entering Phase 2. +### Portability Criteria -## Table of Contents [if the explainer is longer than one printed page] - -- [Introduction](#introduction) -- [Goals [or Motivating Use Cases, or Scenarios]](#goals-or-motivating-use-cases-or-scenarios) -- [Non-goals](#non-goals) -- [API walk-through](#api-walk-through) - - [Use case 1](#use-case-1) - - [Use case 2](#use-case-2) -- [Detailed design discussion](#detailed-design-discussion) - - [[Tricky design choice 1]](#tricky-design-choice-1) - - [[Tricky design choice 2]](#tricky-design-choice-2) -- [Considered alternatives](#considered-alternatives) - - [[Alternative 1]](#alternative-1) - - [[Alternative 2]](#alternative-2) -- [Stakeholder Interest & Feedback](#stakeholder-interest--feedback) -- [References & acknowledgements](#references--acknowledgements) +WASI-I2C must have at least two complete independent implementations. One implementation must be implemented on a microcontroller. ### Introduction -[The "executive summary" or "abstract". Explain in a few sentences what the goals of the project are, and a brief overview of how the solution works. This should be no more than 1-2 paragraphs.] +The WASI-I2C proposal defines an API for the I2C protocol. The API of [embedded_hal](https://github.com/rust-embedded/embedded-hal) is closely followed. + +Reference implementations can be found in [i2c-wasm-components](https://github.com/Zelzahn/i2c-wasm-components). Furthermore, there is also a [wasi-embedded-hal](https://crates.io/crates/wasi-embedded-hal) crate that implements the `embedded-hal` traits for the generated bindings. -### Goals [or Motivating Use Cases, or Scenarios] +### Goals -[What is the end-user need which this project aims to address?] +The primary goal is to provide an interface that WASI programs can use to read and write data over an I2C connection. ### Non-goals -[If there are "adjacent" goals which may appear to be in scope but aren't, enumerate them here. This section may be fleshed out as your design progresses and you encounter necessary technical and other trade-offs.] +Although I2C is in some aspects not that different from SPI, the purpose of this proposal is to solely focus on I2C. ### API walk-through @@ -69,44 +46,19 @@ The full API documentation can be found [here](wasi-proposal-template.md). ### Detailed design discussion -[This section should mostly refer to the .wit.md file that specifies the API. This section is for any discussion of the choices made in the API which don't make sense to document in the spec file itself.] - -#### [Tricky design choice #1] - -[Talk through the tradeoffs in coming to the specific design point you want to make.] - -``` -// Illustrated with example code. -``` +#### Should this be combined with SPI, GPIO and PWM into 1 embedded proposal? -[This may be an open question, in which case you should link to any active discussion threads.] - -#### [Tricky design choice 2] - -[etc.] - -### Considered alternatives - -[This section is not required if you already covered considered alternatives in the design discussion above.] - -#### [Alternative 1] - -[Describe an alternative which was considered, and why you decided against it.] - -#### [Alternative 2] - -[etc.] +Although `embedded_hal` takes this approach, I would keep them separated for now. At least until each proposal is at least in Phase 2. ### Stakeholder Interest & Feedback TODO before entering Phase 3. -[This should include a list of implementers who have expressed interest in implementing the proposal] ### References & acknowledgements Many thanks for valuable feedback and advice from: -- [Person 1] -- [Person 2] -- [etc.] +- Merlijn Sebrechts +- Dan Gohman for the `hello-embedded` repository +- Everyone else in SIG Embedded diff --git a/example-world.md b/example-world.md deleted file mode 100644 index c58d364..0000000 --- a/example-world.md +++ /dev/null @@ -1,72 +0,0 @@ -
example-dep-interface
example-interface
type example-dep-type
u32
-## Import interface example-interface -
Short interface description.
-Explanation for developers using the interface API. It should include an
-overview of the API as a whole as well as call out notable items in it,
-for example example-api-type
and example-api-function
.
type example-dep-type
-#### `record example-api-type` -
Short type description
-Explanation for developers using this type. It may be useful to give
-some examples of places in the API where the type is used, such as in
-the arguments and return type of example-api-function
.
example-api-function: func
Short function description
-Explanation for developers using the API. This should describe the
-arguments which in this function are arg0
, arg1
, and arg2
, and the
-return value.
arg0
: example-api-type
arg1
: string
arg2
: example-dep-type
example-api-type
>wasi:i2c/i2c@0.2.0-draft
wasi:i2c/delay@0.2.0-draft
Inter-Integrated Circuit (I²C) API that is based upon hello-embedded and embedded-hal.
+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.
+The device did not acknowledge its address. The device may be +missing. +
The device did not acknowledge the data. It may not be ready to +process requests at the moment. +
Either the device did not acknowledge its address or the data, but +it is unknown which. +
variant error-code
Operation errors.
+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. +
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. +
The peripheral receive buffer was overrun. +
A different error occurred. +
variant operation
An operation used by the transaction
method.
resource i2c
[method]i2c.transaction: func
Execute the provided operation
s on the I²C bus.
u8
>>, error-code
>[method]i2c.read: func
Reads len
bytes from address address
.
u8
>, error-code
>[method]i2c.write: func
Writes bytes to target with address address
.
error-code
>[method]i2c.write-read: func
Writes bytes to address address
and then reads read-len
bytes
+in a single transaction.
u8
>, error-code
>Delays.
+resource delay
[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.
self
: borrow<delay
>ns
: u32