From b2c4ee62884d1361ab74f52bc81721dcc8f6d557 Mon Sep 17 00:00:00 2001 From: Guillaume Pinot Date: Wed, 5 Aug 2020 00:24:04 +0200 Subject: some cleanups --- firmware/src/main.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'firmware/src') diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 9c261c0..71276c3 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -14,7 +14,7 @@ use keyberon::key_code::KbHidReport; use keyberon::key_code::KeyCode::{self, *}; use keyberon::layout::Layout; use keyberon::matrix::{Matrix, PressedKeys}; -use rtfm::app; +use rtic::app; use stm32f0xx_hal::gpio::{gpioa, gpiob, Input, Output, PullUp, PushPull}; use stm32f0xx_hal::prelude::*; use stm32f0xx_hal::usb; @@ -179,8 +179,10 @@ const APP: () = { } #[task(binds = USB, priority = 2, resources = [usb_dev, usb_class])] - fn usb_rx(mut c: usb_rx::Context) { - usb_poll(&mut c.resources.usb_dev, &mut c.resources.usb_class); + fn usb_rx(c: usb_rx::Context) { + if c.resources.usb_dev.poll(&mut [c.resources.usb_class]) { + c.resources.usb_class.poll(); + } } #[task(binds = TIM3, priority = 1, resources = [usb_class, matrix, debouncer, layout, timer])] @@ -199,15 +201,9 @@ const APP: () = { }; fn send_report(iter: impl Iterator, usb_class: &mut resources::usb_class<'_>) { - use rtfm::Mutex; + use rtic::Mutex; let report: KbHidReport = iter.collect(); if usb_class.lock(|k| k.device_mut().set_keyboard_report(report.clone())) { while let Ok(0) = usb_class.lock(|k| k.write(report.as_bytes())) {} } } - -fn usb_poll(usb_dev: &mut UsbDevice, keyboard: &mut UsbClass) { - if usb_dev.poll(&mut [keyboard]) { - keyboard.poll(); - } -} -- cgit v1.2.3