void hw_interrupt_enable(int index, int ulPin, int mode) { assert(index >= 0 && index < 8); unsigned portNum = g_APinDescription[ulPin].portNum; unsigned bitNum = g_APinDescription[ulPin].bitNum; unsigned int_id = PIN_INT0_IRQn + index; /* Clear IRQ in case it existed already */ NVIC_DisableIRQ(int_id); hw_digital_input(ulPin); /* Configure GPIO interrupt */ GPIO_IntCmd(index, portNum, bitNum, mode); // Clear any pre-existing interrupts requests so it doesn't fire immediately GPIO_ClearInt(TM_INTERRUPT_MODE_RISING, index); GPIO_ClearInt(TM_INTERRUPT_MODE_FALLING, index); GPIO_ClearInt(TM_INTERRUPT_MODE_HIGH, index); GPIO_ClearInt(TM_INTERRUPT_MODE_LOW, index); /* Enable interrupt for Pin Interrupt */ NVIC_EnableIRQ(int_id); }
/*********************************************************************//** * @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 EINT2_IRQHandler(void) { /* clear the EINT2 flag */ EXTI_ClearEXTIFlag(EXTI_EINT2); GPIO_ClearInt(FPGA_RST_SW_PORT, 0x01 << FPGA_RST_SW); reset_FPGA(); }
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; } }
int _GPIO_ClearInt(uint8_t * args) { uint8_t * arg_ptr; uint8_t portNum; uint32_t bitValue; 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; bitValue = (uint32_t) strtoul((char *) arg_ptr, NULL, 16); GPIO_ClearInt(portNum, bitValue); return 0; }
/*********************************************************************//** * @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(); } } }
void PIOINT3_IRQHandler(void) { GPIO_ClearInt(PORT3, GPIO_Pin_3); GPIO_PortIntCmd(PORT3, DISABLE); TIM_Cmd(LPC_TMR32B1, TIM_RESET); // Start Timer1 for time TIM_Cmd(LPC_TMR32B1, TIM_ENABLE); LPC_TMR32B0->TCR = (1<<1); //start counter to count LPC_TMR32B0->TCR = (1<<0); // if(blink) { // GPIO_SetBits(PORT0, GPIO_Pin_7); // } // else { // GPIO_ResetBits(PORT0, GPIO_Pin_7); // } // blink ^= 1; }
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_ClearInt() */ void FIO_ClearInt(uint8_t intMode, uint32_t pintNum) { GPIO_ClearInt(intMode, pintNum); }