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 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: 1 addition & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23097,7 +23097,7 @@ unphone8.build.partitions=default_8MB
unphone8.build.defines=-DBOARD_HAS_PSRAM -DUNPHONE_SPIN=8
unphone8.build.loop_core=-DARDUINO_RUNNING_CORE=1
unphone8.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
unphone8.build.flash_type=qspi
unphone8.build.flash_type=qio
unphone8.build.psram_type=qspi
unphone8.build.memory_type={build.flash_type}_{build.psram_type}

Expand Down
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
9 changes: 5 additions & 4 deletions variants/AirM2M_CORE_ESP32C3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#define Pins_Arduino_h

#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

#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_INTERRUPT)
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)

static const uint8_t LED_BUILTIN = 12;
Expand Down
20 changes: 14 additions & 6 deletions variants/Bee_Data_Logger/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define USB_VID 0x303A
#define USB_PID 0x815C
#define USB_MANUFACTURER "Smart Bee Designs"
#define USB_PRODUCT "Bee Data Logger"
#define USB_SERIAL ""

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 13
#define NUM_ANALOG_INPUTS 7
#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

#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 Expand Up @@ -74,5 +75,12 @@ static const uint8_t LDO2 = 34;
static const uint8_t RGB_DATA = 40;
static const uint8_t RGB_PWR = 34;

#define PIN_NEOPIXEL RGB_DATA
// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+PIN_NEOPIXEL;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API neopixelWrite()
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

#endif /* Pins_Arduino_h */
13 changes: 7 additions & 6 deletions variants/Bee_Motion/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define USB_VID 0x303A
#define USB_PID 0x810D
#define USB_MANUFACTURER "Smart Bee Designs"
#define USB_PRODUCT "Bee Motion S3"
#define USB_SERIAL ""

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 21
#define NUM_ANALOG_INPUTS 12
#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

#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
28 changes: 21 additions & 7 deletions variants/Bee_Motion_Mini/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#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

#define EXTERNAL_NUM_INTERRUPTS 4
#define NUM_DIGITAL_PINS 4
#define NUM_ANALOG_INPUTS 2

#define analogInputToDigitalPin(p) (((p)<6)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<22)?(p):-1)
#define digitalPinHasPWM(p) (p < 22)
#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 < EXTERNAL_NUM_INTERRUPTS)

static const uint8_t TX = 21;
static const uint8_t RX = 20;

static const uint8_t BOOT_BTN = 9;
static const uint8_t PIR = 5;

static const uint8_t SDA = 8;
static const uint8_t SCL = 9;

static const uint8_t SS = 7;
static const uint8_t MOSI = 6;
static const uint8_t MISO = 5;
static const uint8_t SCK = 4;

static const uint8_t A0 = 0;
static const uint8_t A1 = 1;
static const uint8_t A2 = 2;
static const uint8_t A3 = 3;
static const uint8_t A4 = 4;
static const uint8_t A5 = 5;


#endif /* Pins_Arduino_h */
Expand Down
20 changes: 14 additions & 6 deletions variants/Bee_Motion_S3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define USB_VID 0x303A
#define USB_PID 0x8113
#define USB_MANUFACTURER "Smart Bee Designs"
#define USB_PRODUCT "Bee Motion S3"
#define USB_SERIAL ""

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 27
#define NUM_ANALOG_INPUTS 11
#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

#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 Expand Up @@ -81,5 +82,12 @@ static const uint8_t LDO2 = 34;
static const uint8_t RGB_DATA = 40;
static const uint8_t RGB_PWR = 34;

#define PIN_NEOPIXEL RGB_DATA
// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+PIN_NEOPIXEL;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API neopixelWrite()
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

#endif /* Pins_Arduino_h */
21 changes: 15 additions & 6 deletions variants/Bee_S3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define USB_VID 0x303A
#define USB_PID 0x8110
#define USB_MANUFACTURER "Smart Bee Designs"
#define USB_PRODUCT "BeeS3"
#define USB_SERIAL ""

#define EXTERNAL_NUM_INTERRUPTS 45
#define NUM_DIGITAL_PINS 15
#define NUM_ANALOG_INPUTS 8
#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

#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 Expand Up @@ -73,4 +74,12 @@ static const uint8_t VBAT_VOLTAGE = 1;
static const uint8_t RGB_DATA = 48;
static const uint8_t RGB_PWR = 34;

#define PIN_NEOPIXEL RGB_DATA
// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+PIN_NEOPIXEL;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API neopixelWrite()
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

#endif /* Pins_Arduino_h */
16 changes: 7 additions & 9 deletions variants/ET-Board/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 7
#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 LED_BUILTIN = 5;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN



static const uint8_t TX = 34;
static const uint8_t RX = 35;
Expand Down
13 changes: 7 additions & 6 deletions variants/Edgebox-ESP-100/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define EXTERNAL_NUM_INTERRUPTS 34
#define NUM_DIGITAL_PINS 34
#define NUM_ANALOG_INPUTS 2
#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)<2)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<34)?(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

//Programming and Debugging Port
static const uint8_t TXD = 43;
Expand Down
16 changes: 8 additions & 8 deletions variants/Microduino-esp32/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS 22
#define NUM_ANALOG_INPUTS 12
#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 LED_BUILTIN = -1;
static const uint8_t LED_BUILTIN = (uint8_t)-1;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN

#define MTDO 15
#define MTDI 12
Expand Down
15 changes: 7 additions & 8 deletions variants/Nebula_S3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.h"

#define USB_VID 0x303a
#define USB_PID 0x1001

#define EXTERNAL_NUM_INTERRUPTS 20
#define NUM_DIGITAL_PINS 20
#define NUM_ANALOG_INPUTS 6

#define analogInputToDigitalPin(p) (((p)<6)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<20)?(p):-1)
#define digitalPinHasPWM(p) (p < 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

#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 LED_BUILTIN = 45;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 64

Expand Down
14 changes: 7 additions & 7 deletions variants/S_ODI_Ultra_v1/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#define Pins_Arduino_h

#include <stdint.h>
#include "soc/soc_caps.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 LED_BUILTIN = 2;
static const uint8_t LED_BUILTINB = 4;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN
#define BUILTIN_LED2 LED_BUILTINB

static const uint8_t TX = 1;
Expand Down
9 changes: 5 additions & 4 deletions variants/VALTRACK_V4_MFW_ESP32_C3/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#define Pins_Arduino_h

#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

#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_INTERRUPT)
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)

static const uint8_t TX = 21;
Expand Down
Loading