Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a configuration function for the host #7

Open
Zelzahn opened this issue Apr 16, 2024 · 1 comment
Open

Provide a configuration function for the host #7

Zelzahn opened this issue Apr 16, 2024 · 1 comment

Comments

@Zelzahn
Copy link
Collaborator

Zelzahn commented Apr 16, 2024

Some kind of host configuration function should be defined, some of the parameters that could be set: operating speed, target/controller, 10 bit/7 bit addressing, etc.

I see two possible locations:

  • Inside the i2c resource: configure: func(options: options) (options would be a struct then)
  • Provide it as part of an interface for a board world.

Personally, I prefer the second option. It seems to me that this follows the conclusions from #2, and I favour (some kind of) uniformity across board worlds.

@sunfishcode
Copy link
Member

I prefer the second option too. It keeps simple use cases very simple, and complex use cases can still add configuration mechanisms if they need to.

If there is a set of configuration options that are common across a sufficient set of boards, an option would be to define a common interface for configuration, perhaps something in roughly this shape:

interface i2c-config {
    use wasi:i2c/i2c@0.2.0-draft.{i2c, error-code};

     /// maybe like this? and more functions like this?
     set-speed: static func(bus: i2c, speed: u32) -> result<_, error-code>;

     /// or combine the options into a record?
     configure: static func(bus: i2c, options: options) -> result<_, error-code>;
}

That way, worlds could include it if it happens to fit their needs, rather than defining their one board-specific interfaces. I don't think we need to design this right now though; I just wanted to mention the option in case the need arises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants