USB Wakeup u2 Series fix
Now working with HoodLoader2. Also got the chance to test the features on a PC where USB wakeup is supported. It seems to work now properly.
This commit is contained in:
parent
73f08effc0
commit
1fb53348e7
2 changed files with 14 additions and 30 deletions
36
USBCore.cpp
36
USBCore.cpp
|
|
@ -654,32 +654,6 @@ void USB_Flush(u8 ep)
|
|||
ReleaseTX();
|
||||
}
|
||||
|
||||
// edit by NicoHood
|
||||
// added from teensy definition by paul stoffregen
|
||||
//TODO remove, not needed anymore
|
||||
#if defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)
|
||||
#define HW_CONFIG()
|
||||
#define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
|
||||
#define USB_CONFIG() (USBCON = (1<<USBE))
|
||||
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
|
||||
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
|
||||
#define HW_CONFIG() (UHWCON = 0x01)
|
||||
#define PLL_CONFIG() (PLLCSR = 0x12)
|
||||
#define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
|
||||
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
|
||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1287__)
|
||||
#define HW_CONFIG() (UHWCON = 0x81)
|
||||
#define PLL_CONFIG() (PLLCSR = 0x1A)
|
||||
#define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
|
||||
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
|
||||
#elif defined(__AVR_AT90USB1286__)
|
||||
#define HW_CONFIG() (UHWCON = 0x81)
|
||||
#define PLL_CONFIG() (PLLCSR = 0x16)
|
||||
#define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
|
||||
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
|
||||
#endif
|
||||
|
||||
|
||||
static inline void USB_ClockDisable()
|
||||
{
|
||||
#if defined(OTGPADE)
|
||||
|
|
@ -707,6 +681,16 @@ static inline void USB_ClockEnable()
|
|||
#error "Clock rate of F_CPU not supported"
|
||||
#endif
|
||||
|
||||
#elif defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)
|
||||
// for the u2 Series the datasheet is confusing. On page 40 its called PINDIV and on page 290 its called PLLP0
|
||||
#if F_CPU == 16000000UL
|
||||
// Need 16 MHz xtal
|
||||
PLLCSR |= (1 << PLLP0);
|
||||
#elif F_CPU == 8000000UL
|
||||
// Need 8 MHz xtal
|
||||
PLLCSR &= ~(1 << PLLP0);
|
||||
#endif
|
||||
|
||||
// AT90USB646, AT90USB647, AT90USB1286, AT90USB1287
|
||||
#elif defined(PLLP2)
|
||||
#if F_CPU == 16000000UL
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ void setup() {
|
|||
pinMode(8, INPUT_PULLUP);
|
||||
pinMode(9, INPUT_PULLUP);
|
||||
pinMode(10, INPUT_PULLUP);
|
||||
pinMode(11, INPUT_PULLUP);
|
||||
pinMode(12, INPUT_PULLUP);
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
pinMode(3, INPUT_PULLUP);
|
||||
|
||||
// 6374 292
|
||||
Keyboard.begin();
|
||||
|
|
@ -47,13 +47,13 @@ void loop() {
|
|||
Keyboard.releaseAll();
|
||||
delay(300);
|
||||
}
|
||||
if (!digitalRead(11)) {
|
||||
if (!digitalRead(2)) {
|
||||
digitalWrite(13, 1);
|
||||
System.write(SYSTEM_SLEEP);
|
||||
delay(300);
|
||||
digitalWrite(13, 0);
|
||||
}
|
||||
if (!digitalRead(12)) {
|
||||
if (!digitalRead(3)) {
|
||||
digitalWrite(13, 1);
|
||||
USBDevice.wakeupHost();
|
||||
delay(300);
|
||||
|
|
|
|||
Loading…
Reference in a new issue