usb/hid: update for endpoint state changes.

This commit is contained in:
Dario Nieuwenhuis
2022-04-06 02:18:39 +02:00
parent fa9eadcee9
commit 6d514a0b31
2 changed files with 21 additions and 24 deletions

View File

@ -3,9 +3,6 @@
#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
#[path = "../example_common.rs"]
mod example_common;
use core::mem;
use defmt::*;
use embassy::executor::Spawner;
@ -20,6 +17,9 @@ use embassy_usb_hid::{HidClass, ReportId, RequestHandler, State};
use futures::future::join;
use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
use defmt_rtt as _; // global logger
use panic_probe as _;
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
@ -81,30 +81,22 @@ async fn main(_spawner: Spawner, p: Peripherals) {
// Do stuff with the class!
let hid_fut = async {
let mut y: i8 = 5;
loop {
Timer::after(Duration::from_millis(500)).await;
hid.input()
.serialize(&MouseReport {
buttons: 0,
x: 0,
y: 4,
wheel: 0,
pan: 0,
})
.await
.unwrap();
Timer::after(Duration::from_millis(500)).await;
hid.input()
.serialize(&MouseReport {
buttons: 0,
x: 0,
y: -4,
wheel: 0,
pan: 0,
})
.await
.unwrap();
y = -y;
let report = MouseReport {
buttons: 0,
x: 0,
y,
wheel: 0,
pan: 0,
};
match hid.input().serialize(&report).await {
Ok(()) => {}
Err(e) => warn!("Failed to send report: {:?}", e),
}
}
};