//ISR INIT void ctl_buttons_isr_init(CTL_ISR_FN_t fn) { int en; int32u proba; en=ctl_global_interrupts_set(0); buttons_isr=fn; SysCtlPeripheralEnable(PUSHBUTTON_PERIPH); //UNLOCKOLNI KELL A PF0 REGISZTERT MERT NMI-RE VAN ALLITVA HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD; HWREG(PUSHBUTTON_PORT + GPIO_O_CR) |= 0x01; HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = 0; GPIODirModeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_DIR_MODE_IN); GPIOPadConfigSet(PUSHBUTTON_PORT,LEFT_SWITCH | RIGHT_SWITCH , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPinIntDisable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH); if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == LEFT_SWITCH ) { GPIOPinIntClear(PUSHBUTTON_PORT, LEFT_SWITCH ); } if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == RIGHT_SWITCH ) { GPIOPinIntClear(PUSHBUTTON_PORT, RIGHT_SWITCH ); } ctl_set_priority(PUSHBUTTON_IRQ_PRIORITY, 1); ctl_unmask_isr(PUSHBUTTON_IRQ_PRIORITY); ctl_global_interrupts_set(en); GPIOIntTypeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_BOTH_EDGES); //GPIO_BOTH_EDGES GPIOPinIntEnable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH ); }
void EncoderInterruptHandler(void) { int temp = 0; unsigned char pin, pinA, pinB; unsigned port; signed dir; volatile encoder_count_t *p_encCount; if((GPIOPinIntStatus(port=GPIO_PORTC_BASE, false) & (pin=GPIO_PIN_5))) { // encoder 0 fired! pinA = GPIO_PIN_5; pinB = GPIO_PIN_4; dir = dir0; p_encCount = &enc0; } else if(GPIOPinIntStatus(port=GPIO_PORTB_BASE, false) & (pin=GPIO_PIN_4)) { // encoder 0 fired! pinA = GPIO_PIN_5; pinB = GPIO_PIN_4; dir = -dir0; p_encCount = &enc0; } else if(GPIOPinIntStatus(port=GPIO_PORTC_BASE, false) & (pin=GPIO_PIN_6)) { // encoder 1 fired! pinA = GPIO_PIN_6; pinB = GPIO_PIN_6; dir = dir1; p_encCount = &enc1; } else if (GPIOPinIntStatus(port=GPIO_PORTB_BASE, false) & (pin=GPIO_PIN_6)) { // encoder 1 fired! pinA = GPIO_PIN_6; pinB = GPIO_PIN_6; dir = -dir1; p_encCount = &enc1; } else return; GPIOPinIntClear(port, pin); if(GPIOPinRead(GPIO_PORTC_BASE, pinA)) ++temp; // channel A if(GPIOPinRead(GPIO_PORTB_BASE, pinB)) ++temp; // channel B switch(temp) { case 0: // both channels == 0 case 2: // both channels == 1 // channel A == channel B *p_encCount += dir; // --> moving forward break; case 1: // one channel == 1 and the other == 0 // channel A != channel B *p_encCount -= dir; // --> moving backward break; } }
void IntWheelSensor() { CPU_INT32U ulStatusR_A; CPU_INT32U ulStatusL_A; static CPU_INT08U CountL = 0; static CPU_INT08U CountR = 0; static CPU_INT08U data = 0; ulStatusR_A = GPIOPinIntStatus(RIGHT_IR_SENSOR_A_PORT, DEF_TRUE); ulStatusL_A = GPIOPinIntStatus(LEFT_IR_SENSOR_A_PORT, DEF_TRUE); if (ulStatusR_A & RIGHT_IR_SENSOR_A_PIN) { GPIOPinIntClear(RIGHT_IR_SENSOR_A_PORT, RIGHT_IR_SENSOR_A_PIN); /* Clear interrupt.*/ CountR = CountR + 1; } if (ulStatusL_A & LEFT_IR_SENSOR_A_PIN) { GPIOPinIntClear(LEFT_IR_SENSOR_A_PORT, LEFT_IR_SENSOR_A_PIN); CountL = CountL + 1; } if((CountL >= Left_tgt) && (CountR >= Right_tgt)) { data = 0x11; Left_tgt = 0; Right_tgt = 0; CountL = 0; CountR = 0; BSP_MotorStop(LEFT_SIDE); BSP_MotorStop(RIGHT_SIDE); } else if(CountL >= Left_tgt) { data = 0x10; Left_tgt = 0; CountL = 0; BSP_MotorStop(LEFT_SIDE); } else if(CountR >= Right_tgt) { data = 0x01; Right_tgt = 0; CountR = 0; BSP_MotorStop(RIGHT_SIDE); } return; }
void GPIO_PortG_ISR( void ) { unsigned char int_status = 0; GPIO_PIN_T pin = 0; // Figure out which pin caused the interrupt int_status = GPIOPinIntStatus( GPIO_PORTG_BASE, true ); if( int_status & 0x01 ) pin = 0; else if( int_status & 0x02 ) pin = 1; else if( int_status & 0x04 ) pin = 2; else if( int_status & 0x08 ) pin = 3; else if( int_status & 0x10 ) pin = 4; else if( int_status & 0x20 ) pin = 5; else if( int_status & 0x40 ) pin = 6; else if( int_status & 0x80 ) pin = 7; // Acknowledge and diable interrupts for this pin. // GPIOPinIntDisable( GPIO_PORTG_BASE, int_status ); GPIOPinIntClear( GPIO_PORTG_BASE, int_status ); // Call the task function for this pin's interrupt GPIO_PinISR[GPIO_PORT_G][pin](); // Enable interrupts for the pin. XXX Does this provide enough // debouncing for GPIO interrupts? If not, we can set a flag in // main that enables interrupts after a set amount of time. //GPIOPinIntEnable( GPIO_PORTG_BASE, int_status ); }
void RF22_PinIntHandler(void) { if(GPIOPinIntStatus(RFM_22_PORT_INT, false) & RFM_22_PIN_INT) { RF22_isr0(); } GPIOPinIntClear(RFM_22_PORT_INT, RFM_22_PIN_INT); }
void GPIO_3A_ISR(void) { if(GPIOPinIntStatus(SOC_GPIO_3_REGS, GPIO_INT_LINE_1, LCD_INT_PIN)) { LCD_Interrupt(FALSE); LCD_SetInterruptFlag(); GPIOPinIntClear(SOC_GPIO_3_REGS, GPIO_INT_LINE_1, LCD_INT_PIN); } }
/*----------------------------------------------------------------------------*/ void hw_portA_int_handler() { unsigned char mask = GPIOPinIntStatus(GPIO_PORTA_BASE, NULL); if (mask & GPIO_PIN_7) { MAP_GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_7 ); DS1390_int_handler(); } tn_int_exit(); }
bool Extint::triggered() { //is this external line generate the interrupt ? if ( (GPIOPinIntStatus(this->GpioPortBase, false) & this->GpioPin) == this->GpioPin) { return true; } else { return false; } }
void IntGPIOHandler(void) { volatile int i; // Handle select button interrupt // Then clear the interrupt flag if (GPIOPinIntStatus(GPIO_PORTF_BASE, GPIO_PIN_1)) { GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1); } // Make sure flags has time to clear before leaving ISR for(i=0;i<3;i++); }
/*----------------------------------------------------------------------------*/ void hw_portC_int_handler() { unsigned char mask = GPIOPinIntStatus(GPIO_PORTC_BASE, NULL); if (mask & GPIO_PIN_4) { MAP_GPIOPinIntClear(GPIO_PORTC_BASE, GPIO_PIN_4 ); } if (mask & GPIO_PIN_5) { MAP_GPIOPinIntClear(GPIO_PORTC_BASE, GPIO_PIN_5 ); } tn_int_exit(); }
void quad_encoder() { IntDisable(INT_GPIOC); long temp; temp = GPIOPinIntStatus( GPIO_PORTC_BASE, true); Display *disp = global_current_display(0); if( (disp->menu_type >> 4) < 2 ) { if(temp & 0x20) { push_encoder_button(); delaymycode(10); } else if(temp & 0x80) { push_back_button(); delaymycode(10); } else if( (temp & 0x10) || (temp & 0x40) ) { unsigned char curA = GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_4); unsigned char curB = GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_6); Encoder_State* encoder = global_get_encoder(); //(curA == 0)&&(curA != encoder->encoderA_last)&&(curB == encoder->encoderB_last) if( (curB) ) { turn_encoder_left(); delaymycode(1); encoder->encoderA_last = curA; encoder->encoderB_last = curB; } //(curB == 0)&&(curB != encoder->encoderB_last)&&(curA == encoder->encoderA_last) else if( (~(encoder->encoderA_last ^ curB)) ) { turn_encoder_right(); delaymycode(1); encoder->encoderA_last = curA; encoder->encoderB_last = curB; } } } else if ( (disp->menu_type >> 4) >= 2 ) {
void GPIO_Port_B_ISR (void) { ulong ulStatus; #if OS_CRITICAL_METHOD ==3 OS_CPU_SR cpu_sr; #endif OS_ENTER_CRITICAL(); OSIntNesting++; OS_EXIT_CRITICAL(); ulStatus = GPIOPinIntStatus(GPIO_PORTB_BASE, true); // 读取中断状态 GPIOPinIntClear(GPIO_PORTB_BASE, ulStatus); // 清除中断状态,重要 if(ulStatus & GPIO_PIN_5) { OSSemPost(RNSemIsr); } OSIntExit(); }
void TouchScreenIntHandler(void) { GPIOPinIntClear(ADS7843_PORT_INT, ADS7843_PIN_INT); if(GPIOPinIntStatus(ADS7843_PORT_INT, false) & ADS7843_PIN_INT) { touchIntPinInterruptEnable(false); ADS7843touchPenIntHandler(); if(ADS7843dataAvailable()) { // Enable Timer touchScreenTimerEnable(true); TOUCH_DEBUG("PEN_DOWN\r\n"); } else { touchIntPinInterruptEnable(true); } } }
//ISR HANDLER CTL_ISR_FN_t buttons_isr_handler(void) { int32u int_status; int_status = GPIOPinIntStatus( PUSHBUTTON_PORT, 1 ); GPIOPinIntClear( PUSHBUTTON_PORT, int_status ); if(int_status & LEFT_SWITCH) { if(GPIOPinRead(PUSHBUTTON_PORT, LEFT_SWITCH) == LEFT_SWITCH) ctl_events_set_clear(&button_events,0,L_BTN_PUSHED); else ctl_events_set_clear(&button_events,L_BTN_PUSHED,0); } if(int_status & RIGHT_SWITCH) { if(GPIOPinRead(PUSHBUTTON_PORT, RIGHT_SWITCH) == RIGHT_SWITCH) ctl_events_set_clear(&button_events,0, R_BTN_PUSHED); else ctl_events_set_clear(&button_events,R_BTN_PUSHED,0); } }
// ******************************************************* // Interrupt handler for the port. This monitors GPIO pins // and modifies the button_t type. void buttonISR(void) { // button_t* button; // Read the pin's digital state //long rawPinData = GPIOPinRead(button->ulPort, button->ucPin); //long rawPinData = GPIOPinRead(PORT_BASE_B, // UP_B | DOWN_B | LEFT_B | RIGHT_B | SELECT_B); long rawPinData = GPIOPinIntStatus(PORT_BASE_B, UP_B | DOWN_B | LEFT_B | RIGHT_B | SELECT_B); //long rawPinData = GPIOPinIntStatus(PORT_BASE_B, 1); //transfer the current pin read to a more meaningful variable long pin = 0;// = 1 << (buttonPin + 3); //int pinState; long currentPin; // loop through all the pins for (currentPin = UP; currentPin <= SELECT; currentPin++) { button = &buttonPointer[currentPin]; switch(currentPin) { case UP: pin = UP_B; break; case DOWN: pin = DOWN_B; break; case LEFT: pin = LEFT_B; break; case RIGHT: pin = RIGHT_B; break; case SELECT: pin = SELECT_B; break; default: pin = 0; break; } // Don't do anything until pushed button has // been serviced by checkBut(). if ((button->iState == BUT_PUSHED) || (button->iState == BUT_INACTIVE)) { // Do nothing } // check for a button press. else if (rawPinData & pin) { button->iState = BUT_PUSHED; } } GPIOPinIntClear(PORT_BASE_B, LEFT_B | RIGHT_B | SELECT_B | UP_B | DOWN_B); }