aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/nrf/src')
-rw-r--r--examples/nrf/src/bin/usb_hid.rs40
1 files changed, 16 insertions, 24 deletions
diff --git a/examples/nrf/src/bin/usb_hid.rs b/examples/nrf/src/bin/usb_hid.rs
index 6ffb1fd40..741e234b6 100644
--- a/examples/nrf/src/bin/usb_hid.rs
+++ b/examples/nrf/src/bin/usb_hid.rs
@@ -3,9 +3,6 @@
3#![feature(generic_associated_types)] 3#![feature(generic_associated_types)]
4#![feature(type_alias_impl_trait)] 4#![feature(type_alias_impl_trait)]
5 5
6#[path = "../example_common.rs"]
7mod example_common;
8
9use core::mem; 6use core::mem;
10use defmt::*; 7use defmt::*;
11use embassy::executor::Spawner; 8use embassy::executor::Spawner;
@@ -20,6 +17,9 @@ use embassy_usb_hid::{HidClass, ReportId, RequestHandler, State};
20use futures::future::join; 17use futures::future::join;
21use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; 18use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
22 19
20use defmt_rtt as _; // global logger
21use panic_probe as _;
22
23#[embassy::main] 23#[embassy::main]
24async fn main(_spawner: Spawner, p: Peripherals) { 24async fn main(_spawner: Spawner, p: Peripherals) {
25 let clock: pac::CLOCK = unsafe { mem::transmute(()) }; 25 let clock: pac::CLOCK = unsafe { mem::transmute(()) };
@@ -81,30 +81,22 @@ async fn main(_spawner: Spawner, p: Peripherals) {
81 81
82 // Do stuff with the class! 82 // Do stuff with the class!
83 let hid_fut = async { 83 let hid_fut = async {
84 let mut y: i8 = 5;
84 loop { 85 loop {
85 Timer::after(Duration::from_millis(500)).await; 86 Timer::after(Duration::from_millis(500)).await;
86 hid.input()
87 .serialize(&MouseReport {
88 buttons: 0,
89 x: 0,
90 y: 4,
91 wheel: 0,
92 pan: 0,
93 })
94 .await
95 .unwrap();
96 87
97 Timer::after(Duration::from_millis(500)).await; 88 y = -y;
98 hid.input() 89 let report = MouseReport {
99 .serialize(&MouseReport { 90 buttons: 0,
100 buttons: 0, 91 x: 0,
101 x: 0, 92 y,
102 y: -4, 93 wheel: 0,
103 wheel: 0, 94 pan: 0,
104 pan: 0, 95 };
105 }) 96 match hid.input().serialize(&report).await {
106 .await 97 Ok(()) => {}
107 .unwrap(); 98 Err(e) => warn!("Failed to send report: {:?}", e),
99 }
108 } 100 }
109 }; 101 };
110 102