-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fixes and implementation to expose attachInterruptArg in Arduino.h #6003
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5c8c68f
- attachInterrupt and detachInterrupt don't require ICACHE_RAM_ATTR.
dok-net 669b9ce
Fix CI warnings.
dok-net 3c8a851
Revert "Fix CI warnings."
dok-net c59a2c2
Fix CI warnings.
dok-net b7ca699
Done fixing CI warnings.
dok-net 20ff987
Merge branch 'master' into master
dok-net 7e77ba6
Merge branch 'master' into master
dok-net c376c97
Merge remote-tracking branch 'origin/master'
dok-net 3594450
Merge remote-tracking branch 'dok-net/master'
dok-net d6190fd
Merge commit '359445077a6d7bc36743e4dede7794015956b725'
dok-net c353b51
Merge branch 'master' into master
dok-net efafcbd
- attachInterrupt and detachInterrupt don't require ICACHE_RAM_ATTR.
dok-net e04ac23
Fix CI warnings.
dok-net 64a56c9
Revert "Fix CI warnings."
dok-net 38ef0f1
Fix CI warnings.
dok-net 254302b
Done fixing CI warnings.
dok-net 78aa3e8
Track breaking API chance in EspSoftwareSerial.
dok-net 1ecf11c
Merge remote-tracking branch 'dok-net/espswserialapi'
dok-net 1b4077f
Update SoftwareSerial release only after PR containing interrupt hand…
dok-net f21db95
Revert "Track breaking API chance in EspSoftwareSerial."
dok-net 3a206f2
Merge branch 'master' into master
dok-net 4a78b1a
Code formatting cleaned up a bit.
dok-net b03e7c7
Merge branch 'master' into master
dok-net bbd9948
Merge branch 'master' into master
dok-net File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading several times, I don't understand why it is needed to have this
bool functional
.It is always checked along with the not-
nullptr
arg. Why isarg
not sufficient ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do a detailed check (maybe thursday. otherwise friday).
I needed it in ESP32 to distinguish the use of attachinterruptArg from user exposed and usage for functional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-a-v The
bool functional
prevents undefined behavior of type-castingvoid* arg
toArgStructure*
and dereferencing in all those cases that the whole exercise of exposingvoid attachInterruptArg(uint8_t pin, void (*)(void*), void * arg, int mode)
is done for: whenever it's not an
ArgStructure*
, not null either, but for instance somethis
pointer or whatever else fits intovoid*
(32bit integers).I've revisited the code and I am quite sure it's needed where it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I've tested using microsecond resolution instead of CPU cycles for the Software Serial bit timing. The ESP8266 shows no difference, but on the ESP32, at high bit rate (57600cps), the error rate increases measurably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the reduction of the complexity of the generated code, I always try to cpu cycle (if measured durations are less than 26 seconds (esp8266@160MHz) or if overflow is managed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But here (SW serial) it impacts basic usefulness, each worsening in error rate renders it useless in more cases.
My point of view is that unconditionally requiring C++ functional objects in the attachInterruptArg interface through an API that looks like plain C attracts confusion. The compiler can't catch any of it. I have to admit, that I am not entirely happy with the whole construct between FunctionalInterrupt and core_esp8266_wiring_digital, exemplified by the need to copy&paste type definitions
//duplicate from functionalInterrupt.h keep in sync
typedef struct InterruptInfo
because the relationship is bit forced as it is right now.
But anyway, in ESP32 Arduino, it's just the same, so future patches just might take advantage or a more in similarity.