mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:17:23 +00:00
Address review feedback on usb_uart load_settings fix
This commit is contained in:
committed by
GitHub
parent
72270e91ac
commit
a6643517ea
@@ -122,8 +122,9 @@ void USBUartTypeCP210X::enable_channels() {
|
||||
}
|
||||
|
||||
void USBUartTypeCP210X::load_settings(USBUartChannel *channel, bool dump_config) {
|
||||
if (channel == nullptr || !channel->initialised_.load())
|
||||
if (channel == nullptr || !channel->initialised_.load()) {
|
||||
return;
|
||||
}
|
||||
|
||||
usb_host::transfer_cb_t callback = [channel](const usb_host::TransferStatus &status) {
|
||||
if (!status.success) {
|
||||
@@ -132,9 +133,11 @@ void USBUartTypeCP210X::load_settings(USBUartChannel *channel, bool dump_config)
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr uint8_t CP210X_PARITY_SHIFT = 4;
|
||||
static constexpr uint8_t CP210X_DATA_BITS_SHIFT = 8;
|
||||
uint16_t line_control = channel->stop_bits_;
|
||||
line_control |= static_cast<uint8_t>(channel->parity_) << 4;
|
||||
line_control |= channel->data_bits_ << 8;
|
||||
line_control |= static_cast<uint8_t>(channel->parity_) << CP210X_PARITY_SHIFT;
|
||||
line_control |= channel->data_bits_ << CP210X_DATA_BITS_SHIFT;
|
||||
this->control_transfer(USB_VENDOR_IFC | usb_host::USB_DIR_OUT, SET_LINE_CTL, line_control, channel->index_,
|
||||
callback);
|
||||
|
||||
|
||||
@@ -211,8 +211,9 @@ bool USBUartChannel::read_array(uint8_t *data, size_t len) {
|
||||
}
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32)
|
||||
void USBUartChannel::load_settings(bool dump_config) {
|
||||
if (this->parent_ == nullptr || !this->initialised_.load())
|
||||
if (this->parent_ == nullptr || !this->initialised_.load()) {
|
||||
return;
|
||||
}
|
||||
this->parent_->load_settings(this, dump_config);
|
||||
}
|
||||
|
||||
@@ -221,8 +222,8 @@ void USBUartChannel::load_settings() { this->load_settings(true); }
|
||||
|
||||
void USBUartComponent::setup() { USBClient::setup(); }
|
||||
void USBUartComponent::load_settings(USBUartChannel *channel, bool dump_config) {
|
||||
(void) channel;
|
||||
(void) dump_config;
|
||||
static_cast<void>(channel);
|
||||
static_cast<void>(dump_config);
|
||||
}
|
||||
void USBUartComponent::loop() {
|
||||
bool had_work = this->process_usb_events_();
|
||||
|
||||
Reference in New Issue
Block a user