ESPHome  2024.11.0
logger_rp2040.cpp
Go to the documentation of this file.
1 #ifdef USE_RP2040
2 #include "logger.h"
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace logger {
7 
8 static const char *const TAG = "logger";
9 
10 void Logger::pre_setup() {
11  if (this->baud_rate_ > 0) {
12  switch (this->uart_) {
14  this->hw_serial_ = &Serial1;
15  Serial1.begin(this->baud_rate_);
16  break;
18  this->hw_serial_ = &Serial2;
19  Serial2.begin(this->baud_rate_);
20  break;
22  this->hw_serial_ = &Serial;
23  Serial.begin(this->baud_rate_);
24  break;
25  }
26  }
27  global_logger = this;
28  ESP_LOGI(TAG, "Log initialized");
29 }
30 
31 void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
32 
33 const char *const UART_SELECTIONS[] = {"UART0", "UART1", "USB_CDC"};
34 
35 const char *Logger::get_uart_selection_() { return UART_SELECTIONS[this->uart_]; }
36 
37 } // namespace logger
38 } // namespace esphome
39 #endif // USE_RP2040
Logger * global_logger
Definition: logger.cpp:198
const char * get_uart_selection_()
UARTSelection uart_
Definition: logger.h:151
void pre_setup()
Set up this component.
const char *const UART_SELECTIONS[]
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void write_msg_(const char *msg)