Skip to content

Add interrupt section to docs #6560

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 5 commits into from
Sep 28, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/reference.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Reference
=========

Interrupts
----------

Interrupts can be used on the ESP8266, but they must be used with care
and have several limitations:

* Interrupt callback functions must be in IRAM, because the flash may be
in the middle of other operations when they occur. Do this by adding
the ``ICACHE_RAM_ATTR`` attribute on the function definition.

* Interrupts should not perform delay() or any long-running (>1ms) task.
WiFi and other portiong of the code can become unstable if interrupts
are blocked by a long-running interrupt. If you have much to do, you can
set a volatile global flag that your main ``loop()`` can check each pass
or use a scheduled function (which will be called by the OS when it is
safe, and not at IRQ level) to do the work.

* Memory operations can be dangerous and avoided in interrupts. Calls to
``new`` or ``malloc`` should be minimized, and calls to ``realloc`` and
``free`` must NEVER be used.

Digital IO
----------

Expand Down