2009-05-16 00:58:32 Can I change the PORTxIO_MASKA registers?
Frank Van Hooft (CANADA)
Message: 74125
Apologies if this is a silly question, but I've searched & can't find an answer.
I have a GPIO interrupt that I only want to enable part of the time. The GPIO pin in question toggles a lot & I don't want it constantly generating useless interrupts - I'd prefer to have it only generate an interrupt when I actually want the interrupt, and have the interrupt disabled the rest of the time.
I understand I can do this by
request_irq (...); // enable IRQ
free_irq (...); // disable IRQ
but I'd prefer not to have the overhead of doing the request_irq() & free_irq() repeatedly. I was wondering if it's possible to set up the IRQ with the request_irq() just once, and then turn off and on the GPIO IRQ via the appropriate bit in the PORTxIO_MASKA register? I realise that doing this directly would be playing with fire. Is there a proper mechanism to do this? Any other suggestions?
Thanks.
QuoteReplyEditDelete
2009-05-16 01:39:39 Re: Can I change the PORTxIO_MASKA registers?
Mike Frysinger (UNITED STATES)
Message: 74126
disable_irq/enable_irq are the supported method for doing what you want. i think that should do what you need ?
QuoteReplyEditDelete
2009-05-16 12:16:28 Re: Can I change the PORTxIO_MASKA registers?
Frank Van Hooft (CANADA)
Message: 74127
Thanks Mike. It sounds like it might. Do you know if it's safe to call disable_irq() from within my interrupt service routine? I found this description of disable_irq() on the web:
Disable the selected interrupt line. This function waits for any pending IRQ handlers for this interrupt to complete before returning. If you use this function while holding a resource the IRQ handler may need you will deadlock.
This function may be called - with care - from IRQ context.
In my case, I would like to enable the GPIO falling-edge interrupt, then once it occurs my interrupt service routine (interrupt handler) would do a small amount of processing and then turn off the interrupt so it doesn't reoccur. So this would mean the disable_irq() function would be called from within the interrupt handler. A bad idea?
Thanks.
QuoteReplyEditDelete
2009-05-16 13:02:57 Re: Can I change the PORTxIO_MASKA registers?
Mike Frysinger (UNITED STATES)
Message: 74129
you could try disable_irq_nosync() then
QuoteReplyEditDelete
2009-05-16 13:08:56 Re: Can I change the PORTxIO_MASKA registers?
Frank Van Hooft (CANADA)
Message: 74130
That looks like a good idea - thanks! I'll try enable_irq() and disable_irq_nosync() then.
QuoteReplyEditDelete
2009-05-17 02:41:32 Re: Can I change the PORTxIO_MASKA registers?
Frank Van Hooft (CANADA)
Message: 74141
Yep, those two are working well - thanks again Mike.