Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ jobs:
- name: Build
working-directory: ${{ matrix.dir }}
run: |
# Deny warnings so a stray lint (e.g. an unused import) fails CI here
# instead of slipping through. For bloat examples an undenied warning
# gets replayed onto stdout by `cargo size` and corrupts the size parser.
export RUSTFLAGS="-D warnings"
# For bloat examples, remap source paths so the absolute workspace
# prefix doesn't affect binary size (panic messages embed file!() paths).
if [[ "${{ matrix.bloat }}" == "true" ]]; then
export RUSTFLAGS="--remap-path-prefix=$GITHUB_WORKSPACE=/rmk-build"
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix=$GITHUB_WORKSPACE=/rmk-build"
fi
cargo build --release

Expand Down Expand Up @@ -160,7 +164,10 @@ jobs:
# virtual prefix. Without this, absolute paths embedded by panic
# messages (file!() macro) differ in length between $GITHUB_WORKSPACE
# and the temp worktree, producing false size diffs in .rodata/.text.
head_remap="--remap-path-prefix=$GITHUB_WORKSPACE=/rmk-build"
# HEAD also keeps `-D warnings` so RUSTFLAGS matches the Build step
# above and cargo reuses the binary; BASE uses the default lint level
# so a pre-existing warning on main doesn't fail this PR.
head_remap="-D warnings --remap-path-prefix=$GITHUB_WORKSPACE=/rmk-build"
base_remap="--remap-path-prefix=$worktree=/rmk-build"

