51e7a803e1e55541422fb9835e95fc1db704d37b
   3      Copyright (C) Dean Camera, 2010. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  32  *  \brief USB controller interrupt service routine management. 
  34  *  This file contains definitions required for the correct handling of low level USB service routine interrupts 
  35  *  from the USB controller. 
  37  *  \note This file should not be included directly. It is automatically included as needed by the USB driver 
  38  *        dispatch header located in LUFA/Drivers/USB/USB.h. 
  41 #ifndef __USBINTERRUPT_H__ 
  42 #define __USBINTERRUPT_H__ 
  46                 #include <avr/interrupt.h> 
  47                 #include <util/atomic.h> 
  50         /* Enable C linkage for C++ Compilers: */ 
  51                 #if defined(__cplusplus) 
  55         /* Preprocessor Checks: */ 
  56                 #if !defined(__INCLUDE_FROM_USB_DRIVER) 
  57                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. 
  60         /* Private Interface - For use in library only: */ 
  61         #if !defined(__DOXYGEN__) 
  63                         #define USB_INT_Enable(int)              MACROS{ USB_INT_GET_EN_REG(int)   |=   USB_INT_GET_EN_MASK(int);   }MACROE 
  64                         #define USB_INT_Disable(int)             MACROS{ USB_INT_GET_EN_REG(int)   &= ~(USB_INT_GET_EN_MASK(int));  }MACROE 
  65                         #define USB_INT_Clear(int)               MACROS{ USB_INT_GET_INT_REG(int)  &= ~(USB_INT_GET_INT_MASK(int)); }MACROE 
  66                         #define USB_INT_IsEnabled(int)                 ((USB_INT_GET_EN_REG(int)   &    USB_INT_GET_EN_MASK(int)) ? true : false) 
  67                         #define USB_INT_HasOccurred(int)               ((USB_INT_GET_INT_REG(int)  &    USB_INT_GET_INT_MASK(int)) ? true : false) 
  69                         #define USB_INT_GET_EN_REG(a, b, c, d)           a 
  70                         #define USB_INT_GET_EN_MASK(a, b, c, d)          b 
  71                         #define USB_INT_GET_INT_REG(a, b, c, d)          c 
  72                         #define USB_INT_GET_INT_MASK(a, b, c, d)         d 
  74                         #define USB_INT_VBUS                             USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI) 
  75                         #define USB_INT_IDTI                             USBCON, (1 << IDTE)   , USBINT, (1 << IDTI) 
  76                         #define USB_INT_WAKEUPI                          UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI) 
  77                         #define USB_INT_SUSPI                            UDIEN , (1 << SUSPE)  , UDINT , (1 << SUSPI) 
  78                         #define USB_INT_EORSTI                           UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI) 
  79                         #define USB_INT_DCONNI                           UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI) 
  80                         #define USB_INT_DDISCI                           UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI) 
  81                         #define USB_INT_BCERRI                           OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI) 
  82                         #define USB_INT_VBERRI                           OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI) 
  83                         #define USB_INT_SOFI                             UDIEN,  (1 << SOFE)   , UDINT , (1 << SOFI) 
  84                         #define USB_INT_HSOFI                            UHIEN,  (1 << HSOFE)  , UHINT , (1 << HSOFI) 
  85                         #define USB_INT_RSTI                             UHIEN , (1 << RSTE)   , UHINT , (1 << RSTI) 
  86                         #define USB_INT_SRPI                             OTGIEN, (1 << SRPE)   , OTGINT, (1 << SRPI) 
  87                         #define USB_INT_RXSTPI                           UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI) 
  90                         #include "../../../Common/Common.h" 
  91                         #include "../HighLevel/USBMode.h" 
  92                         #include "../HighLevel/Events.h" 
  93                         #include "USBController.h" 
  95                 /* Function Prototypes: */ 
  96                         void USB_INT_ClearAllInterrupts(void); 
  97                         void USB_INT_DisableAllInterrupts(void); 
 100         /* Disable C linkage for C++ Compilers: */ 
 101                 #if defined(__cplusplus)