__interrupt void Button1_ISR (void) { WORD i; if (GPIO_getInterruptStatus (BUTTON1_PORT, BUTTON1_PIN)){ for (i = 0x23FF; i > 0; i--){ //Cheap debounce. } if (GPIO_getInputPinValue(BUTTON1_PORT, BUTTON1_PIN)){ bButton1Pressed = TRUE; } } if (GPIO_getInterruptStatus (BUTTON2_PORT, BUTTON2_PIN)){ for (i = 0x23FF; i > 0; i--){ //Cheap debounce. } if (GPIO_getInputPinValue(BUTTON2_PORT, BUTTON2_PIN)){ bButton2Pressed = TRUE; } } GPIO_clearInterrupt(BUTTON2_PORT, BUTTON2_PIN); __bic_SR_register_on_exit(LPM3_bits); //Wake main from LPMx GPIO_clearInterrupt(BUTTON1_PORT, BUTTON1_PIN); __bic_SR_register_on_exit(LPM3_bits); //Wake main from LPMx }
void Port_1(void) { uint16_t irqStatus=0; static uint32_t last_press=0; irqStatus=GPIO_getInterruptStatus(GPIO_PORT_P1, NDRDY_PIN | TEST_SW_PIN | RESET_SW_PIN | SIMTEST_SW_PIN | SIMRESET_SW_PIN); if (irqStatus & NDRDY_PIN) { readyForPSAData=true; timer_lastIRQ=timer_ms; goodTransfer=true; totalTXLEDLoops=0; GPIO_clearInterrupt(NDRDY_PORT,NDRDY_PIN); } else if ((irqStatus & TEST_SW_PIN) || (irqStatus & SIMTEST_SW_PIN)) { if (timer_ms-last_press>250) { testBtn=true; last_press=timer_ms; } GPIO_clearInterrupt(SIMTEST_SW_PORT,SIMTEST_SW_PIN); GPIO_clearInterrupt(TEST_SW_PORT,TEST_SW_PIN); } else if (irqStatus & RESET_SW_PIN) { resetBtn=true; GPIO_clearInterrupt(RESET_SW_PORT,RESET_SW_PIN); } }
uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort) { uint_fast16_t pendingInts; uint32_t baseAddr; pendingInts = GPIO_getInterruptStatus(selectedPort, 0xFFFF); baseAddr = GPIO_PORT_TO_BASE[selectedPort]; ASSERT(baseAddr != 0xFFFF); switch (selectedPort) { case GPIO_PORT_P1: case GPIO_PORT_P3: case GPIO_PORT_P5: case GPIO_PORT_P7: case GPIO_PORT_P9: return (HWREG8(baseAddr + OFS_P1IE) & pendingInts); case GPIO_PORT_P2: case GPIO_PORT_P4: case GPIO_PORT_P6: case GPIO_PORT_P8: case GPIO_PORT_P10: return (HWREG8(baseAddr + OFS_P2IE) & pendingInts); case GPIO_PORT_PJ: return (HWREG16(baseAddr + OFS_PAIE) & pendingInts); default: return 0; } }
void Port_2(void) { uint16_t irqStatus=0; irqStatus=GPIO_getInterruptStatus(GPIO_PORT_P2,SIMRESET_SW_PIN); if (irqStatus & SIMRESET_SW_PIN) { resetBtn=true; GPIO_clearInterrupt(GPIO_PORT_P2,SIMRESET_SW_PIN); } }