Skip to content

gpio_irq_init does not allow different IRQ handlers #1991

Closed
@infinnovation-dev

Description

@infinnovation-dev

The implementation of gpio_irq_init stores the handler function in a single global variable. Thus it is impossible for different parts of an application (e.g. libraries which have no knowledge of each other) to register different handlers, even for different ports, since the last call to gpio_irq_init "wins".

This violates expectations since the restriction appears not to be documented.

Clearly it works fine when only using the C++ InterruptIn class, since that uses its own unique handler function.

A demonstration program for K64F is available.

The same pattern appears to be used in all platforms' implementations.

IMHO the implementations should maintain an array of handlers in parallel with the channel_ids. Failing that, the documentation should be updated to say e.g.:

 * @param handler The single handler to be attached globally to all GPIO IRQs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions