EDF - OnePIC MCU  v1.1.0
source/8bit_IR/OnePIC_8bit_demo_isr.c
Go to the documentation of this file.
00001 
00013 #include "OnePIC_int.h"
00014 #include "OnePIC_timer.h"
00015 #include "mTouchCVD.h"
00016 #include "bsp.h"
00017 
00018 #include <htc.h>
00019 
00020 #include "OnePIC_8bit_demo_isr.h"
00021 #include "OnePIC_8bit_demo_irda.h" //custom setup for IrDA RX interrupt
00022 #include "OnePIC_8bit_demo_main.h"
00023 
00024 #ifdef WIRELESS_DEMO //exclude this if only using the base code
00025 
00031 extern IR_DEMO_RX rx_byte;
00032 extern IR_DEMO_FLAG rx_tx_flag;
00033 
00045 void interrupt ISR(void) {
00046     //mTouch Interrupt
00047     if (EDF_INT_SourceFlagGet(INT_TMR_2)) {
00048         EDF_INT_SourceFlagClear(INT_TMR_2); //clear flag
00049         mTouch_Scan(); //scan the touch buttons
00050         EDF_TMR_CounterSet(TMR_2, 255);
00051         
00052     }
00053 
00054     //IrDA Demo - Poll RX pin
00055     if (EDF_INT_SourceFlagGet(INT_TMR_4)) {
00056         EDF_INT_SourceFlagClear(INT_TMR_4);
00057         if (!IRDA_RX) { //UART Start Bit is active LOW
00058             rx_byte.irda_rx = irda_getch(); //get the byte NOW!
00059             rx_tx_flag.IRDA_RX_FLAG = 1; //print to the LCD out of the ISR
00060         }
00061     }
00062     //IrDA Demo - MCP2200 RX flag
00063     if (UART_RX_INTERRUPT) {
00064         UART_RX_INTERRUPT = 0;
00065         rx_byte.mcp2200_rx = UART_RX_REGISTER; //must do this to clear interrupt (empty RCREG)
00066         rx_tx_flag.MCP2200_RX_FLAG = 1;
00067     }
00068 }
00069 #endif
00070