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

Adds noInterrupt() and interrupt() functionality #7226

Merged
merged 5 commits into from
Sep 15, 2022
Merged
Changes from 2 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
7 changes: 3 additions & 4 deletions cores/esp32/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define sei()
#define cli()
Copy link
Member

Choose a reason for hiding this comment

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

You could have define sei and cli instead for backwards compatibility with older code. Any reason you didn't @SuGlider?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I know, SEI and CLI are ASM instructions used in ATMEL chips.
Arduino official API is interrupts() and noInterrupts()
I see no reason for defining those ATMEL specific functions.

//interrupts is defined as:

#define interrupts() sei()
//and sei is defined as for the UNO/328p:

# define sei()  __asm__ __volatile__ ("sei" ::)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking ESP8266 Arduino.h I see that it also doesn't define sei() nor cli().
My vote is for keeing it as defined in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

interrupts() and noInterrupts() are described in Arduino Language Reference so I vote for this too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, added back.

#define interrupts() sei()
#define noInterrupts() cli()
// ESP32xx runs FreeRTOS... disabling interrupts can lead to issues, such as Watchdog Timeout
#define interrupts() portENABLE_INTERRUPTS()
#define noInterrupts() portDISABLE_INTERRUPTS()

#define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
Expand Down