Add fast blinking after reset

This commit is contained in:
Jakob Lechner 2025-09-23 20:30:34 +02:00
parent a9db8eeb4f
commit 574b0cb4fe

View file

@ -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,8 +175,13 @@ 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)) {
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,
@ -191,6 +194,7 @@ fn main() -> ! {
// 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();