Add in USB_INT_RegisterHandlers() internal function to register the interrupt handler routines used by LUFA. Add dummy loads after clearing the interrupt lines according to the datasheet.

Add in temporary global interrupts enable/disable macros.
pull/1469/head
Dean Camera 14 years ago
parent 86a2be8536
commit 8c6f26e19d

@ -95,7 +95,7 @@
// TODO // TODO
#define EEMEM #define EEMEM
#define PROGMEM const #define PROGMEM const
#define ISR(Name) void Name (void) #define ISR(Name) void Name (void) __attribute__((__interrupt__)); void Name (void)
#define ATOMIC_BLOCK(x) if (1) #define ATOMIC_BLOCK(x) if (1)
#define ATOMIC_RESTORESTATE #define ATOMIC_RESTORESTATE
#define pgm_read_byte(x) *x #define pgm_read_byte(x) *x
@ -105,6 +105,8 @@
#define _delay_ms(x) #define _delay_ms(x)
#define memcmp_P(...) memcmp(__VA_ARGS__) #define memcmp_P(...) memcmp(__VA_ARGS__)
#define memcpy_P(...) memcpy(__VA_ARGS__) #define memcpy_P(...) memcpy(__VA_ARGS__)
#define cpu_irq_enable() do { asm volatile("" ::: "memory"); __builtin_csrf(AVR32_SR_GM_OFFSET); } while (0)
#define cpu_irq_disable() do { __builtin_ssrf(AVR32_SR_GM_OFFSET); asm volatile("" ::: "memory"); } while (0)
#warning The UC3B architecture support is currently experimental and incomplete! #warning The UC3B architecture support is currently experimental and incomplete!
#endif #endif

