Use SDK macros for matrix detach constants (#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 (https://github.com/espressif/esp-idf/issues/11737).
This commit is contained in:
parent
095008964d
commit
289c2a1405
1 changed files with 5 additions and 6 deletions
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "esp_system.h"
|
||||
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
|
||||
#include "soc/gpio_pins.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
||||
#include "esp32/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
|
|
@ -30,11 +30,10 @@
|
|||
#endif
|
||||
#else // ESP32 Before IDF 4.0
|
||||
#include "rom/gpio.h"
|
||||
#define GPIO_MATRIX_CONST_ZERO_INPUT GPIO_FUNC_IN_LOW
|
||||
#define GPIO_MATRIX_CONST_ONE_INPUT GPIO_FUNC_IN_HIGH
|
||||
#endif
|
||||
|
||||
#define MATRIX_DETACH_OUT_SIG 0x100
|
||||
#define MATRIX_DETACH_IN_LOW_PIN 0x30
|
||||
#define MATRIX_DETACH_IN_LOW_HIGH 0x38
|
||||
|
||||
void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable)
|
||||
{
|
||||
|
|
@ -43,7 +42,7 @@ void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool inv
|
|||
|
||||
void ARDUINO_ISR_ATTR pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable)
|
||||
{
|
||||
gpio_matrix_out(pin, MATRIX_DETACH_OUT_SIG, invertOut, invertEnable);
|
||||
gpio_matrix_out(pin, SIG_GPIO_OUT_IDX, invertOut, invertEnable);
|
||||
}
|
||||
|
||||
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
|
|||
|
||||
void ARDUINO_ISR_ATTR pinMatrixInDetach(uint8_t signal, bool high, bool inverted)
|
||||
{
|
||||
gpio_matrix_in(high?MATRIX_DETACH_IN_LOW_HIGH:MATRIX_DETACH_IN_LOW_PIN, signal, inverted);
|
||||
gpio_matrix_in(high?GPIO_MATRIX_CONST_ONE_INPUT:GPIO_MATRIX_CONST_ZERO_INPUT, signal, inverted);
|
||||
}
|
||||
/*
|
||||
void ARDUINO_ISR_ATTR intrMatrixAttach(uint32_t source, uint32_t inum){
|
||||
|
|
|
|||
Loading…
Reference in a new issue