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
#define EEMEM
#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_RESTORESTATE
#define pgm_read_byte(x) *x
@ -105,6 +105,8 @@
#define _delay_ms(x)
#define memcmp_P(...) memcmp(__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!
#endif

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

@ -84,6 +84,11 @@
};
/* 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)
{

@ -59,6 +59,8 @@ void USB_Init(
#if !defined(USE_STATIC_OPTIONS)
USB_Options = Options;
#endif
USB_INT_RegisterHandlers();
#if defined(USB_CAN_BE_BOTH)
if (Mode == USB_MODE_UID)
@ -103,17 +105,17 @@ void USB_ResetInterface(void)
bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;
#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].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].div = ((F_CLOCK / 2) / 48000000UL);
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 (UIDModeSelectEnabled)
{

@ -68,22 +68,29 @@
USB_INT_SUSPI = 3,
USB_INT_EORSTI = 4,
USB_INT_SOFI = 5,
USB_INT_RXSTPI = 6,
#endif
#if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))
USB_INT_HSOFI = 7,
USB_INT_DCONNI = 8,
USB_INT_DDISCI = 9,
USB_INT_RSTI = 10,
USB_INT_BCERRI = 11,
USB_INT_VBERRI = 12,
USB_INT_HSOFI = 6,
USB_INT_DCONNI = 7,
USB_INT_DDISCI = 8,
USB_INT_RSTI = 9,
USB_INT_BCERRI = 10,
USB_INT_VBERRI = 11,
#endif
};
/* ISR Prototypes: */
ISR(USB_GEN_vect);
/* 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)
{
{
switch (Interrupt)
{
case USB_INT_VBUSTI:
@ -107,9 +114,6 @@
case USB_INT_SOFI:
AVR32_USBB.UDINTESET.sofes = true;
break;
case USB_INT_RXSTPI:
// TODO
return;
#endif
#if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI:
@ -160,9 +164,6 @@
case USB_INT_SOFI:
AVR32_USBB.UDINTECLR.sofec = true;
break;
case USB_INT_RXSTPI:
// TODO
return;
#endif
#if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI:
@ -194,47 +195,56 @@
{
case USB_INT_VBUSTI:
AVR32_USBB.USBSTACLR.vbustic = true;
(void)AVR32_USBB.USBSTACLR;
break;
#if defined(USB_CAN_BE_BOTH)
case USB_INT_IDTI:
AVR32_USBB.USBSTACLR.idtic = true;
(void)AVR32_USBB.USBSTACLR;
break;
#endif
#if defined(USB_CAN_BE_DEVICE)
case USB_INT_WAKEUPI:
AVR32_USBB.UDINTCLR.wakeupc = true;
(void)AVR32_USBB.UDINTCLR;
break;
case USB_INT_SUSPI:
AVR32_USBB.UDINTCLR.suspc = true;
(void)AVR32_USBB.UDINTCLR;
break;
case USB_INT_EORSTI:
AVR32_USBB.UDINTCLR.eorstc = true;
(void)AVR32_USBB.UDINTCLR;
break;
case USB_INT_SOFI:
AVR32_USBB.UDINTCLR.sofc = true;
(void)AVR32_USBB.UDINTCLR;
break;
case USB_INT_RXSTPI:
// TODO
return;
#endif
#if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI:
AVR32_USBB.UHINTCLR.hsofic = true;
(void)AVR32_USBB.UHINTCLR;
break;
case USB_INT_DCONNI:
AVR32_USBB.UHINTCLR.dconnic = true;
(void)AVR32_USBB.UHINTCLR;
break;
case USB_INT_DDISCI:
AVR32_USBB.UHINTCLR.ddiscic = true;
(void)AVR32_USBB.UHINTCLR;
break;
case USB_INT_RSTI:
AVR32_USBB.UHINTCLR.rstic = true;
(void)AVR32_USBB.UHINTCLR;
break;
case USB_INT_BCERRI:
AVR32_USBB.USBSTACLR.bcerric = true;
(void)AVR32_USBB.USBSTACLR;
break;
case USB_INT_VBERRI:
AVR32_USBB.USBSTACLR.vberric = true;
(void)AVR32_USBB.USBSTACLR;
break;
#endif
}
@ -260,9 +270,6 @@
return AVR32_USBB.UDINTE.eorste;
case USB_INT_SOFI:
return AVR32_USBB.UDINTE.sofe;
case USB_INT_RXSTPI:
// TODO
return false;
#endif
#if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI:
@ -303,9 +310,6 @@
return AVR32_USBB.UDINT.eorst;
case USB_INT_SOFI:
return AVR32_USBB.UDINT.sof;
case USB_INT_RXSTPI:
// TODO
return false;
#endif
#if defined(USB_CAN_BE_HOST)
case USB_INT_HSOFI:

@ -53,6 +53,7 @@
* - 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
* - 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
* - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/
* - Linux Secure Storage Dongle: http://github.com/TomMD/teensy

Loading…
Cancel
Save