Partial commit: Rename USBFOO LED driver to fix capitalisation of file name, which...
[pub/USBasp.git] / Bootloaders / CDC / BootloaderCDC.c
index 99e0ccb..7695e33 100644 (file)
@@ -66,6 +66,9 @@ int main(void)
        /* Setup hardware required for the bootloader */
        SetupHardware();
 
+       /* Turn on first LED on the board to indicate that the bootloader has started */
+       LEDs_SetAllLEDs(LEDS_LED1);
+
        /* Enable global interrupts so that the USB stack can function */
        sei();
 
@@ -100,6 +103,17 @@ void SetupHardware(void)
 
        /* Initialize USB Subsystem */
        USB_Init();
+       LEDs_Init();
+       
+       /* Bootloader active LED toggle timer initialization */
+       TIMSK1 = (1 << TOIE1);
+       TCCR1B = ((1 << CS11) | (1 << CS10));   
+}
+
+/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
+ISR(TIMER1_OVF_vect, ISR_BLOCK)
+{
+       LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
 }
 
 /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
@@ -134,6 +148,9 @@ void EVENT_USB_Device_ControlRequest(void)
                return;
        }
 
+       /* Activity - toggle indicator LEDs */
+       LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
+
        /* Process CDC specific control requests */
        switch (USB_ControlRequest.bRequest)
        {
@@ -301,7 +318,7 @@ static uint8_t FetchNextCommandByte(void)
        }
 
        /* Fetch the next byte from the OUT endpoint */
-       return Endpoint_Read_Byte();
+       return Endpoint_Read_8();
 }
 
 /** Writes the next response byte to the CDC data IN endpoint, and sends the endpoint back if needed to free up the
@@ -327,7 +344,7 @@ static void WriteNextResponseByte(const uint8_t Response)
        }
 
        /* Write the next byte to the IN endpoint */
-       Endpoint_Write_Byte(Response);
+       Endpoint_Write_8(Response);
 }
 
 /** Task to read in AVR910 commands from the CDC data OUT endpoint, process them, perform the required actions