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

UartRx's read_byte should be public #1547

Closed
nan-mu opened this issue May 9, 2024 · 0 comments · Fixed by #1548
Closed

UartRx's read_byte should be public #1547

nan-mu opened this issue May 9, 2024 · 0 comments · Fixed by #1548

Comments

@nan-mu
Copy link
Contributor

nan-mu commented May 9, 2024

At uart.rs, line 466, this function should be public:

impl<'d, T, M> UartRx<'d, T, M>
where
    T: Instance,
    M: Mode,
{
    pub fn read_byte(&mut self) -> nb::Result<u8, Error> {
        // On the ESP32-S2 we need to use PeriBus2 to read the FIFO:
        let offset = if cfg!(esp32s2) { 0x20C00000 } else { 0 };

        if T::get_rx_fifo_count() > 0 {
            let value = unsafe {
                let fifo = (T::register_block().fifo().as_ptr() as *mut u8).offset(offset)
                    as *mut crate::peripherals::generic::Reg<FIFO_SPEC>;
                (*fifo).read().rxfifo_rd_byte().bits()
            };

            Ok(value)
        } else {
            Err(nb::Error::WouldBlock)
        }
    }
}

Or you should change the document for uart.rs at line 44:

//! ### Examples
//!
//! #### Sending and Receiving Data
//!
//! ```no_run
//! // Write bytes out over the UART:
//! uart1.write_bytes("Hello, world!".as_bytes())?;
//! ```
//!
//! #### Splitting the UART into TX and RX Components
//!
//! ```no_run
//! // The UART can be split into separate Transmit and Receive components:
//! let (mut tx, rx) = uart1.split();
//!
//! // Each component can be used individually to interact with the UART:
//! tx.write_bytes(&[42u8])?;
//! let byte = rx.read_byte()?;
//! ```

just a tiny fix so I have given a pr, you can accept or fix with other change

@github-project-automation github-project-automation bot moved this to Todo in esp-rs May 9, 2024
nan-mu added a commit to nan-mu/esp-hal that referenced this issue May 9, 2024
github-merge-queue bot pushed a commit that referenced this issue May 13, 2024
* Fix for #1547

* a changelog

* fit pr request

* Add read_byte doc

* fit rustfmt
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant