From 9f2b2f51ffbdc455e2ebbe6edde0f93041f73c2b Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 20 Jul 2021 11:12:22 +0200 Subject: [PATCH] Esp32 c3 support (#2035) --- esphome/components/api/api_server.h | 1 - esphome/components/api/user_services.cpp | 2 +- esphome/core/esphal.cpp | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/esphome/components/api/api_server.h b/esphome/components/api/api_server.h index add22e121e..68d1df2c1f 100644 --- a/esphome/components/api/api_server.h +++ b/esphome/components/api/api_server.h @@ -9,7 +9,6 @@ #include "util.h" #include "list_entities.h" #include "subscribe_state.h" -#include "homeassistant_service.h" #include "user_services.h" #ifdef ARDUINO_ARCH_ESP32 diff --git a/esphome/components/api/user_services.cpp b/esphome/components/api/user_services.cpp index 39e42bcc02..49618f5467 100644 --- a/esphome/components/api/user_services.cpp +++ b/esphome/components/api/user_services.cpp @@ -15,7 +15,7 @@ template<> std::string get_execute_arg_value(const ExecuteServiceAr template<> std::vector get_execute_arg_value>(const ExecuteServiceArgument &arg) { return arg.bool_array; } -template<> std::vector get_execute_arg_value>(const ExecuteServiceArgument &arg) { +template<> std::vector get_execute_arg_value>(const ExecuteServiceArgument &arg) { return arg.int_array; } template<> std::vector get_execute_arg_value>(const ExecuteServiceArgument &arg) { diff --git a/esphome/core/esphal.cpp b/esphome/core/esphal.cpp index d7adc8dbf1..6b8350991e 100644 --- a/esphome/core/esphal.cpp +++ b/esphome/core/esphal.cpp @@ -27,11 +27,16 @@ GPIOPin::GPIOPin(uint8_t pin, uint8_t mode, bool inverted) #ifdef ARDUINO_ARCH_ESP8266 gpio_read_(pin < 16 ? &GPI : &GP16I), gpio_mask_(pin < 16 ? (1UL << pin) : 1) -#endif -#ifdef ARDUINO_ARCH_ESP32 - gpio_set_(pin < 32 ? &GPIO.out_w1ts : &GPIO.out1_w1ts.val), +#elif ARDUINO_ARCH_ESP32 +#ifdef CONFIG_IDF_TARGET_ESP32C3 + gpio_set_(&GPIO.out_w1ts.val), + gpio_clear_(&GPIO.out_w1tc.val), + gpio_read_(&GPIO.in.val), +#else + gpio_set_(pin < 32 ? &GPIO.out_w1ts : &GPIO.out1_w1ts.val), gpio_clear_(pin < 32 ? &GPIO.out_w1tc : &GPIO.out1_w1tc.val), gpio_read_(pin < 32 ? &GPIO.in : &GPIO.in1.val), +#endif gpio_mask_(pin < 32 ? (1UL << pin) : (1UL << (pin - 32))) #endif { @@ -194,12 +199,16 @@ void ICACHE_RAM_ATTR ISRInternalGPIOPin::clear_interrupt() { GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, this->gpio_mask_); #endif #ifdef ARDUINO_ARCH_ESP32 +#ifdef CONFIG_IDF_TARGET_ESP32C3 + GPIO.status_w1tc.val = this->gpio_mask_; +#else if (this->pin_ < 32) { GPIO.status_w1tc = this->gpio_mask_; } else { GPIO.status1_w1tc.intr_st = this->gpio_mask_; } #endif +#endif } void ICACHE_RAM_ATTR HOT GPIOPin::pin_mode(uint8_t mode) {