mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Memset all structs to 0
This commit is contained in:
parent
c1e7306ac6
commit
bd55a56db0
2 changed files with 7 additions and 0 deletions
|
@ -32,6 +32,7 @@ static bool IRAM_ATTR HOT rmt_callback(rmt_channel_handle_t channel, const rmt_r
|
||||||
void RemoteReceiverComponent::setup() {
|
void RemoteReceiverComponent::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up Remote Receiver...");
|
ESP_LOGCONFIG(TAG, "Setting up Remote Receiver...");
|
||||||
rmt_rx_channel_config_t channel{};
|
rmt_rx_channel_config_t channel{};
|
||||||
|
memset(&channel, 0, sizeof(channel));
|
||||||
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
||||||
channel.resolution_hz = 1 * 1000 * 1000;
|
channel.resolution_hz = 1 * 1000 * 1000;
|
||||||
channel.mem_block_symbols = MEM_BLOCK_SIZE * this->mem_block_num_;
|
channel.mem_block_symbols = MEM_BLOCK_SIZE * this->mem_block_num_;
|
||||||
|
@ -56,6 +57,7 @@ void RemoteReceiverComponent::setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rmt_rx_event_callbacks_t callbacks{};
|
rmt_rx_event_callbacks_t callbacks{};
|
||||||
|
memset(&callbacks, 0, sizeof(callbacks));
|
||||||
callbacks.on_recv_done = rmt_callback;
|
callbacks.on_recv_done = rmt_callback;
|
||||||
error = rmt_rx_register_event_callbacks(this->channel_, &callbacks, &this->store_);
|
error = rmt_rx_register_event_callbacks(this->channel_, &callbacks, &this->store_);
|
||||||
if (error != ESP_OK) {
|
if (error != ESP_OK) {
|
||||||
|
@ -68,6 +70,7 @@ void RemoteReceiverComponent::setup() {
|
||||||
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
|
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
|
||||||
uint32_t max_filter_ns = 255u * 1000 / this->clock_divider_;
|
uint32_t max_filter_ns = 255u * 1000 / this->clock_divider_;
|
||||||
uint32_t max_idle_ns = 65535u * 1000;
|
uint32_t max_idle_ns = 65535u * 1000;
|
||||||
|
memset(&this->store_.config, 0, sizeof(this->store_.config));
|
||||||
this->store_.config.signal_range_min_ns = std::min(this->filter_us_ * 1000, max_filter_ns);
|
this->store_.config.signal_range_min_ns = std::min(this->filter_us_ * 1000, max_filter_ns);
|
||||||
this->store_.config.signal_range_max_ns = std::min(this->idle_us_ * 1000, max_idle_ns);
|
this->store_.config.signal_range_max_ns = std::min(this->idle_us_ * 1000, max_idle_ns);
|
||||||
this->store_.receive_size = (MEM_BLOCK_SIZE * this->mem_block_num_ + 1) * sizeof(rmt_symbol_word_t);
|
this->store_.receive_size = (MEM_BLOCK_SIZE * this->mem_block_num_ + 1) * sizeof(rmt_symbol_word_t);
|
||||||
|
|
|
@ -33,6 +33,7 @@ void RemoteTransmitterComponent::dump_config() {
|
||||||
|
|
||||||
void RemoteTransmitterComponent::configure_rmt_() {
|
void RemoteTransmitterComponent::configure_rmt_() {
|
||||||
rmt_tx_channel_config_t channel{};
|
rmt_tx_channel_config_t channel{};
|
||||||
|
memset(&channel, 0, sizeof(channel));
|
||||||
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
channel.clk_src = RMT_CLK_SRC_DEFAULT;
|
||||||
channel.resolution_hz = 1 * 1000 * 1000;
|
channel.resolution_hz = 1 * 1000 * 1000;
|
||||||
channel.gpio_num = gpio_num_t(this->pin_->get_pin());
|
channel.gpio_num = gpio_num_t(this->pin_->get_pin());
|
||||||
|
@ -57,6 +58,7 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rmt_copy_encoder_config_t encoder{};
|
rmt_copy_encoder_config_t encoder{};
|
||||||
|
memset(&encoder, 0, sizeof(encoder));
|
||||||
error = rmt_new_copy_encoder(&encoder, &this->encoder_);
|
error = rmt_new_copy_encoder(&encoder, &this->encoder_);
|
||||||
if (error != ESP_OK) {
|
if (error != ESP_OK) {
|
||||||
this->error_code_ = error;
|
this->error_code_ = error;
|
||||||
|
@ -66,6 +68,7 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rmt_carrier_config_t carrier{};
|
rmt_carrier_config_t carrier{};
|
||||||
|
memset(&carrier, 0, sizeof(carrier));
|
||||||
if (this->current_carrier_frequency_ == 0 || this->carrier_duty_percent_ == 100) {
|
if (this->current_carrier_frequency_ == 0 || this->carrier_duty_percent_ == 100) {
|
||||||
carrier.frequency_hz = 0;
|
carrier.frequency_hz = 0;
|
||||||
carrier.duty_cycle = 100;
|
carrier.duty_cycle = 100;
|
||||||
|
@ -141,6 +144,7 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen
|
||||||
this->transmit_trigger_->trigger();
|
this->transmit_trigger_->trigger();
|
||||||
for (uint32_t i = 0; i < send_times; i++) {
|
for (uint32_t i = 0; i < send_times; i++) {
|
||||||
rmt_transmit_config_t config{};
|
rmt_transmit_config_t config{};
|
||||||
|
memset(&config, 0, sizeof(config));
|
||||||
config.loop_count = 0;
|
config.loop_count = 0;
|
||||||
config.flags.eot_level = this->inverted_;
|
config.flags.eot_level = this->inverted_;
|
||||||
esp_err_t error = rmt_transmit(this->channel_, this->encoder_, this->rmt_temp_.data(),
|
esp_err_t error = rmt_transmit(this->channel_, this->encoder_, this->rmt_temp_.data(),
|
||||||
|
|
Loading…
Reference in a new issue