Add support for GPIO_ANY

This commit is contained in:
Theo Arends 2020-10-03 15:06:52 +02:00
parent ad3cfa6cbb
commit 6f790c0bb0
4 changed files with 11 additions and 7 deletions

View File

@ -652,7 +652,7 @@
#define SDM120_SPEED 2400 // SDM120-Modbus RS485 serial speed (default: 2400 baud)
//#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy monitor (+0k6 code)
#define SDM630_SPEED 9600 // SDM630-Modbus RS485 serial speed (default: 9600 baud)
// #define SDM630_IMPORT // Show import active energy in MQTT and Web (+0k3 code)
// #define SDM630_IMPORT // Show import active energy in MQTT and Web (+0k3 code)
//#define USE_DDS2382 // Add support for Hiking DDS2382 Modbus energy monitor (+0k6 code)
#define DDS2382_SPEED 9600 // Hiking DDS2382 Modbus RS485 serial speed (default: 9600 baud)
//#define USE_DDSU666 // Add support for Chint DDSU666 Modbus energy monitor (+0k6 code)

View File

@ -1218,9 +1218,14 @@ void DumpConvertTable(void) {
uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index = 0);
uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index) {
uint16_t real_gpio = (gpio << 5) + index;
uint16_t real_gpio = gpio << 5;
uint16_t mask = 0xFFE0;
if (index < GPIO_ANY) {
real_gpio += index;
mask = 0xFFFF;
}
for (uint32_t i = 0; i < ARRAY_SIZE(gpio_pin); i++) {
if (gpio_pin[i] == real_gpio) {
if ((gpio_pin[i] & mask) == real_gpio) {
return i; // Pin number configured for gpio
}
}

View File

@ -695,6 +695,8 @@ enum UserSelectableAdc {
* ATTENTION: No user changeable features beyond this point - do not add templates !!!
\*********************************************************************************************/
#define GPIO_ANY 32 // Any GPIO
#ifdef ESP8266
#define MAX_GPI8_PIN 17 // Number of supported GPIO (0..16)

View File

@ -125,10 +125,7 @@ bool Xsns47(uint8_t function)
{
bool result = false;
if (PinUsed(GPIO_SSPI_MISO) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK) &&
(PinUsed(GPIO_SSPI_MAX31865_CS1) || PinUsed(GPIO_SSPI_MAX31865_CS1, 1) || PinUsed(GPIO_SSPI_MAX31865_CS1, 2) ||
PinUsed(GPIO_SSPI_MAX31865_CS1, 3) || PinUsed(GPIO_SSPI_MAX31865_CS1, 4) || PinUsed(GPIO_SSPI_MAX31865_CS1, 5))) {
if (PinUsed(GPIO_SSPI_MAX31865_CS1, GPIO_ANY) && PinUsed(GPIO_SSPI_MISO) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK)) {
switch (function) {
case FUNC_INIT:
MAX31865_Init();