diff --git a/tests/pwm/Cargo.toml b/tests/pwm/Cargo.toml new file mode 100644 index 00000000..6b80f4b8 --- /dev/null +++ b/tests/pwm/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "riot-wrappers-test-pwm" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["staticlib"] + +[profile.release] +panic = "abort" + +[dependencies] +riot-wrappers = { version = "*", features = [ "set_panic_handler" ] } +riot-sys = "*" +embedded-hal = { version = "0.2.4", features = ["unproven"] } diff --git a/tests/pwm/Makefile b/tests/pwm/Makefile new file mode 100644 index 00000000..ea5ac4fe --- /dev/null +++ b/tests/pwm/Makefile @@ -0,0 +1,7 @@ +APPLICATION = riot-wrappers-test-pwm +APPLICATION_RUST_MODULE = riot_wrappers_test_pwm +BASELIBS += $(APPLICATION_RUST_MODULE).module +FEATURES_REQUIRED += rust_target +FEATURES_REQUIRED += periph_pwm + +include $(RIOTBASE)/Makefile.include diff --git a/tests/pwm/src/lib.rs b/tests/pwm/src/lib.rs new file mode 100644 index 00000000..c8177f3f --- /dev/null +++ b/tests/pwm/src/lib.rs @@ -0,0 +1,13 @@ +#![no_std] + +use embedded_hal::Pwm; +use riot_wrappers::pwm::{HertzU32, PWMDevice, PWMMode}; +use riot_wrappers::riot_main; + +riot_main!(main); + +fn main() { + let mut pwm = PWMDevice::<0>::new(0, PWMMode::Left, HertzU32::Hz(10), 100).unwrap(); + let channel_0 = pwm.get_channel(0).unwrap(); + pwm.set_duty(channel_0, 50); // 50% duty_cycle +}