@ -60,6 +60,8 @@ void USB_Init(
USB_Options = Options; USB_Options = Options;
#endif #endif
USB_INT_RegisterHandlers();
if (!(USB_Options & USB_OPT_REG_DISABLED)) if (!(USB_Options & USB_OPT_REG_DISABLED))
USB_REG_On(); USB_REG_On();
else else

@ -84,6 +84,11 @@
}; };
/* Inline Functions: */ /* Inline Functions: */
static inline void USB_INT_RegisterHandlers(void)
{
// Not required for AVR8
}
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
static inline void USB_INT_Enable(const uint8_t Interrupt) static inline void USB_INT_Enable(const uint8_t Interrupt)
{ {

@ -60,6 +60,8 @@ void USB_Init(
USB_Options = Options; USB_Options = Options;
#endif #endif
USB_INT_RegisterHandlers();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (Mode == USB_MODE_UID) if (Mode == USB_MODE_UID)
{ {
@ -103,17 +105,17 @@ void USB_ResetInterface(void)
bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide; bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;
#endif #endif
USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();
USB_Controller_Reset();
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC); AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0); AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].diven = (F_CLOCK != 48000000UL); AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].diven = (F_CLOCK != 48000000UL);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].div = ((F_CLOCK / 2) / 48000000UL); AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].div = ((F_CLOCK / 2) / 48000000UL);
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].cen = true; AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].cen = true;
USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();
USB_Controller_Reset();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (UIDModeSelectEnabled) if (UIDModeSelectEnabled)
{ {

@ -68,19 +68,26 @@
USB_INT_SUSPI = 3, USB_INT_SUSPI = 3,
USB_INT_EORSTI = 4, USB_INT_EORSTI = 4,
USB_INT_SOFI = 5, USB_INT_SOFI = 5,
USB_INT_RXSTPI = 6,
#endif #endif
#if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)) #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))
USB_INT_HSOFI = 7, USB_INT_HSOFI = 6,
USB_INT_DCONNI = 8, USB_INT_DCONNI = 7,
USB_INT_DDISCI = 9, USB_INT_DDISCI = 8,
USB_INT_RSTI = 10, USB_INT_RSTI = 9,
USB_INT_BCERRI = 11, USB_INT_BCERRI = 10,
USB_INT_VBERRI = 12, USB_INT_VBERRI = 11,
#endif #endif
}; };
/* ISR Prototypes: */
ISR(USB_GEN_vect);
/* Inline Functions: */ /* Inline Functions: */
static inline void USB_INT_RegisterHandlers(void)
{
AVR32_INTC.IPR[AVR32_USBB_IRQ % 32].autovector = (uintptr_t)&USB_GEN_vect;
}
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
static inline void USB_INT_Enable(const uint8_t Interrupt) static inline void USB_INT_Enable(const uint8_t Interrupt)
{ {
@ -107,9 +114,6 @@
case USB_INT_SOFI: case USB_INT_SOFI:
AVR32_USBB.UDINTESET.sofes = true; AVR32_USBB.UDINTESET.sofes = true;
break; break;
case USB_INT_RXSTPI:
// TODO
return;
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI: case USB_INT_HSOFI:
@ -160,9 +164,6 @@
case USB_INT_SOFI: case USB_INT_SOFI:
AVR32_USBB.UDINTECLR.sofec = true; AVR32_USBB.UDINTECLR.sofec = true;
break; break;
case USB_INT_RXSTPI:
// TODO
return;
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI: case USB_INT_HSOFI:
@ -194,47 +195,56 @@
{ {
case USB_INT_VBUSTI: case USB_INT_VBUSTI:
AVR32_USBB.USBSTACLR.vbustic = true; AVR32_USBB.USBSTACLR.vbustic = true;
(void)AVR32_USBB.USBSTACLR;
break; break;
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
case USB_INT_IDTI: case USB_INT_IDTI:
AVR32_USBB.USBSTACLR.idtic = true; AVR32_USBB.USBSTACLR.idtic = true;
(void)AVR32_USBB.USBSTACLR;
break; break;
#endif #endif
#if defined(USB_CAN_BE_DEVICE) #if defined(USB_CAN_BE_DEVICE)
case USB_INT_WAKEUPI: case USB_INT_WAKEUPI:
AVR32_USBB.UDINTCLR.wakeupc = true; AVR32_USBB.UDINTCLR.wakeupc = true;
(void)AVR32_USBB.UDINTCLR;
break; break;
case USB_INT_SUSPI: case USB_INT_SUSPI:
AVR32_USBB.UDINTCLR.suspc = true; AVR32_USBB.UDINTCLR.suspc = true;
(void)AVR32_USBB.UDINTCLR;
break; break;
case USB_INT_EORSTI: case USB_INT_EORSTI:
AVR32_USBB.UDINTCLR.eorstc = true; AVR32_USBB.UDINTCLR.eorstc = true;
(void)AVR32_USBB.UDINTCLR;
break; break;
case USB_INT_SOFI: case USB_INT_SOFI:
AVR32_USBB.UDINTCLR.sofc = true; AVR32_USBB.UDINTCLR.sofc = true;
(void)AVR32_USBB.UDINTCLR;
break; break;
case USB_INT_RXSTPI:
// TODO
return;
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI: case USB_INT_HSOFI:
AVR32_USBB.UHINTCLR.hsofic = true; AVR32_USBB.UHINTCLR.hsofic = true;
(void)AVR32_USBB.UHINTCLR;
break; break;
case USB_INT_DCONNI: case USB_INT_DCONNI:
AVR32_USBB.UHINTCLR.dconnic = true; AVR32_USBB.UHINTCLR.dconnic = true;
(void)AVR32_USBB.UHINTCLR;
break; break;
case USB_INT_DDISCI: case USB_INT_DDISCI:
AVR32_USBB.UHINTCLR.ddiscic = true; AVR32_USBB.UHINTCLR.ddiscic = true;
(void)AVR32_USBB.UHINTCLR;
break; break;
case USB_INT_RSTI: case USB_INT_RSTI:
AVR32_USBB.UHINTCLR.rstic = true; AVR32_USBB.UHINTCLR.rstic = true;
(void)AVR32_USBB.UHINTCLR;
break; break;
case USB_INT_BCERRI: case USB_INT_BCERRI:
AVR32_USBB.USBSTACLR.bcerric = true; AVR32_USBB.USBSTACLR.bcerric = true;
(void)AVR32_USBB.USBSTACLR;
break; break;
case USB_INT_VBERRI: case USB_INT_VBERRI:
AVR32_USBB.USBSTACLR.vberric = true; AVR32_USBB.USBSTACLR.vberric = true;
(void)AVR32_USBB.USBSTACLR;
break; break;
#endif #endif
} }
@ -260,9 +270,6 @@
return AVR32_USBB.UDINTE.eorste; return AVR32_USBB.UDINTE.eorste;
case USB_INT_SOFI: case USB_INT_SOFI:
return AVR32_USBB.UDINTE.sofe; return AVR32_USBB.UDINTE.sofe;
case USB_INT_RXSTPI:
// TODO
return false;
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI: case USB_INT_HSOFI:
@ -303,9 +310,6 @@
return AVR32_USBB.UDINT.eorst; return AVR32_USBB.UDINT.eorst;
case USB_INT_SOFI: case USB_INT_SOFI:
return AVR32_USBB.UDINT.sof; return AVR32_USBB.UDINT.sof;
case USB_INT_RXSTPI:
// TODO
return false;
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI: case USB_INT_HSOFI:

@ -53,6 +53,7 @@
* - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ * - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/
* - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html * - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html
* - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm * - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm
* - Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher
* - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove * - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove
* - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/ * - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/
* - Linux Secure Storage Dongle: http://github.com/TomMD/teensy * - Linux Secure Storage Dongle: http://github.com/TomMD/teensy

Loading…
Cancel
Save