base_dir="$worktree/${{ matrix.dir }}"
Expand Down
14 changes: 13 additions & 1 deletion examples/use_rust/nrf52832_ble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use rmk::host::HostService;
use rmk::keyboard::Keyboard;
use rmk::matrix::Matrix;
use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -165,5 +166,16 @@ async fn main(spawner: Spawner) {
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();

run_all!(matrix, storage, ble_transport, wpm_processor, keyboard, host_service).await;
let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

run_all!(
matrix,
storage,
ble_transport,
wpm_processor,
keyboard,
host_service,
watchdog_runner
)
.await;
}
6 changes: 5 additions & 1 deletion examples/use_rust/nrf52840_ble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use rmk::keyboard::Keyboard;
use rmk::matrix::Matrix;
use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::usb::UsbTransport;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -218,6 +219,8 @@ async fn main(spawner: Spawner) {
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

run_all!(
matrix,
encoder,
Expand All @@ -228,7 +231,8 @@ async fn main(spawner: Spawner) {
wpm_processor,
batt_proc,
keyboard,
host_service
host_service,
watchdog_runner
)
.await;
}
6 changes: 5 additions & 1 deletion examples/use_rust/nrf52840_ble_split/src/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::split::ble::central::scan_peripherals;
use rmk::split::central::run_peripheral_manager;
use rmk::usb::UsbTransport;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -263,6 +264,8 @@ async fn main(spawner: Spawner) {
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

// Start
join(
run_all!(
Expand All @@ -277,7 +280,8 @@ async fn main(spawner: Spawner) {
keyboard,
host_service,
capslock_led,
peripheral_battery_monitor
peripheral_battery_monitor,
watchdog_runner
),
join(
run_peripheral_manager::<4, 7, 4, 0, _>(0, &peripheral_addrs, &stack),
Expand Down
5 changes: 4 additions & 1 deletion examples/use_rust/nrf52840_ble_split/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use rmk::input_device::rotary_encoder::RotaryEncoder;
use rmk::matrix::Matrix;
use rmk::split::peripheral::run_rmk_split_peripheral;
use rmk::storage::new_storage_for_split_peripheral;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, run_all};
use static_cell::StaticCell;

Expand Down Expand Up @@ -167,9 +168,11 @@ async fn main(spawner: Spawner) {
);
let mut battery_processor = BatteryProcessor::new(2000, 2806);

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

// Start
join3(
run_all!(matrix, encoder, adc_device, storage),
run_all!(matrix, encoder, adc_device, storage, watchdog_runner),
run_all!(battery_processor),
run_rmk_split_peripheral(0, &stack),
)
Expand Down
6 changes: 5 additions & 1 deletion examples/use_rust/nrf52840_ble_split_dongle/src/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::split::ble::central::scan_peripherals;
use rmk::split::central::run_peripheral_manager;
use rmk::usb::UsbTransport;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -265,6 +266,8 @@ async fn main(spawner: Spawner) {
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

// Start
join(
run_all!(
Expand All @@ -280,7 +283,8 @@ async fn main(spawner: Spawner) {
wpm_processor,
keyboard,
capslock_led,
host_service
host_service,
watchdog_runner
),
join(
scan_peripherals(&stack, &peripheral_addrs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use rmk::input_device::rotary_encoder::RotaryEncoder;
use rmk::matrix::Matrix;
use rmk::split::peripheral::run_rmk_split_peripheral;
use rmk::storage::new_storage_for_split_peripheral;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, run_all};
use static_cell::StaticCell;

Expand Down Expand Up @@ -155,6 +156,12 @@ async fn main(spawner: Spawner) {
let pin_b = Input::new(p.P1_04, embassy_nrf::gpio::Pull::None);
let mut encoder = RotaryEncoder::with_resolution(pin_a, pin_b, 4, true, 1);

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

// Start
join(run_all!(matrix, encoder, storage), run_rmk_split_peripheral(0, &stack)).await;
join(
run_all!(matrix, encoder, storage, watchdog_runner),
run_rmk_split_peripheral(0, &stack),
)
.await;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use rmk::input_device::rotary_encoder::RotaryEncoder;
use rmk::matrix::Matrix;
use rmk::split::peripheral::run_rmk_split_peripheral;
use rmk::storage::new_storage_for_split_peripheral;
use rmk::watchdog::Nrf52Watchdog;
use rmk::{HostResources, run_all};
use static_cell::StaticCell;

Expand Down Expand Up @@ -155,6 +156,12 @@ async fn main(spawner: Spawner) {
let pin_b = Input::new(p.P1_04, embassy_nrf::gpio::Pull::None);
let mut encoder = RotaryEncoder::with_resolution(pin_a, pin_b, 4, true, 1);

let mut watchdog_runner = Nrf52Watchdog::default_runner(p.WDT);

// Start
join(run_all!(matrix, encoder, storage), run_rmk_split_peripheral(1, &stack)).await;
join(
run_all!(matrix, encoder, storage, watchdog_runner),
run_rmk_split_peripheral(1, &stack),
)
.await;
}
5 changes: 4 additions & 1 deletion examples/use_rust/pi_pico_w_ble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use rmk::keyboard::Keyboard;
use rmk::matrix::Matrix;
use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::usb::UsbTransport;
use rmk::watchdog::Rp2040Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -162,6 +163,7 @@ async fn main(spawner: Spawner) {
let mut usb_transport = UsbTransport::new(driver, rmk_config.device_config);
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();
let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
run_all!(
Expand All @@ -171,7 +173,8 @@ async fn main(spawner: Spawner) {
ble_transport,
wpm_processor,
keyboard,
host_service
host_service,
watchdog_runner
)
.await;
}
5 changes: 4 additions & 1 deletion examples/use_rust/pi_pico_w_ble_split/src/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::split::ble::central::scan_peripherals;
use rmk::split::central::run_peripheral_manager;
use rmk::usb::UsbTransport;
use rmk::watchdog::Rp2040Watchdog;
use rmk::{HostResources, KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -168,6 +169,7 @@ async fn main(spawner: Spawner) {
let mut usb_transport = UsbTransport::new(driver, rmk_config.device_config);
let mut ble_transport = BleTransport::new(&stack, rmk_config).await;
let mut wpm_processor = WpmProcessor::new();
let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
join(
Expand All @@ -178,7 +180,8 @@ async fn main(spawner: Spawner) {
ble_transport,
wpm_processor,
keyboard,
host_service
host_service,
watchdog_runner
),
join(
run_peripheral_manager::<4, 7, 4, 0, _>(0, &peripheral_addrs, &stack),
Expand Down
9 changes: 8 additions & 1 deletion examples/use_rust/pi_pico_w_ble_split/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use rmk::futures::future::join;
use rmk::matrix::Matrix;
use rmk::split::peripheral::run_rmk_split_peripheral;
use rmk::storage::new_storage_for_split_peripheral;
use rmk::watchdog::Rp2040Watchdog;
use rmk::{HostResources, run_all};
use static_cell::StaticCell;

Expand Down Expand Up @@ -108,6 +109,12 @@ async fn main(spawner: Spawner) {
let mut rng = rand_chacha::ChaCha12Rng::from_rng(&mut rosc_rng).unwrap();

let stack = build_ble_stack(controller, ble_addr, &mut rng, &mut host_resources).await;
let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
join(run_all!(matrix, storage), run_rmk_split_peripheral(0, &stack)).await;
join(
run_all!(matrix, storage, watchdog_runner),
run_rmk_split_peripheral(0, &stack),
)
.await;
}
14 changes: 13 additions & 1 deletion examples/use_rust/rp2040/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use rmk::keyboard::Keyboard;
use rmk::matrix::Matrix;
use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::usb::UsbTransport;
use rmk::watchdog::Rp2040Watchdog;
use rmk::{KeymapData, initialize_keymap_and_storage, run_all};
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};

Expand Down Expand Up @@ -92,6 +93,17 @@ async fn main(_spawner: Spawner) {
let mut usb_transport = UsbTransport::new(driver, rmk_config.device_config);
let mut wpm_processor = WpmProcessor::new();

let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
run_all!(matrix, storage, usb_transport, wpm_processor, keyboard, host_service).await;
run_all!(
matrix,
storage,
usb_transport,
wpm_processor,
keyboard,
host_service,
watchdog_runner
)
.await;
}
13 changes: 12 additions & 1 deletion examples/use_rust/rp2040_split/src/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use rmk::processor::builtin::wpm::WpmProcessor;
use rmk::split::SPLIT_MESSAGE_MAX_SIZE;
use rmk::split::central::run_peripheral_manager;
use rmk::usb::UsbTransport;
use rmk::watchdog::Rp2040Watchdog;
use rmk::{KeymapData, initialize_keymap_and_storage, run_all};
use static_cell::StaticCell;
use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -102,9 +103,19 @@ async fn main(_spawner: Spawner) {
let mut usb_transport = UsbTransport::new(driver, rmk_config.device_config);
let mut wpm_processor = WpmProcessor::new();

let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
join(
run_all!(matrix, storage, usb_transport, wpm_processor, keyboard, host_service),
run_all!(
matrix,
storage,
usb_transport,
wpm_processor,
keyboard,
host_service,
watchdog_runner
),
run_peripheral_manager::<2, 1, 2, 2, _>(0, uart_receiver),
)
.await;
Expand Down
9 changes: 8 additions & 1 deletion examples/use_rust/rp2040_split/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use rmk::matrix::Matrix;
use rmk::run_all;
use rmk::split::SPLIT_MESSAGE_MAX_SIZE;
use rmk::split::peripheral::run_rmk_split_peripheral;
use rmk::watchdog::Rp2040Watchdog;
use static_cell::StaticCell;

bind_interrupts!(struct Irqs {
Expand All @@ -45,6 +46,12 @@ async fn main(_spawner: Spawner) {
let debouncer = DefaultDebouncer::new();
let mut matrix = Matrix::<_, _, _, 2, 2, true>::new(row_pins, col_pins, debouncer);

let mut watchdog_runner = Rp2040Watchdog::default_runner(embassy_rp::watchdog::Watchdog::new(p.WATCHDOG));

// Start
join(run_all!(matrix), run_rmk_split_peripheral(uart_instance)).await;
join(
run_all!(matrix, watchdog_runner),
run_rmk_split_peripheral(uart_instance),
)
.await;
}
4 changes: 4 additions & 0 deletions rmk-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ darling = "0.23"
cargo_toml = "0.22"
strum = { version = "0.28", default-features = false, features = ["derive"] }

[features]
## Enable hardware watchdog code generation
watchdog = []

[lib]
proc-macro = true
doctest = false
Expand Down
Loading