firmware/interrupt.c
author root@rika
Thu, 23 Apr 2009 20:55:41 +0200
changeset 33 7a0c4b0354ba
parent 2 2f55e5dd591d
permissions -rw-r--r--
updated documentation
     1 /*
     2  * Project Frontplatte
     3  *
     4  * interrupt.c  -  handle interrupts
     5  *
     6  * This file is released under the GNU General Public License. Refer
     7  * to the COPYING file distributed with this package.
     8  *
     9  * (c) 2007 Carsten Presser cpresser AT fsing.uni-sb.de
    10  */
    11 
    12 
    13 
    14 #include <p18cxxx.h>
    15 #include "interrupt.h"
    16 
    17 
    18 #include "rc5.h"
    19 #include "myi2c.h"
    20 #include "user.h"
    21 #include "io_cfg.h"
    22 #include "delay.h"
    23 
    24 
    25 /** V A R I A B L E S **********************************************/
    26 unsigned char c;
    27 
    28 
    29 /** I N T E R R U P T  V E C T O R S *****************************************/
    30 #pragma code high_vector=0x0808 //(0x0808)
    31 void interrupt_at_high_vector(void)
    32 {
    33     _asm goto high_isr _endasm
    34 }
    35 #pragma code
    36 
    37 #pragma code low_vector=0x0818 //(0x0818)
    38 void interrupt_at_low_vector(void)
    39 {
    40     _asm goto low_isr _endasm
    41 }
    42 #pragma code
    43 
    44 
    45 /** C O D E ******************************************************************/
    46 #pragma interrupt high_isr
    47 void high_isr(void)
    48 {
    49 
    50 /* Timer0 */
    51 	if (INTCONbits.TMR0IF)
    52 	{
    53 		INTCONbits.TMR0IF 	= 0;	// clear flag
    54 		rc5_scrap();
    55 	}
    56 
    57 /* Infrared Interrupt */
    58 	if (INTCON3bits.INT2IF)
    59 	{
    60 		rc5_decode();
    61 
    62 		INTCON3bits.INT2IF	= 0;						// clear flag
    63 		INTCON2bits.INTEDG2 = !INTCON2bits.INTEDG2;		// toogle edge detect...
    64 	}
    65 }
    66 
    67 #pragma interruptlow low_isr
    68 void low_isr(void)
    69 {
    70 /* I2C Interrupt Line */
    71 	INTCONbits.GIEL		= 0;
    72 
    73 	if (INTCONbits.RBIF) 			// i2c_int
    74 	{
    75 		PORTB			= PORTB;	// end mismatch condition... (see page 114)
    76 		INTCONbits.RBIF	= 0;		// then clear the flag!
    77 	
    78 
    79 		if (PIN_I2C_INT == 0) 			// ignore falling edge
    80 		{
    81 			gg_ioflags |= FLAG_I2C;
    82 		}
    83 	} // end of i2c-int
    84 
    85 	if (PIR2bits.TMR3IF)
    86 	{
    87 		PIR2bits.TMR3IF = 0;
    88 		c++;
    89 		if (c > 0x08)
    90 		{
    91 			c = 0x00;
    92 			gg_ioflags |= FLAG_COUNTER;
    93 		}
    94 	}
    95 
    96 	INTCONbits.GIEL		= 1;
    97 }
    98 #pragma code