projekty/Source/example1/src/Interrupt.c

Go to the documentation of this file.
00001 /*
00002  * $Id: Interrupt.c,v 1 2005/06/06 17:44:00 BorisK Exp $
00003  *
00004  * Copyright (C) 2005 ONTRACK s.r.o.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA    
00019  * 02111-1307, USA.
00020  *
00021  * [1] ARM-based Microcontroller LPC2119/2129/2194/2292/9994, "Preliminary User Manual", February 03, 2004
00022  *
00023  * Written by Boris Kralik <kralikbo@yahoo.com>, 2005
00024  *
00025  */
00026 #include "Interrupt.h"
00027 #include "./include/lpc229x.h"
00028 #include "./include/lpcTMR.h"
00029 #include "./include/lpcVIC.h"
00030 #include "./include/lpcSCB.h"
00031 #include "sysTime.h"
00032 /************************************************************************************
00033         Name:           INT_Initialize
00034         Description:    Initialization Interrupt vectors
00035         Parameters:     void
00036         Return:         void
00037 ************************************************************************************/
00038 void INT_Initialize(void)
00039 {
00040         disableIRQ();
00041         WD_Reset();
00042         VICIntEnClear   =       0xFFFFFFFF;     // clear all interrupts
00043         VICIntSelect    =       0x00000000;     // clear all FIQ selections
00044         VICDefVectAddr  =       0x00000000;     // point unvectored IRQs to reset()
00045         enableIRQ();
00046 }
00047 /***********************************************************************************
00048         Name:           ADC_interrupt
00049         Description:    ADC interrupt routines
00050         Parameters:     void
00051         Return:         void
00052 ************************************************************************************/
00053 #define TRI (3.06/1023)//0.002988
00054 void ADC_interrupt(void)
00055 {
00056         disableIRQ();
00057         ADC_int();
00058         VICVectAddr = 0;       // Acknowledge Interrupt
00059         enableIRQ();
00060 }
00061 
00062 void CAN_LUT_interrupt()
00063 {
00064         disableIRQ();
00065         #if 0
00066                 printf("\n\rCAN_LUT:0x%X\n\rCAN_LUTERR:0x%X",CAN_LUT,CAN_LUTERR);
00067         #endif
00068         VICVectAddr     =       0;              //Signal the end of interrupt
00069         LUT_interrupt();
00070         enableIRQ();
00071 }
00072 void CAN1_TX_interrupt (void)
00073 {
00074         disableIRQ();
00075         CAN1_CMR        =       0x00000004;             //release the recieve buffer
00076         VICVectAddr     =       0;              //Signal the end of interrupt
00077         enableIRQ();
00078 }
00079 void CAN1_RX_interrupt (void)
00080 {
00081         //????IOCLR1    =       ~C1RDA<<8;              //clear output pins
00082         //??IOSET1      =       C1RDA<<8;               //set output pins
00083         disableIRQ();
00084         #if 1
00085                 printf("\n\rCAN1_RX_interrupt");
00086         #endif
00087         CAN1_CMR        =       0x00000004;             //release the recieve buffer
00088         VICVectAddr     =       0;              //Signal the end of interrupt
00089         enableIRQ();
00090 }
00091         
00092 
00093 /***********************************************************************************
00094         Name:           EINT1_interrupt
00095         Description:    EXT1 interrupt routines
00096         Parameters:     void
00097         Return:         void
00098 ************************************************************************************/
00099 void 
00100 _EINT1_interrupt(void)
00101 {
00102         disableIRQ();
00103         #if 0
00104                 UARTWriteStr("\n\rExt 1 Interrupt");
00105         #endif
00106         SCB_EXTINT = 0x00000002;//Must be, clear interrupt
00107         VICVectAddr = 0;       // Acknowledge Interrupt
00108         //EINT();
00109         enableIRQ();
00110 }
00111 /***********************************************************************************
00112         Name:           TIMER0_interrupt
00113         Description:    TIMER0  interrupt routines
00114         Parameters:     void
00115         Return:         void
00116 ************************************************************************************/
00117 void TIMER0_interrupt(void)
00118 {
00119         disableIRQ();
00120         #if 0
00121                 UARTWriteStr("\n\rTIMER0_interrupt");
00122         #endif
00123         T0_IR   |=      0x1;
00124         T0_IR |= (1 << 4);      // Clear interrupt flag by writing 1 to Bit 4
00125         VICVectAddr = 0;        // Acknowledge Interrupt (rough?)
00126         enableIRQ();
00127 }
00128 /***********************************************************************************
00129         Name:           TIMER1_interrupt
00130         Description:    TIMER1  interrupt routines
00131         Parameters:     void
00132         Return:         void
00133 ************************************************************************************/
00134 void TIMER1_interrupt(void)
00135 {
00136         disableIRQ();
00137         #if 0
00138                 UARTWriteStr("\n\rTIMER1_interrupt");
00139         #endif
00140         T1_IR |= (1 << 4);      // Clear interrupt flag by writing 1 to Bit 4
00141         VICVectAddr = 0;        // Acknowledge Interrupt (rough?)
00142         TIMER_Int();
00143         enableIRQ();
00144 }
00145 /***********************************************************************************
00146         Name:           RTC_interrupt
00147         Description:    RealTimeClock interrupt routines
00148         Parameters:     void
00149         Return:         void
00150 ************************************************************************************/
00151 void
00152 RTC_interrupt(void)
00153 {
00154         disableIRQ();
00155         #if DBG
00156                 UARTWriteStr("Alarm occours;");
00157         #endif
00158         VICVectAddr = 0;       // Acknowledge Interrupt
00159         enableIRQ();
00160 }
00161 
00162 void UART0_interrupt(void)
00163 {
00164         disableIRQ();
00165         #if 1
00166                 UARTWriteStr("UART0_interrupt");//UART0
00167         #endif
00168         enableIRQ();
00169         VICVectAddr = 0;       // Acknowledge Interrupt (rough?)
00170 }
00171 
00172 /*      
00173         name of function: SetEXT1
00174         parameters:     mode    H-edge sensitive else level sensitive
00175                         polar   H-falling edge else rising edge in edge sensitive mode
00176         return:         void
00177 */
00178 
00179 void SetEXT1(char mode, char polar)
00180 {
00181         if (mode > 0)   
00182                 SCB_EXTMODE  |= (1 << 1);       // edge sensitive EXT_INT1
00183         else 
00184                 SCB_EXTMODE  &= (0 << 1);       // level sensitive EXT_INT1
00185         if (polar > 0) 
00186                 SCB_EXTPOLAR |= (1 << 1);       // falling edge sensitive, H=falling edge
00187         else
00188                 SCB_EXTPOLAR &= (0 << 1);       // rising edge sensitive , L=rising edge
00189 }

Generated on Fri Sep 21 13:41:54 2007 for example1 by  doxygen 1.4.7