ESP IDF support.

This commit is contained in:
Your Name
2023-02-13 21:12:44 +01:00
parent aafaf474d3
commit f2097c76af
16 changed files with 151 additions and 96 deletions

View File

@@ -9,7 +9,6 @@ namespace uart {
class truma_ESP32ArduinoUARTComponent : public ESP32ArduinoUARTComponent {
public:
bool is_hw_serial() { return true; }
HardwareSerial *get_hw_serial() { return this->hw_serial_; }
uint8_t get_hw_serial_number() { return this->number_; }
};

View File

@@ -9,8 +9,9 @@ namespace uart {
class truma_IDFUARTComponent : public IDFUARTComponent {
public:
bool is_hw_serial() { return true; }
uint8_t get_hw_serial_number() { return this->uart_num_; }
// `QueueHandle_t uart_event_queue_;` is also added to base class.
QueueHandle_t *get_uart_event_queue() { return &this->uart_event_queue_; }
};
} // namespace uart

View File

@@ -79,7 +79,11 @@ void IDFUARTComponent::setup() {
return;
}
err = uart_driver_install(this->uart_num_, this->rx_buffer_size_, 0, 0, nullptr, 0);
err = uart_driver_install(this->uart_num_, this->rx_buffer_size_,
0, // UART TX ring buffer size.
// If set to zero, driver will not use TX buffer, TX function will block task until all
// data have been sent out.
20, &(this->uart_event_queue_), 0);
if (err != ESP_OK) {
ESP_LOGW(TAG, "uart_driver_install failed: %s", esp_err_to_name(err));
this->mark_failed();

View File

@@ -26,6 +26,7 @@ class IDFUARTComponent : public UARTComponent, public Component {
protected:
void check_logger_conflict() override;
uart_port_t uart_num_;
QueueHandle_t uart_event_queue_;
uart_config_t get_config_();
SemaphoreHandle_t lock_;