Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LpUart::new() set tx_idle_num to 0 twice #2860

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zpg6
Copy link

@zpg6 zpg6 commented Dec 21, 2024

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

In the LpUart::new() function in esp-hal/src/uart.rs

// 🟨 FIRST TIME:
// Set tx idle
me.uart
    .idle_conf()
    .modify(|_, w| unsafe { w.tx_idle_num().bits(0) });

// Disable hw-flow control
me.uart
    .hwfc_conf()
    .modify(|_, w| w.rx_flow_en().clear_bit());

// Get source clock frequency
// default == SOC_MOD_CLK_RTC_FAST == 2

// LP_CLKRST.lpperi.lp_uart_clk_sel = 0;
unsafe { LP_CLKRST::steal() }
    .lpperi()
    .modify(|_, w| w.lp_uart_clk_sel().clear_bit());

// Override protocol parameters from the configuration
// uart_hal_set_baudrate(&hal, cfg->uart_proto_cfg.baud_rate, sclk_freq);
me.change_baud_internal(config.baudrate, config.clock_source);
// uart_hal_set_parity(&hal, cfg->uart_proto_cfg.parity);
me.change_parity(config.parity);
// uart_hal_set_data_bit_num(&hal, cfg->uart_proto_cfg.data_bits);
me.change_data_bits(config.data_bits);
// uart_hal_set_stop_bits(&hal, cfg->uart_proto_cfg.stop_bits);
me.change_stop_bits(config.stop_bits);

// 🟨 SECOND TIME:
// uart_hal_set_tx_idle_num(&hal, LP_UART_TX_IDLE_NUM_DEFAULT);
me.change_tx_idle(0); // LP_UART_TX_IDLE_NUM_DEFAULT == 0

I removed 🟨 FIRST TIME, as I do not see any impacts of leaving tx_idle_num as default (256) until it is called a few lines later.

Testing

Ongoing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant