ESPHome  2024.11.3
uart_component_esp_idf.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_ESP_IDF
4 
5 #include <driver/uart.h>
7 #include "uart_component.h"
8 
9 namespace esphome {
10 namespace uart {
11 
12 class IDFUARTComponent : public UARTComponent, public Component {
13  public:
14  void setup() override;
15  void dump_config() override;
16  float get_setup_priority() const override { return setup_priority::BUS; }
17 
18  void write_array(const uint8_t *data, size_t len) override;
19 
20  bool peek_byte(uint8_t *data) override;
21  bool read_array(uint8_t *data, size_t len) override;
22 
23  int available() override;
24  void flush() override;
25 
26  uint8_t get_hw_serial_number() { return this->uart_num_; }
27  QueueHandle_t *get_uart_event_queue() { return &this->uart_event_queue_; }
28 
41  void load_settings(bool dump_config) override;
42  void load_settings() override { this->load_settings(true); }
43 
44  protected:
45  void check_logger_conflict() override;
46  uart_port_t uart_num_;
47  QueueHandle_t uart_event_queue_;
48  uart_config_t get_config_();
49  SemaphoreHandle_t lock_;
50 
51  bool has_peek_{false};
52  uint8_t peek_byte_;
53 };
54 
55 } // namespace uart
56 } // namespace esphome
57 
58 #endif // USE_ESP_IDF
bool read_array(uint8_t *data, size_t len) override
const float BUS
For communication buses like i2c/spi.
Definition: component.cpp:16
float get_setup_priority() const override
bool peek_byte(uint8_t *data) override
void write_array(const uint8_t *data, size_t len) override
std::string size_t len
Definition: helpers.h:293
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7