Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] gpio: Add interrupt functionalities for GPIOs #8

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

SoucheSouche
Copy link
Collaborator

@SoucheSouche SoucheSouche commented Sep 5, 2022

Implement the GPIO interrupt functionalities based on the esp-idf gpio driver.

  • start the ISR service
  • stop the ISR service
  • add interrupt handler(s) on a given GPIO
  • remove interrupt handler(s) on a given GPIO
  • enable interrupts on a given GPIO
  • disable interrupt on a given GPIO
  • set the interrupt type on a given GPIO

@SoucheSouche SoucheSouche self-assigned this Sep 5, 2022
@SoucheSouche SoucheSouche changed the title gpio: Add interrupt functionalities for GPIOs [Draft] gpio: Add interrupt functionalities for GPIOs Sep 5, 2022
@SoucheSouche SoucheSouche force-pushed the feature/gpio-interrupt branch 12 times, most recently from a81cbe6 to a84ecda Compare September 12, 2022 06:03
@SoucheSouche SoucheSouche force-pushed the feature/gpio-interrupt branch 7 times, most recently from 0ca9f8c to 9eb6e08 Compare September 14, 2022 08:47
@SoucheSouche SoucheSouche force-pushed the feature/gpio-interrupt branch 4 times, most recently from 13af606 to 3525f53 Compare September 19, 2022 05:32
This commits implements the simpliest class wrapping the basic gpio interrupt
functionalities.
- Setting an interrupt on a given GPIO and providing a callback function
- enabling the interrupt on a given GPIO
- disabling the interrupt on a given GPIO

The gpio_intr_cxx example is added as a sandbox for testing during development
this commit adds:
- gpio_common_cxx.hpp where the GPIONum and GPIOExceptions types are defined
  to make it accessible on both gpio_intr_cxx.hpp and gpio_cxx.hpp
- the strong type GPIOIntrType
- the conversion function from GPIOIntrType to C driver gpio_intr_type
- the conversion function from GPIONum to C driver gpio_num_t
- create GPIOIsrFlag class that builds and provides ISR flags to pass to gpio_install_isr_service()
…ven GPIO number

this function will also disable de interrupts on this GPIO
…thods in GPIO_intr

- remove reference to GPIO_Intr from gpio_cxx.hpp to lower binary size when interrupt
is not used.
- gpio_intr prefix removed as it is redundant with the name of the Class.
- the callback table now accepts a list a callback ona given GPIO number.
- when first callback is added on a given GPIO, the generic callback is registered
to the driver.
- when the last callback is removed on a given GPIO, the generic callback is de-registered
from the driver
…. Move isr service related method to GPIOIsr

- Remove conversion functions and use get_value<>() instead
- GPIOIntr is tied to a GPIO number, the user handles instances of the classes itself
- GPIOIsr provides function to start and stop ISR service from the driver (WIP)
this commit also move hldr_bounce and driver_handler methods to the
provate section of GPIOIntr.
This will force the user to have a GPIO input setup when using the interrupt
functionalities.
The new constructor takes gpio number, pull mode and driver strength as parameters.
This constructor by used in GPIOIntr constructor.
Create 3 senarios running on 3 different threads.
In each scenario, a GPIOIntr instance is created and 1(or 2) callback(s) is(are)
registered.
the example showcases the usage of lambda function, static function and non static
member function as callback for GPIO interrupts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant