Skip to content

FunctionalInterrupt/ScheduledFunctions should be in a library, not in esp32-hal-gpio #2734

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
wants to merge 49 commits into from

Conversation

dok-net
Copy link
Contributor

@dok-net dok-net commented May 2, 2019

After mulling over the situation with the pending PR esp8266/Arduino#6003, I have rewritten the support for std::functional and scheduled interrupts to be less intrusive.
First, the support is revoked. Second, the refactored code is brought back as an example in libraries/ESP32/examples/GPIO/FunctionalInterrupt.
I have unified the code with the ESP8266 version: esp8266/Arduino#6038

@dok-net
Copy link
Contributor Author

dok-net commented May 2, 2019

I don't know if this is redundant, but if integrating the Schedule.h functionality that brings loop-synchronized scheduling, is desired, here's what it takes:

  • copy Schedule.(h|cpp) from libraries/ESP32/examples/GPIO/FunctionalInterrupt to cores/esp32.
  • add cores/esp32/Schedule.cpp to CMakeLists.txt right before cores/esp32/Stream.cpp.
  • add #include "Schedule.h" as last include in Arduino.h.
  • add run_scheduled_functions(); right under loop(); in void loopTask(void *pvParameters) which is in cores/esp32/main.cpp.

@me-no-dev
Copy link
Member

here are a few thoughts :)

  • Do not rename header filenames.
  • Do not include ESP8266 Arduino code in examples.
  • ESP32 Arduino runs on top of FreeRTOS :) we have threads and other tools to create scheduled commands
  • ESP32 Arduino doesn't necessarily have to have 1:1 what ESP8266 Arduino have. Chips are not the same, runtime is not the same... many differences.
  • Such PR Should be split in two, where we can in one discuss that Schedule library and another to discuss Functional Interrupt

@dok-net dok-net force-pushed the functional-shouldbe-lib branch from d2ec37c to 53aa967 Compare May 11, 2019 15:49
@dok-net
Copy link
Contributor Author

dok-net commented May 11, 2019

@me-no-dev :

Do not rename header filenames.

Checked - though they were deleted and resurrected as pure example code, not renamed ;-)

Do not include ESP8266 Arduino code in examples.

Functional* was previously included from ESP8266. I am working with the WEMOS D1 mini like boards, and I think Arduino is all about portability, please don't restrict this.

ESP32 Arduino runs on top of FreeRTOS :) we have threads and other tools to create scheduled commands

Again, Functional* did in fact get accepted earlier from a different source, I am removing them due to problems :-)

ESP32 Arduino doesn't necessarily have to have 1:1 what ESP8266 Arduino have. Chips are not the same, runtime is not the same... many differences.

Naturally, but helping migrate code is not an evil thing, anyway.

Such PR Should be split in two, where we can in one discuss that Schedule library and another to discuss Functional Interrupt

Dropping Schedule in the example is just due to my perception of the original author's intent of adding FunctionalInterrupt in the first place.

OK - I hope you can review this PR for it's own merits. The core issue I am addressing is that non-IRAM code will be surreptitiously called from ISRs if FunctionalInterrupt.h gets used.

@dok-net dok-net force-pushed the functional-shouldbe-lib branch 4 times, most recently from f01691b to 97aba98 Compare June 3, 2019 13:51
@dok-net dok-net force-pushed the functional-shouldbe-lib branch from 3950637 to db42f37 Compare June 7, 2019 18:57
dok-net added 26 commits June 7, 2019 23:26
Same yield behavior as on ESP8266 - scheduler has policies for loop and yield initiated runs.
(cherry picked from commit d39be67)

squash! Add Schedule.(h|cpp) from ESP8266 to run off loopTask.

squash! Add Schedule.(h|cpp) from ESP8266 to run off loopTask.
squash! Ticker and Schedule updated from ESP8266 Arduino
…ndling:

- VIP treatment in general attach/detach/handling looks untidy:
  extern symbols without matching header include but copy&paste
  special under-the-hood c++ delete support, where everyone else has to do their own
  resource tracking as usual.
- FunctionalInterrupt is not used by anything inside core ESP32 Arduino for 8 months now,
  it can be a library, which reduces precious core size for everyone else.

This reverts commit ea61563.
…as example code.

It should be decided whether to reinstate these in the core, or make them an optional library.
…n attachInterruptArg().

This is sufficient for resource management - the function has static duration anyway.
…late the ISR in

ICACHE_RAM rule (ESP8266 core catches this).
squash! Return Ticker to libraries only for modularity.
@dok-net dok-net force-pushed the functional-shouldbe-lib branch from db42f37 to ef061bc Compare June 7, 2019 22:16
@dok-net dok-net closed this Jun 28, 2019
@dok-net dok-net deleted the functional-shouldbe-lib branch June 28, 2019 21:20
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.

2 participants