interrupt_gcc.c

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00022 /* Copyright (c) 2006, Atmel Corporation All rights reserved.
00023  *
00024  * Redistribution and use in source and binary forms, with or without
00025  * modification, are permitted provided that the following conditions are met:
00026  *
00027  * 1. Redistributions of source code must retain the above copyright notice,
00028  * this list of conditions and the following disclaimer.
00029  *
00030  * 2. Redistributions in binary form must reproduce the above copyright notice,
00031  * this list of conditions and the following disclaimer in the documentation
00032  * and/or other materials provided with the distribution.
00033  *
00034  * 3. The name of ATMEL may not be used to endorse or promote products derived
00035  * from this software without specific prior written permission.
00036  *
00037  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00038  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00039  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00040  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00041  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00042  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00043  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00045  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00046  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00047  */
00048 
00049 #ifdef __GNUC__
00050 
00051 #include "interrupt_gcc.h"
00052 
00053 char *stringINT __attribute__((aligned(32)));
00054 int stringSizeINT;
00055 char *stringINT2 __attribute__((aligned(32)));
00056 int stringSizeINT2;
00057 
00058 
00061 __int_handler *pdc_interrupt_handler(void)
00062 {
00063     pdc_setTxNextBuf((void *) &USART_MODULE,
00064             pdc_translatePtr((void *)stringINT2), stringSizeINT2);
00065 
00066     return (void *) AVR32_RAR_INT0;
00067 }
00068 
00069 
00072 void init_usart_interrupts(void)
00073 {
00074     set_interrupts_base((void *) AVR32_INTC_ADDRESS);
00075 
00076     /* register_interrupt((__int_handler) INT_HANDLER_FUNC,
00077        GROUP,
00078        LINE,
00079        PRIORITY); */
00080     register_interrupt((__int_handler) pdc_interrupt_handler,
00081             USART_MODULE_IRQ / 32,
00082             USART_MODULE_IRQ % 32,
00083             INT0);
00084 }
00085 
00086 
00089 void start_interrupts(void)
00090 {
00091     pdc_disable((void *) &USART_MODULE);
00092 
00093     stringINT = "INT: AVR32 PDC application demo\r\n";
00094     stringSizeINT = 33;
00095     stringINT2 = "INT: AVR32 PDC application demo ENDTX int\r\n";
00096     stringSizeINT2 = 43;
00097 
00098     pdc_flushCache((void *)stringINT, stringSizeINT/4);
00099     pdc_flushCache((void *)stringINT2, stringSizeINT2/4);
00100 
00101     pdc_setTxBuf((void *) &USART_MODULE,
00102             pdc_translatePtr((void *)stringINT), stringSizeINT,
00103             pdc_translatePtr((void *)stringINT), stringSizeINT);
00104 
00105     /* Turn on ENDTX interrupts from USART */
00106     USART_MODULE.ier = AVR32_USART_IER_ENDTX_MASK;
00107     init_interrupts();
00108 
00109     pdc_enable((void *) &USART_MODULE);
00110 }
00111 
00112 
00115 void stop_interrupts(void)
00116 {
00117     USART_MODULE.idr = AVR32_USART_IDR_ENDTX_MASK;
00118 
00119     /* Wait for current PDC transfer to complete */
00120     do {
00121     } while(pdc_txBytesLeft((void *) &USART_MODULE) != 0);
00122 
00123     pdc_disable((void *) &USART_MODULE);
00124 }
00125 
00126 #endif /* #ifdef __GNUC__ */
00127 

Generated on Wed May 10 15:03:11 2006 for AVR32108 - Peripheral Direct Memory Access Driver by  doxygen 1.4.6-NO