/*********************************************************************//** * @brief External interrupt 3 handler sub-routine * @param[in] None * @return None **********************************************************************/ void EINT3_IRQHandler(void) { int j; #ifdef MICROPENDOUS_X if (GPIO_GetIntStatus(2,10,1)) { GPIO_ClearInt(2,(1<<10)); #else if(GPIO_GetIntStatus(0, 25, 1)) { GPIO_ClearInt(0,(1<<25)); #endif for (j= 0; j<8; j++) { #ifdef MCB_LPC_1768 /* Use MCB1700 board: * blink LED P1.29 when EINT3 occur */ FIO_ByteSetValue(1, 3, INT3_LED); delay(); FIO_ByteClearValue(1, 3, INT3_LED); delay(); #elif defined(IAR_LPC_1768) /* Use IAR LPC1768 KS board: * blink LED2 P0.4 when EINT3 occur */ FIO_ByteSetValue(0, 0, INT3_LED); delay(); FIO_ByteClearValue(0, 0, INT3_LED); delay(); #elif defined(MICROPENDOUS_X) /* Use MICROPENDOUS_X board: * blink LED1 P1.18 when EINT3 occur */ FIO_ByteClearValue(1, 2, INT3_LED); delay(); FIO_ByteSetValue(1, 2, INT3_LED); delay(); #endif } } } /*-------------------------PRIVATE FUNCTIONS------------------------------*/ /*********************************************************************//** * @brief Delay function * @param[in] None * @return None **********************************************************************/ void delay (void) { unsigned int i; for (i = 0; i < 0x100000; i++) { } }
/*********************************************************************//** * @brief External interrupt 3 handler sub-routine * @param[in] None * @return None **********************************************************************/ void EINT3_IRQHandler(void) { int j; if(GPIO_GetIntStatus(0, 25, 1)) { GPIO_ClearInt(0,(1<<25)); for (j= 0; j<8; j++) { #ifdef MCB_LPC_1768 /* Use MCB1700 board: * blink LED P1.29 when EINT3 occur */ FIO_ByteSetValue(1, 3, INT3_LED); delay(); FIO_ByteClearValue(1, 3, INT3_LED); delay(); #elif defined(IAR_LPC_1768) /* Use IAR LPC1768 KS board: * blink LED2 P0.4 when EINT3 occur */ FIO_ByteSetValue(0, 0, INT3_LED); delay(); FIO_ByteClearValue(0, 0, INT3_LED); delay(); #endif } } }
void SpeedInput::interruptHandler() { if(GPIO_GetIntStatus(input.getPort(), input.getPin(), 1)) { uint32_t currentPeriod = periodTimer->read_us(); periodTimer->start(); GPIO_ClearInt(input.getPort(), (1<<input.getPin())); if(currentPeriod > MAX_PERIOD) currentSpeed = 0.0f; else currentSpeed = (float)1000000 / currentPeriod / 4712 * 60 * 60; } }
/*********************************************************************//** * @brief External interrupt 3 handler sub-routine * @param[in] None * @return None **********************************************************************/ void GPIO_IRQHandler(void) { int j; if(GPIO_GetIntStatus(BRD_PIO_USED_INTR_PORT, BRD_PIO_USED_INTR_PIN, 1)) { GPIO_ClearInt(BRD_PIO_USED_INTR_PORT, BRD_PIO_USED_INTR_MASK); for (j = 0; j < 10; j++) { FIO_ByteSetValue(LED2_PORT, LED2_BYTE, LED2_BIT); delay(); FIO_ByteClearValue(LED2_PORT, LED2_BYTE, LED2_BIT); delay(); } } }
int _GPIO_GetIntStatus(uint8_t * args) { uint8_t * arg_ptr; uint8_t portNum; uint32_t pinNum; uint8_t edgeState; if ((arg_ptr = (uint8_t *) strtok(NULL, " ")) == NULL) return 1; portNum = (uint8_t) strtoul((char *) arg_ptr, NULL, 16); if ((arg_ptr = (uint8_t *) strtok(NULL, " ")) == NULL) return 1; pinNum = (uint32_t) strtoul((char *) arg_ptr, NULL, 16); if ((arg_ptr = (uint8_t *) strtok(NULL, " ")) == NULL) return 1; edgeState = (uint8_t) strtoul((char *) arg_ptr, NULL, 16); sprintf((char *) str, "%x\r\n", (unsigned int) GPIO_GetIntStatus(portNum, pinNum, edgeState)); writeUSBOutString(str); return 0; }
void EINT3_IRQHandler(void) { if (GPIO_GetIntStatus(1, 10, 1)) { GPIO_ClearInt(2,(1<<10)); toggle=~toggle; #ifdef MCB_LPC_1768_ADC_BURST_MULTI if(toggle) { ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL_3,ENABLE); FIO_ByteSetValue(1, 3, POLL_LED); } else { ADC_ChannelCmd(LPC_ADC,_ADC_CHANNEL_3,DISABLE); FIO_ByteClearValue(1, 3, POLL_LED); } #endif } }
void FuelLevel::interruptHandler() { static bool haveStartBit; static bool currentLogicState; static uint8_t currentBit; static uint16_t rxData; bool edgeIsHigh; if(GPIO_GetIntStatus(dataPin.getPort(), dataPin.getPin(), 1)) //falling edge edgeIsHigh = false; else if(GPIO_GetIntStatus(dataPin.getPort(), dataPin.getPin(), 0)) //rising edge edgeIsHigh = true; else return; // if(isLast) { GPIO_ClearInt(dataPin.getPort(), (1<<dataPin.getPin())); } uint32_t currentPeriod = periodTimer.read_us(); periodTimer.start(); if(currentPeriod >= BIT_PERIOD * 15) //packet timeout haveStartBit = false; if(!haveStartBit) //start new packet { haveStartBit = true; currentLogicState = false; currentBit = 0; rxData = 0; return; } //else continue existing packet //count up the number of bit periods since the last edge and set the bits if(currentBit > 0) currentBit = currentBit; uint8_t state = currentLogicState ? 1 : 0; while(currentPeriod >= BIT_PERIOD/2) { rxData += (state<<currentBit++); if(currentPeriod < BIT_PERIOD) break; currentPeriod -= BIT_PERIOD; } //if we got an edge here then the parity bit is high and there won't be any more edges if(currentBit == 12) { state = edgeIsHigh ? 1 : 0; rxData += state << currentBit++; } if(currentBit == 13) //just received the last bit { bool parityBit = rxData & 0x1000; //TODO verify parity rxData &= ~0x1800; //clear parity bit and zero bit rxData >>= 1; //shift off the start bit this->decilitres = rxData; }
/** * @brief The same with GPIO_GetIntStatus() */ FunctionalState FIO_GetIntStatus(uint32_t pintNum) { return (GPIO_GetIntStatus(pintNum)); }