mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-28 17:52:28 +00:00
stm32: add usb_hid_mouse example
Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
This commit is contained in:
parent
315fb040ee
commit
61653229b6
@ -10,8 +10,8 @@ use embassy_time::Timer;
|
|||||||
use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State};
|
use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State};
|
||||||
use embassy_usb::control::OutResponse;
|
use embassy_usb::control::OutResponse;
|
||||||
use embassy_usb::Builder;
|
use embassy_usb::Builder;
|
||||||
use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
|
|
||||||
use futures::future::join;
|
use futures::future::join;
|
||||||
|
use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -127,22 +127,22 @@ join(usb_fut, hid_fut).await;
|
|||||||
struct MyRequestHandler {}
|
struct MyRequestHandler {}
|
||||||
|
|
||||||
impl RequestHandler for MyRequestHandler {
|
impl RequestHandler for MyRequestHandler {
|
||||||
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
|
fn get_report(&self, id: ReportId, _buf: &mut [u8]) -> Option<usize> {
|
||||||
info!("Get report for {:?}", id);
|
info!("Get report for {:?}", id);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
|
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
|
||||||
info!("Set report for {:?}: {=[u8]}", id, data);
|
info!("Set report for {:?}: {=[u8]}", id, data);
|
||||||
OutResponse::Accepted
|
OutResponse::Accepted
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) {
|
fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) {
|
||||||
info!("Set idle rate for {:?} to {:?}", id, dur);
|
info!("Set idle rate for {:?} to {:?}", id, dur);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> {
|
fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> {
|
||||||
info!("Get idle rate for {:?}", id);
|
info!("Get idle rate for {:?}", id);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user