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

Resolve #3182 extend RMT memory #3264

Closed
wants to merge 78 commits into from

Conversation

enelson1001
Copy link
Contributor

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 developer guidelines

Extra:

Pull Request Details 📖

Add the ability to extend RMT memory on a RMT channel

Description

Added changes to rmt.rs to allow the user to use extended RMT memory on a channel. This allows a user to have more pulse codes than the default of 64, 48 pulse codes depending upon the device used.
My uses case was to receive pulse codes from a weather station sensor that exceeded one RMT memory block of 64 (for ESP32).

Testing

I tested on an ESP32 and a ESP32S3 using the examples/embassy_rmt_rx. I also wrote my own example that would transmit and receive a 207 pulsecodes on an ESP32. I sent 207 pulsecodes from the ESP32 to a ESP32S3. The 207 pulsecodes contained 3 duplicate messages and I was able to receive 2 of the 3 message on the ESP32S3 since the ESP32S# max receive memory is 192.

@bugadani
Copy link
Contributor

We'll need some way to prevent multiple channels accidentally using the same memory blocks. I didn't see anything related in this PR, did I miss something?

@enelson1001
Copy link
Contributor Author

enelson1001 commented Mar 16, 2025

We'll need some way to prevent multiple channels accidentally using the same memory blocks. I didn't see anything related in this PR, did I miss something?

I would think we would have to add a variable to maybe new_internal that has information if a block of memory is used or available. Does this sound like a good approach?

Never mind I think I have an idea how to solve.

@enelson1001
Copy link
Contributor Author

I would like some feedback to the approach that I was thinking of using. The implementation would be the same in the configure_tx_channel. Not sure how to handle ESP32S3 for receive since it uses ch_index.

fn configure_rx_channel<'d, P: PeripheralInput, T: RxChannelInternal>(
    pin: impl Peripheral<P = P> + 'd,
    config: RxChannelConfig,
) -> Result<T, Error> {
    cfg_if::cfg_if! {
        if #[cfg(any(esp32, esp32s2))] {
            let threshold = 0b111_1111_1111_1111;
        } else {
            let threshold = 0b11_1111_1111_1111;
        }
    }

    if config.idle_threshold > threshold {
        return Err(Error::InvalidArgument);
    }

    let config_memsize = config.memsize;

    if config_memsize > NUM_CHANNELS as u8 {
        return Err(Error::InvalidMemsize);
    }

    if config_memsize > NUM_CHANNELS as u8 - T::CHANNEL {
        return Err(Error::InvalidMemsize);
    }

    // If config_memsize is greather than 1 then the user wants to use extended
    // memory for this channel
    if config_memsize > 1 {
        // If a channel's memory block is used by another channel then its memory size
        // will be set to 0. If a channel's memory block is available then its
        // memory size will be 1

        // Check to see if any the memory blocks requested in config_memsize are taken
        // (ie memsize != 1), if so throw an error
        let rmt = crate::peripherals::RMT::regs();
        for i in T::CHANNEL..T::CHANNEL + config_memsize {
            if rmt.chconf0(i as usize).read().mem_size().bits() != 1 {
                info!("RMT memory block is taken");
                return Err(Error::InvalidMemsize);
            }
        }

        // If the memory blocks are available then set the extended memory blocks size
        // to 0 to indicate they are taken. Setting the memsize for this channel will
        // be set further down in the code
        for i in T::CHANNEL + 1..T::CHANNEL + config_memsize {
            rmt.chconf0(i as usize)
                .modify(|_, w| unsafe { w.mem_size().bits(0) });
        }
    }

    crate::into_mapped_ref!(pin);
    pin.init_input(crate::gpio::Pull::None);
    T::input_signal().connect_to(pin);

    T::set_divider(config.clk_divider);
    T::set_carrier(
        config.carrier_modulation,
        config.carrier_high,
        config.carrier_low,
        config.carrier_level,
    );
    T::set_filter_threshold(config.filter_threshold);
    T::set_idle_threshold(config.idle_threshold);
    T::set_memsize(config.memsize);

    Ok(T::new())
}

yuiiio and others added 21 commits March 22, 2025 19:07
* esp32s2: psram_cache_init typo fix

broken esp32s2 psram since
cb0016a

* Add PSRAM test

* Add changelog entry

---------

Co-authored-by: Dániel Buga <[email protected]>
* feat: Update documentation links

* feat: Add documentation field to Cargo.toml
* Add failing test case

* Use pointer difference as the true FIFO count

* Take FIFO pointers into account when calculating FIFO length

* Fix grammar

* Clear RX FIFO on overflow

* Update esp-hal/src/uart.rs

Co-authored-by: Dominic Fischer <[email protected]>

* Handle overflow caught by RxFuture

* Reset the fifo after clearing the interrupt

---------

Co-authored-by: Dominic Fischer <[email protected]>
- Fixes a few links being broken after the rename in
#3049
* Fix esp-lp-hal gpio read

* Update esp-lp-hal changelog

* Fix esp-lp-hal for esp32-s2 and esp32-c6

* Add PR number #3191 to the changelog
* Correctly clear fastrd_mode when data mode is Single

* Print logs in QA test

* Port SPI timing tuning from esp-idf

* Fix ESP32 QSPI signals

