mirror of
https://github.com/esphome/esphome.git
synced 2025-09-30 00:52:20 +01:00
Bump ESP32 Arduino version to 3.1.3 (#8604)
Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
@@ -4,15 +4,12 @@ from esphome.components import esp32, esp32_rmt, remote_base
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_BUFFER_SIZE,
|
||||
CONF_CLOCK_DIVIDER,
|
||||
CONF_CLOCK_RESOLUTION,
|
||||
CONF_DUMP,
|
||||
CONF_FILTER,
|
||||
CONF_ID,
|
||||
CONF_IDLE,
|
||||
CONF_MEMORY_BLOCKS,
|
||||
CONF_PIN,
|
||||
CONF_RMT_CHANNEL,
|
||||
CONF_RMT_SYMBOLS,
|
||||
CONF_TOLERANCE,
|
||||
CONF_TYPE,
|
||||
@@ -103,49 +100,36 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
|
||||
cv.positive_time_period_microseconds,
|
||||
cv.Range(max=TimePeriod(microseconds=4294967295)),
|
||||
),
|
||||
cv.SplitDefault(CONF_CLOCK_DIVIDER, esp32_arduino=80): cv.All(
|
||||
cv.only_on_esp32,
|
||||
cv.only_with_arduino,
|
||||
cv.int_range(min=1, max=255),
|
||||
),
|
||||
cv.Optional(CONF_CLOCK_RESOLUTION): cv.All(
|
||||
cv.only_on_esp32,
|
||||
cv.only_with_esp_idf,
|
||||
esp32_rmt.validate_clock_resolution(),
|
||||
),
|
||||
cv.Optional(CONF_IDLE, default="10ms"): cv.All(
|
||||
cv.positive_time_period_microseconds,
|
||||
cv.Range(max=TimePeriod(microseconds=4294967295)),
|
||||
),
|
||||
cv.SplitDefault(CONF_MEMORY_BLOCKS, esp32_arduino=3): cv.All(
|
||||
cv.only_with_arduino, cv.int_range(min=1, max=8)
|
||||
),
|
||||
cv.Optional(CONF_RMT_CHANNEL): cv.All(
|
||||
cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=False)
|
||||
),
|
||||
cv.SplitDefault(
|
||||
CONF_RMT_SYMBOLS,
|
||||
esp32_idf=192,
|
||||
esp32_s2_idf=192,
|
||||
esp32_s3_idf=192,
|
||||
esp32_p4_idf=192,
|
||||
esp32_c3_idf=96,
|
||||
esp32_c5_idf=96,
|
||||
esp32_c6_idf=96,
|
||||
esp32_h2_idf=96,
|
||||
): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)),
|
||||
esp32=192,
|
||||
esp32_s2=192,
|
||||
esp32_s3=192,
|
||||
esp32_p4=192,
|
||||
esp32_c3=96,
|
||||
esp32_c5=96,
|
||||
esp32_c6=96,
|
||||
esp32_h2=96,
|
||||
): cv.All(cv.only_on_esp32, cv.int_range(min=2)),
|
||||
cv.Optional(CONF_FILTER_SYMBOLS): cv.All(
|
||||
cv.only_with_esp_idf, cv.int_range(min=0)
|
||||
cv.only_on_esp32, cv.int_range(min=0)
|
||||
),
|
||||
cv.SplitDefault(
|
||||
CONF_RECEIVE_SYMBOLS,
|
||||
esp32_idf=192,
|
||||
): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)),
|
||||
esp32=192,
|
||||
): cv.All(cv.only_on_esp32, cv.int_range(min=2)),
|
||||
cv.Optional(CONF_USE_DMA): cv.All(
|
||||
esp32.only_on_variant(
|
||||
supported=[esp32.const.VARIANT_ESP32S3, esp32.const.VARIANT_ESP32P4]
|
||||
),
|
||||
cv.only_with_esp_idf,
|
||||
cv.boolean,
|
||||
),
|
||||
}
|
||||
@@ -156,24 +140,15 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
|
||||
async def to_code(config):
|
||||
pin = await cg.gpio_pin_expression(config[CONF_PIN])
|
||||
if CORE.is_esp32:
|
||||
if esp32_rmt.use_new_rmt_driver():
|
||||
var = cg.new_Pvariable(config[CONF_ID], pin)
|
||||
cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS]))
|
||||
cg.add(var.set_receive_symbols(config[CONF_RECEIVE_SYMBOLS]))
|
||||
if CONF_USE_DMA in config:
|
||||
cg.add(var.set_with_dma(config[CONF_USE_DMA]))
|
||||
if CONF_CLOCK_RESOLUTION in config:
|
||||
cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION]))
|
||||
if CONF_FILTER_SYMBOLS in config:
|
||||
cg.add(var.set_filter_symbols(config[CONF_FILTER_SYMBOLS]))
|
||||
else:
|
||||
if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None:
|
||||
var = cg.new_Pvariable(
|
||||
config[CONF_ID], pin, rmt_channel, config[CONF_MEMORY_BLOCKS]
|
||||
)
|
||||
else:
|
||||
var = cg.new_Pvariable(config[CONF_ID], pin, config[CONF_MEMORY_BLOCKS])
|
||||
cg.add(var.set_clock_divider(config[CONF_CLOCK_DIVIDER]))
|
||||
var = cg.new_Pvariable(config[CONF_ID], pin)
|
||||
cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS]))
|
||||
cg.add(var.set_receive_symbols(config[CONF_RECEIVE_SYMBOLS]))
|
||||
if CONF_USE_DMA in config:
|
||||
cg.add(var.set_with_dma(config[CONF_USE_DMA]))
|
||||
if CONF_CLOCK_RESOLUTION in config:
|
||||
cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION]))
|
||||
if CONF_FILTER_SYMBOLS in config:
|
||||
cg.add(var.set_filter_symbols(config[CONF_FILTER_SYMBOLS]))
|
||||
else:
|
||||
var = cg.new_Pvariable(config[CONF_ID], pin)
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
|
||||
#if defined(USE_ESP32)
|
||||
#include <driver/rmt_rx.h>
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ struct RemoteReceiverComponentStore {
|
||||
uint32_t filter_us{10};
|
||||
ISRInternalGPIOPin pin;
|
||||
};
|
||||
#elif defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
|
||||
#elif defined(USE_ESP32)
|
||||
struct RemoteReceiverComponentStore {
|
||||
/// Stores RMT symbols and rx done event data
|
||||
volatile uint8_t *buffer{nullptr};
|
||||
@@ -55,21 +55,13 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase,
|
||||
|
||||
{
|
||||
public:
|
||||
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5
|
||||
RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1)
|
||||
: RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {}
|
||||
|
||||
RemoteReceiverComponent(InternalGPIOPin *pin, rmt_channel_t channel, uint8_t mem_block_num = 1)
|
||||
: RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(channel, mem_block_num) {}
|
||||
#else
|
||||
RemoteReceiverComponent(InternalGPIOPin *pin) : RemoteReceiverBase(pin) {}
|
||||
#endif
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void loop() override;
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
|
||||
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5
|
||||
#ifdef USE_ESP32
|
||||
void set_filter_symbols(uint32_t filter_symbols) { this->filter_symbols_ = filter_symbols; }
|
||||
void set_receive_symbols(uint32_t receive_symbols) { this->receive_symbols_ = receive_symbols; }
|
||||
void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
|
||||
@@ -80,21 +72,16 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase,
|
||||
|
||||
protected:
|
||||
#ifdef USE_ESP32
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
void decode_rmt_(rmt_symbol_word_t *item, size_t item_count);
|
||||
rmt_channel_handle_t channel_{NULL};
|
||||
uint32_t filter_symbols_{0};
|
||||
uint32_t receive_symbols_{0};
|
||||
bool with_dma_{false};
|
||||
#else
|
||||
void decode_rmt_(rmt_item32_t *item, size_t item_count);
|
||||
RingbufHandle_t ringbuf_;
|
||||
#endif
|
||||
esp_err_t error_code_{ESP_OK};
|
||||
std::string error_string_{""};
|
||||
#endif
|
||||
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || (defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5)
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || defined(USE_ESP32)
|
||||
RemoteReceiverComponentStore store_;
|
||||
HighFrequencyLoopRequester high_freq_;
|
||||
#endif
|
||||
|
@@ -14,7 +14,6 @@ static const uint32_t RMT_CLK_FREQ = 32000000;
|
||||
static const uint32_t RMT_CLK_FREQ = 80000000;
|
||||
#endif
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
static bool IRAM_ATTR HOT rmt_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *event, void *arg) {
|
||||
RemoteReceiverComponentStore *store = (RemoteReceiverComponentStore *) arg;
|
||||
rmt_rx_done_event_data_t *event_buffer = (rmt_rx_done_event_data_t *) (store->buffer + store->buffer_write);
|
||||
@@ -37,11 +36,9 @@ static bool IRAM_ATTR HOT rmt_callback(rmt_channel_handle_t channel, const rmt_r
|
||||
store->buffer_write = next_write;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RemoteReceiverComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
rmt_rx_channel_config_t channel;
|
||||
memset(&channel, 0, sizeof(channel));
|
||||
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
||||
@@ -105,62 +102,11 @@ void RemoteReceiverComponent::setup() {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
#else
|
||||
this->pin_->setup();
|
||||
rmt_config_t rmt{};
|
||||
this->config_rmt(rmt);
|
||||
rmt.gpio_num = gpio_num_t(this->pin_->get_pin());
|
||||
rmt.rmt_mode = RMT_MODE_RX;
|
||||
if (this->filter_us_ == 0) {
|
||||
rmt.rx_config.filter_en = false;
|
||||
} else {
|
||||
rmt.rx_config.filter_en = true;
|
||||
rmt.rx_config.filter_ticks_thresh = static_cast<uint8_t>(
|
||||
std::min(this->from_microseconds_(this->filter_us_) * this->clock_divider_, (uint32_t) 255));
|
||||
}
|
||||
rmt.rx_config.idle_threshold =
|
||||
static_cast<uint16_t>(std::min(this->from_microseconds_(this->idle_us_), (uint32_t) 65535));
|
||||
|
||||
esp_err_t error = rmt_config(&rmt);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_config";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
error = rmt_driver_install(this->channel_, this->buffer_size_, 0);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
if (error == ESP_ERR_INVALID_STATE) {
|
||||
this->error_string_ = str_sprintf("RMT channel %i is already in use by another component", this->channel_);
|
||||
} else {
|
||||
this->error_string_ = "in rmt_driver_install";
|
||||
}
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
error = rmt_get_ringbuf_handle(this->channel_, &this->ringbuf_);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_get_ringbuf_handle";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
error = rmt_rx_start(this->channel_, true);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_rx_start";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RemoteReceiverComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Remote Receiver:");
|
||||
LOG_PIN(" Pin: ", this->pin_);
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Clock resolution: %" PRIu32 " hz\n"
|
||||
" RMT symbols: %" PRIu32 "\n"
|
||||
@@ -172,22 +118,6 @@ void RemoteReceiverComponent::dump_config() {
|
||||
this->clock_resolution_, this->rmt_symbols_, this->filter_symbols_, this->receive_symbols_,
|
||||
this->tolerance_, (this->tolerance_mode_ == remote_base::TOLERANCE_MODE_TIME) ? " us" : "%",
|
||||
this->filter_us_, this->idle_us_);
|
||||
#else
|
||||
if (this->pin_->digital_read()) {
|
||||
ESP_LOGW(TAG, "Remote Receiver Signal starts with a HIGH value. Usually this means you have to "
|
||||
"invert the signal using 'inverted: True' in the pin schema!");
|
||||
}
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Channel: %d\n"
|
||||
" RMT memory blocks: %d\n"
|
||||
" Clock divider: %u\n"
|
||||
" Tolerance: %" PRIu32 "%s\n"
|
||||
" Filter out pulses shorter than: %" PRIu32 " us\n"
|
||||
" Signal is done after %" PRIu32 " us of no changes",
|
||||
this->channel_, this->mem_block_num_, this->clock_divider_, this->tolerance_,
|
||||
(this->tolerance_mode_ == remote_base::TOLERANCE_MODE_TIME) ? " us" : "%", this->filter_us_,
|
||||
this->idle_us_);
|
||||
#endif
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, "Configuring RMT driver failed: %s (%s)", esp_err_to_name(this->error_code_),
|
||||
this->error_string_.c_str());
|
||||
@@ -195,7 +125,6 @@ void RemoteReceiverComponent::dump_config() {
|
||||
}
|
||||
|
||||
void RemoteReceiverComponent::loop() {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
if (this->store_.error != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Receive error");
|
||||
this->error_code_ = this->store_.error;
|
||||
@@ -221,25 +150,9 @@ void RemoteReceiverComponent::loop() {
|
||||
this->call_listeners_dumpers_();
|
||||
}
|
||||
}
|
||||
#else
|
||||
size_t len = 0;
|
||||
auto *item = (rmt_item32_t *) xRingbufferReceive(this->ringbuf_, &len, 0);
|
||||
if (item != nullptr) {
|
||||
this->decode_rmt_(item, len / sizeof(rmt_item32_t));
|
||||
vRingbufferReturnItem(this->ringbuf_, item);
|
||||
|
||||
if (!this->temp_.empty()) {
|
||||
this->call_listeners_dumpers_();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
void RemoteReceiverComponent::decode_rmt_(rmt_symbol_word_t *item, size_t item_count) {
|
||||
#else
|
||||
void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t item_count) {
|
||||
#endif
|
||||
bool prev_level = false;
|
||||
bool idle_level = false;
|
||||
uint32_t prev_length = 0;
|
||||
|
Reference in New Issue
Block a user