Skip to content

Add methods to check if there's an IRQ handler #764

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

Merged
merged 2 commits into from
Nov 8, 2019

Conversation

LinoBarreca
Copy link
Contributor

@LinoBarreca LinoBarreca commented Nov 8, 2019

Summary

Added methods to check if there's an user-IRQ-handler currently attached.

This PR implements the following feature

  • It's easier to understand if you need to attach or detach an IRQ
  • Lower memory usage in complex scenarios

Why
..well...first of all...why not?
The HardwareTimer, internally, knows if there's a callback. Exposing this to the user makes no harm.
It's a good C++ programming practice to give a way for an object to expose its status.

Now let's talk about why should it be there.
Imagine a situation in which you want to disable the callback (for example on a channel) leaving the timer running and receiving other interrupts on other channels.

When you have multiple timers and each of them has multiple channels it's difficult to keep track of them all, moreover if they aren't enabled and disabled from the "main" schetch but by some other interrupt handler.

In a situation where you have "multiple sources" of detach/attach this can be cumbersome.
Providing a "zero-cost" (each HardwareTimer knows it already) property which will expose the status of the interrupt handler (present/absent) will make code easier to write and with less bugs.

Validation

Should be good.

Code formatting

Should be good.

Closing issues

Doesn't close any issue but helps programmers to not create new ones.

@fpistm fpistm requested a review from ABOSTM November 8, 2019 13:00
@fpistm fpistm added the enhancement New feature or request label Nov 8, 2019
@LinoBarreca
Copy link
Contributor Author

LinoBarreca commented Nov 8, 2019

NOTE: update to wiki is needed (to inform users that they have the new methods available)
I can do that too..but I first wanted to see if this gets merged :)

Copy link
Contributor

@ABOSTM ABOSTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lokks good to me

@LinoBarreca
Copy link
Contributor Author

Ok. I go edit the wiki then, adding the methods as supported from 1.8.0 :)

@LinoBarreca
Copy link
Contributor Author

Done.

@ABOSTM ABOSTM added this to the 1.8.0🎄 🎅 milestone Nov 8, 2019
@fpistm fpistm merged commit 149b648 into stm32duino:master Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants