1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-11 14:23:47 +01:00

Prepare some components for idf >= 5 (#5061)

This commit is contained in:
Jimmy Hedman
2023-07-27 07:18:02 +02:00
committed by GitHub
parent 959d1944fd
commit 3eff7e76aa
10 changed files with 32 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/application.h"
#include "esphome/core/defines.h"
#include <cinttypes>
namespace esphome {
namespace uart {
@@ -12,8 +13,8 @@ static const char *const TAG = "uart";
void UARTDevice::check_uart_settings(uint32_t baud_rate, uint8_t stop_bits, UARTParityOptions parity,
uint8_t data_bits) {
if (this->parent_->get_baud_rate() != baud_rate) {
ESP_LOGE(TAG, " Invalid baud_rate: Integration requested baud_rate %u but you have %u!", baud_rate,
this->parent_->get_baud_rate());
ESP_LOGE(TAG, " Invalid baud_rate: Integration requested baud_rate %" PRIu32 " but you have %" PRIu32 "!",
baud_rate, this->parent_->get_baud_rate());
}
if (this->parent_->get_stop_bits() != stop_bits) {
ESP_LOGE(TAG, " Invalid stop bits: Integration requested stop_bits %u but you have %u!", stop_bits,

View File

@@ -5,6 +5,7 @@
#include "esphome/core/defines.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include <cinttypes>
#ifdef USE_LOGGER
#include "esphome/components/logger/logger.h"
@@ -125,7 +126,7 @@ void IDFUARTComponent::dump_config() {
if (this->rx_pin_ != nullptr) {
ESP_LOGCONFIG(TAG, " RX Buffer Size: %u", this->rx_buffer_size_);
}
ESP_LOGCONFIG(TAG, " Baud Rate: %u baud", this->baud_rate_);
ESP_LOGCONFIG(TAG, " Baud Rate: %" PRIu32 " baud", this->baud_rate_);
ESP_LOGCONFIG(TAG, " Data Bits: %u", this->data_bits_);
ESP_LOGCONFIG(TAG, " Parity: %s", LOG_STR_ARG(parity_to_str(this->parity_)));
ESP_LOGCONFIG(TAG, " Stop bits: %u", this->stop_bits_);
@@ -150,7 +151,7 @@ bool IDFUARTComponent::peek_byte(uint8_t *data) {
if (this->has_peek_) {
*data = this->peek_byte_;
} else {
int len = uart_read_bytes(this->uart_num_, data, 1, 20 / portTICK_RATE_MS);
int len = uart_read_bytes(this->uart_num_, data, 1, 20 / portTICK_PERIOD_MS);
if (len == 0) {
*data = 0;
} else {
@@ -174,7 +175,7 @@ bool IDFUARTComponent::read_array(uint8_t *data, size_t len) {
this->has_peek_ = false;
}
if (length_to_read > 0)
uart_read_bytes(this->uart_num_, data, length_to_read, 20 / portTICK_RATE_MS);
uart_read_bytes(this->uart_num_, data, length_to_read, 20 / portTICK_PERIOD_MS);
xSemaphoreGive(this->lock_);
#ifdef USE_UART_DEBUGGER
for (size_t i = 0; i < len; i++) {