]> mj.ucw.cz Git - home-hw.git/commitdiff
Clock firmware: Fix USB restart
authorMartin Mares <mj@ucw.cz>
Sun, 14 May 2023 13:31:42 +0000 (15:31 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 14 May 2023 13:31:42 +0000 (15:31 +0200)
clock/firmware/main.c

index 50ce5676603346138c5d34e02eec81ca1ccbe410..27de39d7aef1dd234a3e26ba9ef4d26585537d88 100644 (file)
@@ -505,6 +505,9 @@ static void ep01_cb(usbd_device *dev, uint8_t ep UNUSED)
 
 static void ep82_send(u32 key_code)
 {
+       if (!usb_configured)
+               return;
+
        if (usb_tx_in_flight) {
                debug_printf("USB: Send overrun!\n");
                return;
@@ -533,6 +536,7 @@ static void set_config_cb(usbd_device *dev, uint16_t wValue UNUSED)
        usbd_ep_setup(dev, 0x01, USB_ENDPOINT_ATTR_BULK, 64, ep01_cb);
        usbd_ep_setup(dev, 0x82, USB_ENDPOINT_ATTR_BULK, 4, ep82_cb);
        usb_configured = true;
+       usb_tx_in_flight = false;
 }
 
 static void reset_cb(void)