From 8681c19dab1a5ff4158eacffb2e5cbd53ac7a578 Mon Sep 17 00:00:00 2001 From: Nico Date: Fri, 20 Feb 2015 14:45:25 +0100 Subject: [PATCH] Added No USB workaround to pins.h Due to a bad Leonardo Bootloader this is the only way (i know) to fix this bug right now. It no longer needs to be included in the sketch anymore, this will be compiled automatically now. --- avr/variants/leonardo_no_usb/no_usb_isr.cpp | 11 +++++++ avr/variants/micro_no_usb/no_usb_isr.cpp | 11 +++++++ .../Leonardo_Micro_NoUSB_Blink.ino | 31 ------------------- 3 files changed, 22 insertions(+), 31 deletions(-) create mode 100644 avr/variants/leonardo_no_usb/no_usb_isr.cpp create mode 100644 avr/variants/micro_no_usb/no_usb_isr.cpp delete mode 100644 examples/Projects/Leonardo_Micro_NoUSB_Blink/Leonardo_Micro_NoUSB_Blink.ino diff --git a/avr/variants/leonardo_no_usb/no_usb_isr.cpp b/avr/variants/leonardo_no_usb/no_usb_isr.cpp new file mode 100644 index 0000000..eec342f --- /dev/null +++ b/avr/variants/leonardo_no_usb/no_usb_isr.cpp @@ -0,0 +1,11 @@ +#include +#include + +// workaround for undefined USBCON has to be placed in every sketch +// otherwise the timings wont work correctly +// this is only needed for Leonardo/Micro boards and not for HoodLoader2 +// due to a better bootloader reset (usb clock does not run after programming) +ISR(USB_GEN_vect) +{ + UDINT = 0; +} \ No newline at end of file diff --git a/avr/variants/micro_no_usb/no_usb_isr.cpp b/avr/variants/micro_no_usb/no_usb_isr.cpp new file mode 100644 index 0000000..eec342f --- /dev/null +++ b/avr/variants/micro_no_usb/no_usb_isr.cpp @@ -0,0 +1,11 @@ +#include +#include + +// workaround for undefined USBCON has to be placed in every sketch +// otherwise the timings wont work correctly +// this is only needed for Leonardo/Micro boards and not for HoodLoader2 +// due to a better bootloader reset (usb clock does not run after programming) +ISR(USB_GEN_vect) +{ + UDINT = 0; +} \ No newline at end of file diff --git a/examples/Projects/Leonardo_Micro_NoUSB_Blink/Leonardo_Micro_NoUSB_Blink.ino b/examples/Projects/Leonardo_Micro_NoUSB_Blink/Leonardo_Micro_NoUSB_Blink.ino deleted file mode 100644 index 8309b26..0000000 --- a/examples/Projects/Leonardo_Micro_NoUSB_Blink/Leonardo_Micro_NoUSB_Blink.ino +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (c) 2014 NicoHood - See the readme for credit to other people. - - Leonardo_Micro_NoUSB_Blink - - Blinks Led and shows what workaround is needed to fix the timing. - This is not needed for HoodLoader2 devices any more. -*/ - - -// workaround for undefined USBCON has to be placed in every sketch -// otherwise the timings wont work correctly -ISR(USB_GEN_vect) -{ - UDINT = 0; -} - -// the setup function runs once when you press reset or power the board -void setup() { - // initialize digital pin 13 as an output. - pinMode(13, OUTPUT); -} - -// the loop function runs over and over again forever -void loop() { - digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) - delay(1000); // wait for a second - digitalWrite(13, LOW); // turn the LED off by making the voltage LOW - delay(1000); // wait for a second -}