Remove loop

This commit is contained in:
hodasemi 2024-03-11 10:58:41 +01:00
parent 9968ada7a0
commit ac2c05ec69

View file

@ -4,7 +4,6 @@ mod serial_config;
use numtoa::NumToA; use numtoa::NumToA;
use core::convert::Infallible;
use core::future::Future; use core::future::Future;
use embassy_rp::bind_interrupts; use embassy_rp::bind_interrupts;
@ -37,7 +36,7 @@ impl Serial<'static> {
pub fn new( pub fn new(
usb: USB, usb: USB,
serial_config: SerialConfig<'static>, serial_config: SerialConfig<'static>,
) -> (Serial<'static>, impl Future<Output = Infallible>) { ) -> (Serial<'static>, impl Future<Output = ()>) {
// Create the driver, from the HAL. // Create the driver, from the HAL.
let driver = Driver::new(usb, Irqs); let driver = Driver::new(usb, Irqs);
@ -84,15 +83,13 @@ impl Serial<'static> {
(Self { class }, Self::run_usb()) (Self { class }, Self::run_usb())
} }
fn run_usb() -> impl Future<Output = Infallible> { fn run_usb() -> impl Future<Output = ()> {
unsafe {
async { async {
loop { unsafe {
USB.as_mut().unwrap().run().await; USB.as_mut().unwrap().run().await;
} }
} }
} }
}
pub async fn send_msg(&mut self, s: &str) -> Result<(), EndpointError> { pub async fn send_msg(&mut self, s: &str) -> Result<(), EndpointError> {
self.class.write_packet(s.as_bytes()).await self.class.write_packet(s.as_bytes()).await