diff --git a/esphome/components/max9611/max9611.cpp b/esphome/components/max9611/max9611.cpp index ca081b9f16..cf6f13d52d 100644 --- a/esphome/components/max9611/max9611.cpp +++ b/esphome/components/max9611/max9611.cpp @@ -42,17 +42,17 @@ void MAX9611Component::setup() { const uint8_t fast_mode_dat[] = {CONTROL_REGISTER_1_ADRR, MAX9611Multiplexer::MAX9611_MULTIPLEXER_FAST_MODE}; if (this->write(reinterpret_cast(&setup_dat), sizeof(setup_dat)) != ErrorCode::ERROR_OK) { - ESP_LOGE(TAG, "Failed to setup Max9611 during GAIN SET"); + ESP_LOGE(TAG, "GAIN SET failed"); return; } delay(SETUP_DELAY); if (this->write(reinterpret_cast(&fast_mode_dat), sizeof(fast_mode_dat)) != ErrorCode::ERROR_OK) { - ESP_LOGE(TAG, "Failed to setup Max9611 during FAST MODE SET"); + ESP_LOGE(TAG, "FAST MODE SET failed"); return; } } void MAX9611Component::dump_config() { - ESP_LOGCONFIG(TAG, "Dump Config max9611..."); + ESP_LOGCONFIG(TAG, "MAX9611:"); ESP_LOGCONFIG(TAG, " CSA Gain Register: %x", gain_); LOG_I2C_DEVICE(this); } @@ -63,7 +63,7 @@ void MAX9611Component::update() { // Just read the entire register map in a bulk read, faster than individually querying register. const ErrorCode read_result = this->read(register_map_, sizeof(register_map_)); if (write_result != ErrorCode::ERROR_OK || read_result != ErrorCode::ERROR_OK) { - ESP_LOGW(TAG, "MAX9611 Update FAILED!"); + ESP_LOGW(TAG, "Update failed"); return; } uint16_t csa_register = ((register_map_[CSA_DATA_BYTE_MSB_ADRR] << 8) | (register_map_[CSA_DATA_BYTE_LSB_ADRR])) >> 4; diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index 38e37300af..66812170be 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -1003,8 +1003,13 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool * @param variable_name Name for the queue */ void Nextion::add_no_result_to_queue_(const std::string &variable_name) { - // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - nextion::NextionQueue *nextion_queue = new nextion::NextionQueue; + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + nextion::NextionQueue *nextion_queue = allocator.allocate(1); + if (nextion_queue == nullptr) { + ESP_LOGW(TAG, "Failed to allocate NextionQueue"); + return; + } + new (nextion_queue) nextion::NextionQueue(); // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) nextion_queue->component = new nextion::NextionComponentBase; @@ -1137,8 +1142,13 @@ void Nextion::add_to_get_queue(NextionComponentBase *component) { if ((!this->is_setup() && !this->ignore_is_setup_)) return; - // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - nextion::NextionQueue *nextion_queue = new nextion::NextionQueue; + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + nextion::NextionQueue *nextion_queue = allocator.allocate(1); + if (nextion_queue == nullptr) { + ESP_LOGW(TAG, "Failed to allocate NextionQueue"); + return; + } + new (nextion_queue) nextion::NextionQueue(); nextion_queue->component = component; nextion_queue->queue_time = millis(); @@ -1165,8 +1175,13 @@ void Nextion::add_addt_command_to_queue(NextionComponentBase *component) { if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping()) return; - // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - nextion::NextionQueue *nextion_queue = new nextion::NextionQueue; + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + nextion::NextionQueue *nextion_queue = allocator.allocate(1); + if (nextion_queue == nullptr) { + ESP_LOGW(TAG, "Failed to allocate NextionQueue"); + return; + } + new (nextion_queue) nextion::NextionQueue(); nextion_queue->component = component; nextion_queue->queue_time = millis(); diff --git a/esphome/components/rp2040/gpio.cpp b/esphome/components/rp2040/gpio.cpp index e32b93b5c2..3927815e46 100644 --- a/esphome/components/rp2040/gpio.cpp +++ b/esphome/components/rp2040/gpio.cpp @@ -8,7 +8,7 @@ namespace rp2040 { static const char *const TAG = "rp2040"; -static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) { +static int flags_to_mode(gpio::Flags flags, uint8_t pin) { if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone) return INPUT; } else if (flags == gpio::FLAG_OUTPUT) { @@ -25,14 +25,16 @@ static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) { } struct ISRPinArg { + uint32_t mask; uint8_t pin; bool inverted; }; ISRInternalGPIOPin RP2040GPIOPin::to_isr() const { auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory) - arg->pin = pin_; - arg->inverted = inverted_; + arg->pin = this->pin_; + arg->inverted = this->inverted_; + arg->mask = 1 << this->pin_; return ISRInternalGPIOPin((void *) arg); } @@ -81,21 +83,36 @@ void RP2040GPIOPin::detach_interrupt() const { detachInterrupt(pin_); } using namespace rp2040; bool IRAM_ATTR ISRInternalGPIOPin::digital_read() { - auto *arg = reinterpret_cast(arg_); - return bool(digitalRead(arg->pin)) != arg->inverted; // NOLINT + auto *arg = reinterpret_cast(this->arg_); + return bool(sio_hw->gpio_in & arg->mask) != arg->inverted; } + void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) { - auto *arg = reinterpret_cast(arg_); - digitalWrite(arg->pin, value != arg->inverted ? 1 : 0); // NOLINT + auto *arg = reinterpret_cast(this->arg_); + if (value != arg->inverted) { + sio_hw->gpio_set = arg->mask; + } else { + sio_hw->gpio_clr = arg->mask; + } } + void IRAM_ATTR ISRInternalGPIOPin::clear_interrupt() { // TODO: implement // auto *arg = reinterpret_cast(arg_); // GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1UL << arg->pin); } + void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) { - auto *arg = reinterpret_cast(arg_); - pinMode(arg->pin, flags_to_mode(flags, arg->pin)); // NOLINT + auto *arg = reinterpret_cast(this->arg_); + if (flags & gpio::FLAG_OUTPUT) { + sio_hw->gpio_oe_set = arg->mask; + } else if (flags & gpio::FLAG_INPUT) { + sio_hw->gpio_oe_clr = arg->mask; + hw_write_masked(&padsbank0_hw->io[arg->pin], + (bool_to_bit(flags & gpio::FLAG_PULLUP) << PADS_BANK0_GPIO0_PUE_LSB) | + (bool_to_bit(flags & gpio::FLAG_PULLDOWN) << PADS_BANK0_GPIO0_PDE_LSB), + PADS_BANK0_GPIO0_PUE_BITS | PADS_BANK0_GPIO0_PDE_BITS); + } } } // namespace esphome diff --git a/esphome/components/weikai/__init__.py b/esphome/components/weikai/__init__.py index 4c8f7e700d..796423438e 100644 --- a/esphome/components/weikai/__init__.py +++ b/esphome/components/weikai/__init__.py @@ -16,6 +16,7 @@ CODEOWNERS = ["@DrCoolZic"] AUTO_LOAD = ["uart"] MULTI_CONF = True +CONF_DATA_BITS = "data_bits" CONF_STOP_BITS = "stop_bits" CONF_PARITY = "parity" CONF_CRYSTAL = "crystal" @@ -60,6 +61,7 @@ WKBASE_SCHEMA = cv.Schema( cv.Required(CONF_ID): cv.declare_id(WeikaiChannel), cv.Optional(CONF_CHANNEL, default=0): cv.int_range(min=0, max=3), cv.Required(CONF_BAUD_RATE): cv.int_range(min=1), + cv.Optional(CONF_DATA_BITS, default=8): cv.one_of(8, int=True), cv.Optional(CONF_STOP_BITS, default=1): cv.one_of(1, 2, int=True), cv.Optional(CONF_PARITY, default="NONE"): cv.enum( uart.UART_PARITY_OPTIONS, upper=True diff --git a/esphome/core/hal.h b/esphome/core/hal.h index 034f9d692f..0ccf21ad83 100644 --- a/esphome/core/hal.h +++ b/esphome/core/hal.h @@ -24,6 +24,11 @@ #define PROGMEM ICACHE_RODATA_ATTR #endif +#elif defined(USE_RP2040) + +#define IRAM_ATTR __attribute__((noinline, long_call, section(".time_critical"))) +#define PROGMEM + #else #define IRAM_ATTR diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 02778a6de9..78deec8e65 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -604,6 +604,10 @@ class ESPHomeDumper(yaml.SafeDumper): return self.represent_secret(value.id) return self.represent_stringify(value.id) + # The below override configures this dumper to indent output YAML properly: + def increase_indent(self, flow=False, indentless=False): + return super().increase_indent(flow, False) + ESPHomeDumper.add_multi_representer( dict, lambda dumper, value: dumper.represent_mapping("tag:yaml.org,2002:map", value) diff --git a/platformio.ini b/platformio.ini index ec1e54de09..0e7bd80bc6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -323,6 +323,17 @@ build_flags = ${flags:clangtidy.build_flags} -DUSE_ESP32_VARIANT_ESP32C3 +;;;;;;;; ESP32-C6 ;;;;;;;; + +[env:esp32c6-idf] +extends = common:esp32-idf +board = esp32-c6-devkitc-1 +board_build.esp-idf.sdkconfig_path = .temp/sdkconfig-esp32c6-idf +build_flags = + ${common:esp32-idf.build_flags} + ${flags:runtime.build_flags} + -DUSE_ESP32_VARIANT_ESP32C6 + ;;;;;;;; ESP32-S2 ;;;;;;;; [env:esp32s2-arduino] diff --git a/tests/components/wk2132_i2c/common.yaml b/tests/components/wk2132_i2c/common.yaml index f9c8ab756d..942e01aafc 100644 --- a/tests/components/wk2132_i2c/common.yaml +++ b/tests/components/wk2132_i2c/common.yaml @@ -17,4 +17,10 @@ wk2132_i2c: parity: none - id: wk2132_id_1 channel: 1 - baud_rate: 19200 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: wk2132_id_1 + id: distance_sensor diff --git a/tests/components/wk2132_i2c/test.esp32-ard.yaml b/tests/components/wk2132_i2c/test.esp32-ard.yaml index 3b761d3fc1..94552c5a40 100644 --- a/tests/components/wk2132_i2c/test.esp32-ard.yaml +++ b/tests/components/wk2132_i2c/test.esp32-ard.yaml @@ -3,3 +3,4 @@ substitutions: sda_pin: GPIO21 <<: !include common.yaml + diff --git a/tests/components/wk2132_spi/common.yaml b/tests/components/wk2132_spi/common.yaml index b21e89120c..a077b36998 100644 --- a/tests/components/wk2132_spi/common.yaml +++ b/tests/components/wk2132_spi/common.yaml @@ -18,4 +18,10 @@ wk2132_spi: parity: none - id: wk2132_spi_id1 channel: 1 - baud_rate: 921600 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: wk2132_spi_id1 + id: distance_sensor diff --git a/tests/components/wk2168_i2c/common.yaml b/tests/components/wk2168_i2c/common.yaml index fe4689d6db..10463e8abf 100644 --- a/tests/components/wk2168_i2c/common.yaml +++ b/tests/components/wk2168_i2c/common.yaml @@ -24,7 +24,13 @@ wk2168_i2c: baud_rate: 115200 - id: id3 channel: 3 - baud_rate: 115200 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: id3 + id: distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/components/wk2168_spi/common.yaml b/tests/components/wk2168_spi/common.yaml index 7626e18df6..fb126193fc 100644 --- a/tests/components/wk2168_spi/common.yaml +++ b/tests/components/wk2168_spi/common.yaml @@ -24,7 +24,13 @@ wk2168_spi: baud_rate: 115200 - id: id3 channel: 3 - baud_rate: 115200 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: id3 + id: distance_sensor # individual binary_sensor inputs binary_sensor: diff --git a/tests/components/wk2204_i2c/common.yaml b/tests/components/wk2204_i2c/common.yaml index 80f636c690..70c0f4babf 100644 --- a/tests/components/wk2204_i2c/common.yaml +++ b/tests/components/wk2204_i2c/common.yaml @@ -25,4 +25,10 @@ wk2204_i2c: parity: none - id: wk2204_id_3 channel: 3 - baud_rate: 19200 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: wk2204_id_3 + id: distance_sensor diff --git a/tests/components/wk2204_spi/common.yaml b/tests/components/wk2204_spi/common.yaml index 3bae9c9a6d..a08cdb906f 100644 --- a/tests/components/wk2204_spi/common.yaml +++ b/tests/components/wk2204_spi/common.yaml @@ -26,4 +26,10 @@ wk2204_spi: parity: none - id: wk2204_spi_id3 channel: 3 - baud_rate: 921600 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: wk2204_spi_id3 + id: distance_sensor diff --git a/tests/components/wk2212_i2c/common.yaml b/tests/components/wk2212_i2c/common.yaml index 2e891c5520..0759ef8688 100644 --- a/tests/components/wk2212_i2c/common.yaml +++ b/tests/components/wk2212_i2c/common.yaml @@ -18,10 +18,16 @@ wk2212_i2c: parity: none - id: uart_i2c_id1 channel: 1 - baud_rate: 115200 + baud_rate: 9600 stop_bits: 1 parity: none +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: uart_i2c_id1 + id: distance_sensor + # individual binary_sensor inputs binary_sensor: - platform: gpio diff --git a/tests/components/wk2212_spi/common.yaml b/tests/components/wk2212_spi/common.yaml index ad9f11d9e8..693d2a9ab2 100644 --- a/tests/components/wk2212_spi/common.yaml +++ b/tests/components/wk2212_spi/common.yaml @@ -18,7 +18,13 @@ wk2212_spi: parity: none - id: id1 channel: 1 - baud_rate: 115200 + baud_rate: 9600 + +# Ensures a sensor doesn't break validation +sensor: + - platform: a02yyuw + uart_id: id1 + id: distance_sensor # individual binary_sensor inputs binary_sensor: @@ -55,4 +61,3 @@ switch: mode: output: true inverted: true - diff --git a/tests/test_build_components/build_components_base.esp32-c6-idf.yaml b/tests/test_build_components/build_components_base.esp32-c6-idf.yaml new file mode 100644 index 0000000000..9dbc465ca2 --- /dev/null +++ b/tests/test_build_components/build_components_base.esp32-c6-idf.yaml @@ -0,0 +1,17 @@ +esphome: + name: componenttestesp32c6idf + friendly_name: $component_name + +esp32: + board: esp32-c6-devkitc-1 + framework: + type: esp-idf + +logger: + level: VERY_VERBOSE + +packages: + component_under_test: !include + file: $component_test_file + vars: + component_test_file: $component_test_file