Skip to content

Commit

Permalink
feat(example): add led config to stm32h7 example
Browse files Browse the repository at this point in the history
Signed-off-by: HaoboGu <[email protected]>
  • Loading branch information
HaoboGu committed Feb 22, 2024
1 parent 7e8641a commit 82c2591
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions boards/stm32h7/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ macro_rules! config_matrix_pins_stm32 {
}
};
}

macro_rules! output_pin_stm32 {
(peripherals: $p:ident, output: $out_pin:ident, initial_level: $initial_level: ident) => {
{
let output_pin = Output::new($p.$out_pin, embassy_stm32::gpio::Level::$initial_level, embassy_stm32::gpio::Speed::VeryHigh).degrade();
Some(output_pin)
}
};
}
11 changes: 9 additions & 2 deletions boards/stm32h7/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use embassy_stm32::{
};
use panic_probe as _;
use rmk::{
config::{KeyboardUsbConfig, RmkConfig, VialConfig},
config::{KeyboardUsbConfig, LightConfig, RmkConfig, VialConfig},
initialize_keyboard_with_config_and_run,
keymap::KeyMap,
keymap::KeyMap, PinState,
};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -113,9 +113,16 @@ async fn main(_spawner: Spawner) {

let vial_config = VialConfig::new(VIAL_KEYBOARD_ID, VIAL_KEYBOARD_DEF);

let light_config = LightConfig {
capslock: output_pin_stm32!(peripherals: p, output: PE3, initial_level: Low),
scrolllock: None,
numslock: output_pin_stm32!(peripherals: p, output: PA2, initial_level: Low),
on_state: PinState::High,
};
let keyboard_config = RmkConfig {
usb_config: keyboard_usb_config,
vial_config,
light_config,
..Default::default()
};

Expand Down

0 comments on commit 82c2591

Please sign in to comment.