Skip to content

Implement sei/cli using port{EXIT,ENTER}_CRITICAL #835

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 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions cores/esp32/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define sei()
#define cli()
#define sei() portEXIT_CRITICAL(&arduino_mux);
#define cli() portENTER_CRITICAL(&arduino_mux);
#define interrupts() sei()
#define noInterrupts() cli()

Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/esp32-hal-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define HWTIMER_LOCK() portENTER_CRITICAL(timer->lock)
#define HWTIMER_UNLOCK() portEXIT_CRITICAL(timer->lock)

portMUX_TYPE arduino_mux = portMUX_INITIALIZER_UNLOCKED;

Copy link
Member

Choose a reason for hiding this comment

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

first mayb e move those to esp32-hal.h and esp32-hal-misc.c ? should not be in the timers ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps also rename arduino_mux to interrupt_lock or interrupt_mux ?

typedef struct {
union {
struct {
Expand Down
2 changes: 2 additions & 0 deletions cores/esp32/esp32-hal-timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern "C" {
#include "esp32-hal.h"
#include "freertos/FreeRTOS.h"

extern portMUX_TYPE arduino_mux;

struct hw_timer_s;
typedef struct hw_timer_s hw_timer_t;

Expand Down