mirror of
https://github.com/esphome/esphome.git
synced 2025-04-03 09:20:29 +01:00
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
40 lines
991 B
C++
40 lines
991 B
C++
#ifdef USE_RP2040
|
|
#include "logger.h"
|
|
#include "esphome/core/log.h"
|
|
|
|
namespace esphome {
|
|
namespace logger {
|
|
|
|
static const char *const TAG = "logger";
|
|
|
|
void Logger::pre_setup() {
|
|
if (this->baud_rate_ > 0) {
|
|
switch (this->uart_) {
|
|
case UART_SELECTION_UART0:
|
|
this->hw_serial_ = &Serial1;
|
|
Serial1.begin(this->baud_rate_);
|
|
break;
|
|
case UART_SELECTION_UART1:
|
|
this->hw_serial_ = &Serial2;
|
|
Serial2.begin(this->baud_rate_);
|
|
break;
|
|
case UART_SELECTION_USB_CDC:
|
|
this->hw_serial_ = &Serial;
|
|
Serial.begin(this->baud_rate_);
|
|
break;
|
|
}
|
|
}
|
|
global_logger = this;
|
|
ESP_LOGI(TAG, "Log initialized");
|
|
}
|
|
|
|
void HOT Logger::write_msg_(const char *msg) { this->hw_serial_->println(msg); }
|
|
|
|
const char *const UART_SELECTIONS[] = {"UART0", "UART1", "USB_CDC"};
|
|
|
|
const char *Logger::get_uart_selection_() { return UART_SELECTIONS[this->uart_]; }
|
|
|
|
} // namespace logger
|
|
} // namespace esphome
|
|
#endif // USE_RP2040
|