Skip to content

Adds S3 GPIO48 in digitalPinToInterrupt() + GPIO INTR Review #8562

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 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions cores/esp32/esp32-hal-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ extern void __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtrArg userFunc,
{
static bool interrupt_initialized = false;

// makes sure that pin -1 (255) will never work -- this follows Arduino standard
if (pin >= NUM_DIGITAL_PINS) return;

if(!interrupt_initialized) {
esp_err_t err = gpio_install_isr_service((int)ARDUINO_ISR_FLAG);
interrupt_initialized = (err == ESP_OK) || (err == ESP_ERR_INVALID_STATE);
Expand Down
12 changes: 6 additions & 6 deletions variants/esp32/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16
#define NUM_DIGITAL_PINS SOC_GPIO_PIN_COUNT // GPIO 0..39
#define NUM_ANALOG_INPUTS 16 // ESP32 has 16 ADC pins
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs

#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34)
#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):NOT_AN_INTERRUPT)
#define digitalPinHasPWM(p) (p < 34) // PWM only for GPIO0..33 - NOT GPIO 34,35,36 and 39

static const uint8_t TX = 1;
static const uint8_t RX = 3;
Expand Down
8 changes: 4 additions & 4 deletions variants/esp32c3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <stdint.h>
#include "soc/soc_caps.h"

#define EXTERNAL_NUM_INTERRUPTS 22
#define NUM_DIGITAL_PINS 22
#define NUM_ANALOG_INPUTS 6
#define NUM_DIGITAL_PINS SOC_GPIO_PIN_COUNT // GPIO 0..21 - not all are available
#define NUM_ANALOG_INPUTS 6 // GPIO 0..5
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs

static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+8;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
Expand All @@ -15,7 +15,7 @@ static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+8;
#define RGB_BRIGHTNESS 64

#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):NOT_AN_INTERRUP)
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)

static const uint8_t TX = 21;
Expand Down
12 changes: 6 additions & 6 deletions variants/esp32s2/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <stdint.h>
#include "soc/soc_caps.h"

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 48
#define NUM_ANALOG_INPUTS 20
#define NUM_DIGITAL_PINS SOC_GPIO_PIN_COUNT // GPIO 0..46
#define NUM_ANALOG_INPUTS 20 // GPIO 1..20
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs

static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+18; // GPIO pin for Saola-1 & DevKitM-1 = 18
//static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+45; // GPIO pin for Kaluga = 45
Expand All @@ -15,9 +15,9 @@ static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+18; // GPIO pin for Saola-
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
#define digitalPinHasPWM(p) (p < 46)
#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):NOT_AN_INTERRUPT)
#define digitalPinHasPWM(p) (p < NUM_DIGITAL_PINS)

static const uint8_t TX = 43;
static const uint8_t RX = 44;
Expand Down
12 changes: 6 additions & 6 deletions variants/esp32s3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#define USB_VID 0x303a
#define USB_PID 0x1001

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 48
#define NUM_ANALOG_INPUTS 20
#define NUM_DIGITAL_PINS SOC_GPIO_PIN_COUNT // GPIO 0..48
#define NUM_ANALOG_INPUTS 20 // GPIO 1..20
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs

// Some boards have too low voltage on this pin (board design bug)
// Use different pin with 3V and connect with 48
Expand All @@ -20,9 +20,9 @@ static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+48;
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
#define digitalPinHasPWM(p) (p < 46)
#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):NOT_AN_INTERRUPT)
#define digitalPinHasPWM(p) (p < NUM_DIGITAL_PINS)

static const uint8_t TX = 43;
static const uint8_t RX = 44;
Expand Down