* Print the reason of an Unsupported error

* Partial changelog
* Test flip-link

* Add todo

* Rebuild if linker files change

* Let espsegs show .stack

* Try to fix flip_link

* Changelog

* Make SSP configurable

* Substitute config values
* WIP

* Explain Async a bit better

* Update esp-hal/src/lib.rs

Co-authored-by: Scott Mabin <[email protected]>

* Improve consistency

* Disallow constructing driver modes

---------

Co-authored-by: Scott Mabin <[email protected]>
* Mark unstable parts of config unstable

* Unstable
* uart: docs improvement, re-shuffle and merge impl blocks

* Add a note into developer-guidelines
* and again

* examples

* fix?

* tz

* after snippet

* fmt

* clippy

* ugh

* fix

* ugh

* remove examples

* reset xtask

* Update esp-hal/CHANGELOG.md

Co-authored-by: Juraj Sadel <[email protected]>

---------

Co-authored-by: Robert Bastian <[email protected]>
Co-authored-by: Juraj Sadel <[email protected]>
* FIFO_SIZE vs CHUNK_SIZE

* I2C: ESP32/S2 workarounds

* Docs

* Fix test

* CHANGELOG.md

* Test empty writes, again

* Empty Write

* Comments

* Add TODO comment

* Use real FIFO size

* Docs

* Chunks
* feat(esp-println): Add timestamp to logging

- Introduce new `timestamp` feature to enable logging with a timestamp in millis, in the same format as the bootloader.

* Add CHANGELOG.md entry
* Pass CI=1 to lint_packages

* Move xtensa procmacros to repo root

* Fix lint issues
* Prepare linker scripts for app-desc

* Explain flash offset

* Explain `rotext_dummy`

* Test app-descriptor

* fmt

* embedded-storage
enelson1001 and others added 28 commits March 22, 2025 19:28
* esp32s2: psram_cache_init typo fix

broken esp32s2 psram since
cb0016a

* Add PSRAM test

* Add changelog entry

---------

Co-authored-by: Dániel Buga <[email protected]>
* Add failing test case

* Use pointer difference as the true FIFO count

* Take FIFO pointers into account when calculating FIFO length

* Fix grammar

* Clear RX FIFO on overflow

* Update esp-hal/src/uart.rs

Co-authored-by: Dominic Fischer <[email protected]>

* Handle overflow caught by RxFuture

* Reset the fifo after clearing the interrupt

---------

Co-authored-by: Dominic Fischer <[email protected]>
* Correctly clear fastrd_mode when data mode is Single

* Print logs in QA test

* Port SPI timing tuning from esp-idf

* Fix ESP32 QSPI signals

* Print the reason of an Unsupported error

* Partial changelog
* Test flip-link

* Add todo

* Rebuild if linker files change

* Let espsegs show .stack

* Try to fix flip_link

* Changelog

* Make SSP configurable

* Substitute config values
* uart: docs improvement, re-shuffle and merge impl blocks

* Add a note into developer-guidelines
* and again

* examples

* fix?

* tz

* after snippet

* fmt

* clippy

* ugh

* fix

* ugh

* remove examples

* reset xtask

* Update esp-hal/CHANGELOG.md

Co-authored-by: Juraj Sadel <[email protected]>

---------

Co-authored-by: Robert Bastian <[email protected]>
Co-authored-by: Juraj Sadel <[email protected]>
* FIFO_SIZE vs CHUNK_SIZE

* I2C: ESP32/S2 workarounds

* Docs

* Fix test

* CHANGELOG.md

* Test empty writes, again

* Empty Write

* Comments

* Add TODO comment

* Use real FIFO size

* Docs

* Chunks
* feat(esp-println): Add timestamp to logging

- Introduce new `timestamp` feature to enable logging with a timestamp in millis, in the same format as the bootloader.

* Add CHANGELOG.md entry
* Pass CI=1 to lint_packages

* Move xtensa procmacros to repo root

* Fix lint issues
* Prepare linker scripts for app-desc

* Explain flash offset

* Explain `rotext_dummy`

* Test app-descriptor

* fmt

* embedded-storage
This attempts to add a doctest showing how to plug a micro-second Unix
timestamp into Jiff, and then get, e.g., the weekday in a particular
locale. The example also makes use of Jiff's new `tz::get!` proc-macro
for embedding time zones into the binary for use in core-only
environments.

Ref #3185, Ref #3200
* Add degrade fns, move anyi2s and anyi2c

* Update esp-hal/CHANGELOG.md

Co-authored-by: Dominic Fischer <[email protected]>

---------

Co-authored-by: Dominic Fischer <[email protected]>
* Support "build-documentation-index --serve"

* Support `/latest` in generated docs

* `/latest` vs `/latest/`

* Update documentation field
* Disregard env setting when level is set manually

* Sort filter rules

* Changelog

* Remove no-longer-true doc line

* Fex typo
* Move OnDrop

* Abort async transfer

* Finish sentence
* i2c: make blocking impl first in docs

* uart: group write and flush together

* reviews && use address instead of addr in lp i2c in pub API
@enelson1001
Copy link
Contributor Author

my fork is completely broken will start over with new fork.

@enelson1001 enelson1001 closed this by deleting the head repository Mar 23, 2025
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.