Skip to content

Commit

Permalink
PWM: Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Remmirad committed Mar 21, 2023
1 parent ac6558d commit 5536eaf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/pwm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
7 changes: 7 additions & 0 deletions tests/pwm/Makefile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions tests/pwm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 5536eaf

Please sign in to comment.