Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 289c2a1

Browse filesBrowse files
authored
Use SDK macros for matrix detach constants (espressif#8345)
The constants that need to be passed to gpio_matrix_in and gpio_matrix_out to detach an input or output pin from a peripheral vary by platform. Use SIG_GPIO_OUT_IDX to detach an output, and GPIO_MATRIX_CONST_ONE_INPUT and GPIO_MATRIX_CONST_ZERO_INPUT to detach an input. ESP32 before IDF 4.0 didn't define GPIO_MATRIX_CONST_*_INPUT, so add compatibility #defines for GPIO_FUNC_IN_LOW/HIGH. GPIO_FUNC_IN_LOW/HIGH exist in IDF 4.0+, but can't be used because they have the wrong values for ESP32-C3 at least in IDF 4.4.3 (espressif/esp-idf#11737).
1 parent 0950089 commit 289c2a1
Copy full SHA for 289c2a1

File tree

Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed
Open diff view settings
Collapse file

‎cores/esp32/esp32-hal-matrix.c‎

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-matrix.c
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include "esp_system.h"
1919
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
20+
#include "soc/gpio_pins.h"
2021
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
21-
#include "esp32/rom/gpio.h"
2222
#elif CONFIG_IDF_TARGET_ESP32S2
2323
#include "esp32s2/rom/gpio.h"
2424
#elif CONFIG_IDF_TARGET_ESP32S3
@@ -30,11 +30,10 @@
3030
#endif
3131
#else // ESP32 Before IDF 4.0
3232
#include "rom/gpio.h"
33+
#define GPIO_MATRIX_CONST_ZERO_INPUT GPIO_FUNC_IN_LOW
34+
#define GPIO_MATRIX_CONST_ONE_INPUT GPIO_FUNC_IN_HIGH
3335
#endif
3436

35-
#define MATRIX_DETACH_OUT_SIG 0x100
36-
#define MATRIX_DETACH_IN_LOW_PIN 0x30
37-
#define MATRIX_DETACH_IN_LOW_HIGH 0x38
3837

3938
void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable)
4039
{
@@ -43,7 +42,7 @@ void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool inv
4342

4443
void ARDUINO_ISR_ATTR pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable)
4544
{
46-
gpio_matrix_out(pin, MATRIX_DETACH_OUT_SIG, invertOut, invertEnable);
45+
gpio_matrix_out(pin, SIG_GPIO_OUT_IDX, invertOut, invertEnable);
4746
}
4847

4948
void ARDUINO_ISR_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool inverted)
@@ -53,7 +52,7 @@ void ARDUINO_ISR_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool invert
5352

5453
void ARDUINO_ISR_ATTR pinMatrixInDetach(uint8_t signal, bool high, bool inverted)
5554
{
56-
gpio_matrix_in(high?MATRIX_DETACH_IN_LOW_HIGH:MATRIX_DETACH_IN_LOW_PIN, signal, inverted);
55+
gpio_matrix_in(high?GPIO_MATRIX_CONST_ONE_INPUT:GPIO_MATRIX_CONST_ZERO_INPUT, signal, inverted);
5756
}
5857
/*
5958
void ARDUINO_ISR_ATTR intrMatrixAttach(uint32_t source, uint32_t inum){

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.