interrupt_example_iar.c

Go to the documentation of this file.
00001 /* ************************************************************************
00002 
00003 Copyright (c) 2006, Atmel Corporation All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice,
00009 this list of conditions and the
00010 following disclaimer.
00011 
00012 2. Redistributions in binary form must reproduce the above copyright notice,
00013 this list of conditions and the following disclaimer in the documentation
00014 and/or other materials provided with the distribution.
00015 
00016 3. The name of ATMEL may not be used to endorse or promote products
00017 derived from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS
00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00022 PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY
00023 DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00027 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00028 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
00030 WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 
00032 POSSIBILITY OF SUCH DAMAGE.
00033 ************************************************************************ */
00034 
00035 
00036 /*
00037   NOTE:
00038     To get this example to work on your stk1000, connect J6 to J15 and J3 to
00039     J25. You can then press the switches to generate an interrupt. The
00040     corresponding led will be lit to indicate that the interrupt has triggered.
00041 
00042     This appnote uses the PIO controller. The settings and configuration of the
00043     PIO controller is not a part of this appnote. Please read the appnote "Using
00044     the AVR32 pio controller" for further information.
00045 */
00046 
00047 #include <avr32/ioap7000.h>
00048 #include <intrinsics.h>
00049 
00050 #define SUCCESS 0;
00051 #define ERROR  -1;
00052 
00053 #define INPUT_MASK 0x000000ff
00054 #define OUTPUT_MASK 0x0000ff00
00055 
00062 #pragma handler=AVR32_PIOC_IRQ_GROUP,2
00063 __interrupt __root void pioc_interrupt_handler()
00064 {
00065   volatile struct avr32_pio_t *pioc = &AVR32_PIOC;
00066   int status;
00067 
00068   status = pioc->isr;
00069   status = pioc->pdsr;
00070   pioc->odsr =~(status&INPUT_MASK)<<8; /* set led */
00071 }
00072 
00078 int main( void )
00079 {
00080   volatile struct avr32_pio_t *pioc = &AVR32_PIOC;
00081 
00082   /*
00083   Setup the PIO controller. Set PIOC[8..15] as output, PIOC[0..7] as input.
00084   */
00085 
00086   pioc->oer = OUTPUT_MASK;
00087   pioc->odr= INPUT_MASK;
00088   pioc->per = OUTPUT_MASK&INPUT_MASK;
00089   pioc->codr = INPUT_MASK & OUTPUT_MASK;
00090   pioc->puer = INPUT_MASK & OUTPUT_MASK;
00091 
00092   pioc->idr &= ~INPUT_MASK;
00093   pioc->ier = INPUT_MASK;
00094   pioc->ower = OUTPUT_MASK;
00095 
00096   __enable_interrupt();
00097 
00098   while(1);
00099 
00100 }

Generated on Wed May 10 15:23:22 2006 for AVR32101 The AVR32 Interrupt Controller by  doxygen 1.4.6