tock / libtock-rs

Rust userland library for Tock
Apache License 2.0
161 stars 108 forks source link

Usage of gpio #461

Open J0hn-Lawrence opened 1 year ago

J0hn-Lawrence commented 1 year ago

Hi everyone,

I am wondering how I can use GPIO.

A comment starting on line 9 of the file "libtock-rs/apis/gpio/src/lib.rs" states the following:

Include by
[gpio.txt](https://github.com/tock/libtock-rs/files/10993761/gpio.txt)
 using: "use libtock::Gpios;"
Turn on a pin by: "let pin = Gpios::get_pin(0)?;"

When I create a new example "gpio.rs" in the examples directory and try to build it with "$ make EXAMPLE=gpio" I get the following error:

   |    use libtock::Gpios;
   |     ^^^^^^^^^^^^^^ no `Gpios` in the root

I have tried to build for nrf52, microbit_v2 and raspberry pi pico (which I think is not supported yet?), but all failed with the same message so I suppose this is not a target specific problem. i have also tried not capitalizing any letter in the use statement and also tried the singular of gpio -> "use libtock::gpio;". That did not work out as well. I have attached the few lines of code I wrote in the file gpio.txt.

My questions: Is this behavior expected or am I doing something completely wrong here? Is there any documentation regarding the GPIO usage other than the comments in the aforementioned file?

If this is the wrong place to discuss this, please feel free to tell me and the issue can be closed.

Thank you!

bradjc commented 1 year ago

I wrote an example for GPIO here: #498. That should be a good starting point using the GPIO library.