From 574b0cb4fe90ca862af4bf8aae65b2082cf2d469 Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Tue, 23 Sep 2025 20:30:34 +0200 Subject: [PATCH] Add fast blinking after reset --- src/main.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 20d6c98..0136bce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,8 +116,6 @@ fn main() -> ! { .self_powered(false) .build(); - let mut start_time: u64 = 0; - let mut storage: [u8; (DISK_BLOCK_SIZE * DISK_BLOCK_NUM) as usize] = [0u8; (DISK_BLOCK_SIZE * DISK_BLOCK_NUM) as usize]; const LBA: u32 = DISK_BLOCK_NUM - 1; @@ -177,20 +175,26 @@ fn main() -> ! { defmt::info!("entering main loop"); + let mut start_time: u64 = 0; loop { - let interval = match (usb_device.state(), led_pin.is_set_high().unwrap_or_else(|_| false)) { - // The USB device has just been created or reset. - (UsbDeviceState::Default, true) => 100_000, - (UsbDeviceState::Default, false) => 100_000, - // The USB device has received an address from the host. - (UsbDeviceState::Addressed, true) => 250_000, - (UsbDeviceState::Addressed, false) => 250_000, - // The USB device has been configured and is fully functional. - (UsbDeviceState::Configured, true) => 1_000_000, - (UsbDeviceState::Configured, false) => 0, - // The USB device has been suspended by the host or it has been unplugged from the USB bus. - (UsbDeviceState::Suspend, true) => 25_000, - (UsbDeviceState::Suspend, false) => 2_000_000, + let interval = if timer.get_counter().ticks() < 2_000_000 { + 25_000 + } + else { + match (usb_device.state(), led_pin.is_set_high().unwrap_or_else(|_| false)) { + // The USB device has just been created or reset. + (UsbDeviceState::Default, true) => 100_000, + (UsbDeviceState::Default, false) => 100_000, + // The USB device has received an address from the host. + (UsbDeviceState::Addressed, true) => 250_000, + (UsbDeviceState::Addressed, false) => 250_000, + // The USB device has been configured and is fully functional. + (UsbDeviceState::Configured, true) => 1_000_000, + (UsbDeviceState::Configured, false) => 0, + // The USB device has been suspended by the host or it has been unplugged from the USB bus. + (UsbDeviceState::Suspend, true) => 25_000, + (UsbDeviceState::Suspend, false) => 2_000_000, + } }; if timer.get_counter().ticks() - start_time > interval { let _ = led_pin.toggle();