Erroneously triggered IRQ?

18 Dec 2011

IRQKeypad::IRQKeypad( PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7) {
#ifdef _DEBUG
    if ( s_pKeypad)
        error("Only one keypad can exist!");
#endif

    s_pKeypad = this;
    _Pins[0] = p0;
    _Pins[1] = p1;
    _Pins[2] = p2;
    _Pins[3] = p3;
    _Pins[4] = p4;
    _Pins[5] = p5;
    _Pins[6] = p6;
    _Pins[7] = p7;
    // clear all pins output value
    for ( char s=0; s<8; ++s) {
        if (_Pins[s] == NC) break;
        uint32_t msk = PINMASK(_Pins[s]);
        LPC_GPIO_TypeDef* pd = PORTDEF(_Pins[s]);
        pd->FIOMASK |= msk;
        pd->FIODIR |= msk;
        pd->FIOCLR = msk;
    }
    _IRQMask = PINMASK(p4) | PINMASK(p5) | PINMASK(p6);
    if ( p7 != NC) {
        _IRQMask |= PINMASK(p7);
    }
    Activate();  //sets p4..p7 as inputs

    _handler.Init(GPIO_Handler);  // irq must be activated after initialization of pins,dons't use constructor
    LPC_GPIOINT->IO0IntEnF |= _IRQMask;  // the GPIO pins are default PullUp mode, need to detect the first edge, which will is the falling one
}

Initialization code: It just configures some pins, NIV_SetVector/EnableVector is called in _handler.Init(). Why is GPIO_Handler called when I reset the mbed?

18 Dec 2011

hm so it seems I'm getting an interrupt when switching the direction :(