forked from future-proof-iot/RIOT-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(embassy): provide a GPIO API unified across architectures (futur…
- Loading branch information
Showing
41 changed files
with
2,232 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "blinky" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
publish = false | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
embassy-executor = { workspace = true } | ||
embassy-time = { workspace = true } | ||
riot-rs = { path = "../../src/riot-rs", features = [ | ||
"external-interrupts", | ||
"time", | ||
] } | ||
riot-rs-boards = { path = "../../src/riot-rs-boards" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# blinky | ||
|
||
## About | ||
|
||
This application is demonstrating basic GPIO output usage with RIOT-rs. | ||
|
||
## How to run | ||
|
||
In this folder, run | ||
|
||
laze build -b nrf52840dk run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apps: | ||
- name: blinky | ||
context: | ||
# list of contexts that have an entry in `pins.rs` | ||
- esp | ||
- microbit-v2 | ||
- nrf52840dk | ||
- nrf5340dk | ||
- rp | ||
- st-nucleo-f401re | ||
- st-nucleo-h755zi-q | ||
- st-nucleo-wb55 | ||
selects: | ||
- ?release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![no_main] | ||
#![no_std] | ||
#![feature(type_alias_impl_trait)] | ||
#![feature(used_with_arg)] | ||
|
||
mod pins; | ||
|
||
use embassy_time::{Duration, Timer}; | ||
use riot_rs::embassy::gpio::{Level, Output}; | ||
|
||
#[riot_rs::task(autostart, peripherals)] | ||
async fn blinky(peripherals: pins::LedPeripherals) { | ||
let mut led = Output::new(peripherals.led, Level::Low); | ||
|
||
// The micro:bit uses an LED matrix; pull the column line low. | ||
#[cfg(context = "microbit-v2")] | ||
let _led_col1 = Output::new(peripherals.led_col1, Level::Low); | ||
|
||
loop { | ||
led.toggle(); | ||
Timer::after(Duration::from_millis(500)).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use riot_rs::embassy::arch::peripherals; | ||
|
||
#[cfg(context = "microbit-v2")] | ||
riot_rs::define_peripherals!(LedPeripherals { | ||
led_col1: P0_28, | ||
led: P0_21, | ||
}); | ||
|
||
#[cfg(context = "nrf52840dk")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: P0_13 }); | ||
|
||
#[cfg(context = "nrf5340dk")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: P0_28 }); | ||
|
||
#[cfg(context = "rp")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: PIN_1 }); | ||
|
||
#[cfg(context = "esp")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: GPIO_0 }); | ||
|
||
#[cfg(context = "st-nucleo-f401re")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: PA5 }); | ||
|
||
#[cfg(context = "st-nucleo-h755zi-q")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: PB0 }); | ||
|
||
#[cfg(context = "st-nucleo-wb55")] | ||
riot_rs::define_peripherals!(LedPeripherals { led: PB5 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "gpio" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
publish = false | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
embassy-executor = { workspace = true } | ||
embassy-futures = { workspace = true } | ||
embassy-time = { workspace = true } | ||
riot-rs = { path = "../../src/riot-rs", features = [ | ||
"external-interrupts", | ||
"time", | ||
] } | ||
riot-rs-boards = { path = "../../src/riot-rs-boards" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# gpio | ||
|
||
## About | ||
|
||
This application is testing GPIO usage with RIOT-rs. | ||
|
||
## How to run | ||
|
||
In this folder, run | ||
|
||
laze build -b nrf52840dk run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apps: | ||
- name: gpio | ||
selects: | ||
- ?release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#![no_main] | ||
#![no_std] | ||
#![feature(type_alias_impl_trait)] | ||
#![feature(used_with_arg)] | ||
|
||
mod pins; | ||
|
||
use embassy_time::{Duration, Timer}; | ||
use riot_rs::embassy::gpio::{Input, Level, Output, Pull}; | ||
|
||
#[riot_rs::task(autostart, peripherals)] | ||
async fn blinky(peripherals: pins::Peripherals) { | ||
let mut led1 = Output::new(peripherals.led1, Level::Low); | ||
|
||
#[allow(unused_variables)] | ||
let pull = Pull::Up; | ||
#[cfg(context = "st-nucleo-h755zi-q")] | ||
let pull = Pull::None; | ||
|
||
let mut btn1 = Input::builder(peripherals.btn1, pull) | ||
.build_with_interrupt() | ||
.unwrap(); | ||
|
||
// The micro:bit uses an LED matrix; pull the column line low. | ||
#[cfg(context = "microbit-v2")] | ||
let _led_col1 = Output::new(peripherals.led_col1, Level::Low); | ||
|
||
loop { | ||
// Wait for the button being pressed or 300 ms, whichever comes first. | ||
let _ = embassy_futures::select::select( | ||
btn1.wait_for_low(), | ||
Timer::after(Duration::from_millis(300)), | ||
) | ||
.await; | ||
|
||
led1.toggle(); | ||
Timer::after(Duration::from_millis(100)).await; | ||
} | ||
} |
Oops, something went wrong.