/****************************************************************************
 * arch/arm/include/samd2l2/samd20_irq.h
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.  The
 * ASF licenses this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 ****************************************************************************/

/* This file should never be included directly but, rather,
 * only indirectly through nuttx/irq.h
 */

#ifndef __ARCH_ARM_INCLUDE_SAMD2L2_SAMD20_IRQ_H
#define __ARCH_ARM_INCLUDE_SAMD2L2_SAMD20_IRQ_H

/****************************************************************************
 * Included Files
 ****************************************************************************/

/****************************************************************************
 * Pre-processor Prototypes
 ****************************************************************************/

/* External interrupts */

#define SAM_IRQ_PM         (SAM_IRQ_INTERRUPT+0)   /* Power Manager */
#define SAM_IRQ_SYSCTRL    (SAM_IRQ_INTERRUPT+1)   /* System Controller */
#define SAM_IRQ_WDT        (SAM_IRQ_INTERRUPT+2)   /* Watchdog Timer */
#define SAM_IRQ_RTC        (SAM_IRQ_INTERRUPT+3)   /* Real Time Counter */
#define SAM_IRQ_EIC        (SAM_IRQ_INTERRUPT+4)   /* External Interrupt Controller */
#define SAM_IRQ_NVMCTRL    (SAM_IRQ_INTERRUPT+5)   /* Non-Volatile Memory Controller */
#define SAM_IRQ_EVSYS      (SAM_IRQ_INTERRUPT+6)   /* Event System */
#define SAM_IRQ_SERCOM0    (SAM_IRQ_INTERRUPT+7)   /* Serial Communication Interface 0 */
#define SAM_IRQ_SERCOM1    (SAM_IRQ_INTERRUPT+8)   /* Serial Communication Interface 1 */
#define SAM_IRQ_SERCOM2    (SAM_IRQ_INTERRUPT+9)   /* Serial Communication Interface 2 */
#define SAM_IRQ_SERCOM3    (SAM_IRQ_INTERRUPT+10)  /* Serial Communication Interface 3 */
#define SAM_IRQ_SERCOM4    (SAM_IRQ_INTERRUPT+11)  /* Serial Communication Interface 4 */
#define SAM_IRQ_SERCOM5    (SAM_IRQ_INTERRUPT+12)  /* Serial Communication Interface 5 */
#define SAM_IRQ_TC0        (SAM_IRQ_INTERRUPT+13)  /* Timer/Counter 0 */
#define SAM_IRQ_TC1        (SAM_IRQ_INTERRUPT+14)  /* Timer/Counter 1 */
#define SAM_IRQ_TC2        (SAM_IRQ_INTERRUPT+15)  /* Timer/Counter 2 */
#define SAM_IRQ_TC3        (SAM_IRQ_INTERRUPT+16)  /* Timer/Counter 3 */
#define SAM_IRQ_TC4        (SAM_IRQ_INTERRUPT+17)  /* Timer/Counter 4 */
#define SAM_IRQ_TC5        (SAM_IRQ_INTERRUPT+18)  /* Timer/Counter 5 */
#define SAM_IRQ_TC6        (SAM_IRQ_INTERRUPT+19)  /* Timer/Counter 6 */
#define SAM_IRQ_TC7        (SAM_IRQ_INTERRUPT+20)  /* Timer/Counter 7 */
#define SAM_IRQ_ADC        (SAM_IRQ_INTERRUPT+21)  /* Analog-to-Digital Converter */
#define SAM_IRQ_AC         (SAM_IRQ_INTERRUPT+22)  /* Analog Comparator */
#define SAM_IRQ_DAC        (SAM_IRQ_INTERRUPT+23)  /* Digital-to-Analog Converter */
#define SAM_IRQ_PTC        (SAM_IRQ_INTERRUPT+24)  /* Peripheral Touch Controller*/

#define SAM_IRQ_NINTS      (25)                    /* Total number of interrupts */
#define SAM_IRQ_NIRQS      (SAM_IRQ_INTERRUPT+25)  /* The number of real interrupts */

/* GPIO interrupts.  Up to 16 pins may be configured to support interrupts */

#ifdef CONFIG_SAMD2L2_GPIOIRQ
#  define SAM_IRQ_EXTINT0  (SAM_IRQ_NIRQS+0)       /* External interrupt 0 */
#  define SAM_IRQ_EXTINT1  (SAM_IRQ_NIRQS+1)       /* External interrupt 1 */
#  define SAM_IRQ_EXTINT2  (SAM_IRQ_NIRQS+2)       /* External interrupt 2 */
#  define SAM_IRQ_EXTINT3  (SAM_IRQ_NIRQS+3)       /* External interrupt 3 */
#  define SAM_IRQ_EXTINT4  (SAM_IRQ_NIRQS+4)       /* External interrupt 4 */
#  define SAM_IRQ_EXTINT5  (SAM_IRQ_NIRQS+5)       /* External interrupt 5 */
#  define SAM_IRQ_EXTINT6  (SAM_IRQ_NIRQS+6)       /* External interrupt 6 */
#  define SAM_IRQ_EXTINT7  (SAM_IRQ_NIRQS+7)       /* External interrupt 7 */
#  define SAM_IRQ_EXTINT8  (SAM_IRQ_NIRQS+8)       /* External interrupt 8 */
#  define SAM_IRQ_EXTINT9  (SAM_IRQ_NIRQS+9)       /* External interrupt 9 */
#  define SAM_IRQ_EXTINT10 (SAM_IRQ_NIRQS+10)      /* External interrupt 10 */
#  define SAM_IRQ_EXTINT11 (SAM_IRQ_NIRQS+11)      /* External interrupt 11 */
#  define SAM_IRQ_EXTINT12 (SAM_IRQ_NIRQS+12)      /* External interrupt 12 */
#  define SAM_IRQ_EXTINT13 (SAM_IRQ_NIRQS+13)      /* External interrupt 13 */
#  define SAM_IRQ_EXTINT14 (SAM_IRQ_NIRQS+14)      /* External interrupt 14 */
#  define SAM_IRQ_EXTINT15 (SAM_IRQ_NIRQS+15)      /* External interrupt 15 */
#  define SAM_IRQ_NEXTINTS 16
#else
#  define SAM_IRQ_NEXTINTS 0
#endif

/* Total number of IRQ numbers */

#define NR_IRQS            (SAM_IRQ_INTERRUPT + SAM_IRQ_NINTS + SAM_IRQ_NEXTINTS)

/****************************************************************************
 * Public Types
 ****************************************************************************/

/****************************************************************************
 * Inline functions
 ****************************************************************************/

/****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif

#endif /* __ARCH_ARM_INCLUDE_SAMD2L2_SAMD20_IRQ_H */
