usb-interrupt.c
00001 #include <AT91SAM7S64.h>
00002 #include <interrupt-utils.h>
00003 #include <usb-interrupt.h>
00004 #include <usb-api.h>
00005 #include <stdio.h>
00006
00007 static void
00008 usb_int_safe (void) __attribute__((noinline));
00009
00010 static void
00011 usb_int_safe (void)
00012 {
00013 unsigned int int_status;
00014
00015 int_status = *AT91C_UDP_ISR & *AT91C_UDP_IMR;
00016
00017 if (int_status & (AT91C_UDP_EP0 | AT91C_UDP_EP1 | AT91C_UDP_EP2
00018 | AT91C_UDP_EP3)) {
00019 unsigned int ep_index;
00020
00021 for (ep_index = 0; ep_index < 4; ep_index++) {
00022 if (int_status & (1<<ep_index)) {
00023 usb_arch_transfer_complete(ep_index);
00024 }
00025 }
00026 } else if (int_status & AT91C_UDP_ENDBUSRES) {
00027 *AT91C_UDP_ICR = AT91C_UDP_ENDBUSRES;
00028 usb_arch_reset_int();
00029 } else if (int_status & AT91C_UDP_RXSUSP) {
00030
00031 *AT91C_UDP_ICR = AT91C_UDP_RXSUSP;
00032 usb_arch_suspend_int();
00033 } else if (int_status & AT91C_UDP_RXRSM) {
00034
00035 *AT91C_UDP_ICR = AT91C_UDP_RXRSM;
00036 usb_arch_resume_int();
00037 } else if (int_status & AT91C_UDP_SOFINT) {
00038
00039 *AT91C_UDP_ICR = AT91C_UDP_SOFINT;
00040 } else if (int_status & AT91C_UDP_WAKEUP) {
00041
00042 *AT91C_UDP_ICR = AT91C_UDP_WAKEUP;
00043 } else {
00044 puts("Other USB interrupt");
00045 }
00046
00047
00048 }
00049
00050 void NACKEDFUNC
00051 usb_int (void)
00052 {
00053 ISR_STORE();
00054 ISR_ENABLE_NEST();
00055 usb_int_safe();
00056 ISR_DISABLE_NEST();
00057 *AT91C_AIC_EOICR = 0;
00058 ISR_RESTORE();
00059 }