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 all 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
2 changes: 0 additions & 2 deletions cores/esp32/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define sei()
#define cli()
#define interrupts() sei()
#define noInterrupts() cli()

Expand Down
18 changes: 18 additions & 0 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
#include "esp_log.h"
#include <sys/time.h>

static portMUX_TYPE interrupt_mux = portMUX_INITIALIZER_UNLOCKED;
static uint8_t interrupts_disabled = 0;
void sei()
{
if (interrupts_disabled) {
portEXIT_CRITICAL(&interrupt_mux);
interrupts_disabled = 0;
}
}

void cli()
{
if (!interrupts_disabled) {
portENTER_CRITICAL(&interrupt_mux);
interrupts_disabled = 1;
}
}

//Undocumented!!! Get chip temperature in Farenheit
//Source: https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_int_temp_sensor/ESP32_int_temp_sensor.ino
uint8_t temprature_sens_read();
Expand Down
5 changes: 5 additions & 0 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ void yield(void);
#include "esp32-hal-bt.h"
#include "esp_system.h"

#include <freertos/portmacro.h>

void sei();
void cli();

//returns chip temperature in Celsius
float temperatureRead();

Expand Down