Mbed-os 6.17 doesn't have the Interrupt Clear function in Interrupt class?

Hello! These days I’m studying and building programs to create an interrupt function to click the joystick button and turn on/off the LED on the Mbed LPC1768. But I found that the button will generate a lot of rise signal and trigger lot of interrupt. I use the enable() and disable() function but the existing interrupt state caused by button 's vibrating is still alive. But I didn’t find the clear() function from the Interrupt class in mbed-os. I think that’s a big mistake for an RTOS. How to clear the intrrupt of the corresponding GPIO port_pin? Will the mbed-os add the clear() function into the Interrupt class in the next version?

Hello,

There will be not future releases under ARM Mbed - Important update on Mbed - End of Life - Mbed OS - Arm Mbed OS support forum

What should the Clear method do? Because how you exactly wrote, the button generates, so the issue is in hardware and it is not issue of Mbed.
The class/driver is called InterruptIn because it is for manage interrupts in general, not only for a button which has specific behavior ( Switch Bounce and How to Deal with It - Technical Articles (allaboutcircuits.com)) but also for sensors or another devices what are capable to geerate exact square signal.
In general you are responsible to make a choose what will be adapted - Software to Hardware or vice versa.

BR, Jan

Hello! In my opinion, the clear function is just clear the IRQ status by the IntClr register. I found that disable IRQ can only stop storeing new IRQ into IRQ Status Register and stop sending this IRQ to CPU, but the IRQ status generated by button vibration is still alive in IRQ Status Register, which means when I enable IRQ after the interrupt event is handled over, the existing IRQ status generated by the vibration during the last IRQ event but not be cleared yet will still be sent to the CPU first and lead to the multiple response.
The interrupt “.clear()” function is widely used in RTOS such as Ethernet drivers in VxWorks OS because some modules may not stop generating IRQ unless this IRQ event is handled over. Although we disables it at the beginning of the IRQ handle funtion, some IRQ can still be generated and sent to the IRQ Status Register before we disable it.

I also find that the “.rise()” or “.fall()” function which will call the “gpio_irq_set()” function in mbed-os source code can clear the IRQ status, so I use this function to clear it before I re-enable it. I write an example to show the necessity to clear the IRQ satus. Maybe you can execute this code on LPC1768+Application Board and see the result. You can also delete the “joystick.rise(&trigger);” in “lightup()” function to see another result.

/* How to disable/clear/enable interrupt and avoid button signal vibrate */
// global variables
DigitalOut led(LED1);
InterruptIn joystick(p14);
Thread thread;
Semaphore sem;

void trigger()  // Interrupt fun
{
    joystick.disable_irq();
    sem.release();  // release semaphore
}

void lightup()  // Thread fun
{
    while(true)
    {
        sem.acquire();  // wait and stop here, until the semaphore is released
        led = !led;
        ThisThread::sleep_for(500ms);  // disable irq in irq_func and enable it in thread after delay - filtering to avoid the button vibrate
        joystick.rise(&trigger);    // mbed-os doesn't have an irq_clr interface, so we can use irq initialze (rise) to clear irq state because rise() has cleared the irq.
        joystick.enable_irq();
    }
}

int main(){
    joystick.rise(&trigger);
    thread.start(&lightup);
}