Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Oct 11, 2025

Pull Request Overview

Right now instantiating chips in boards' main.rs is straightforward for two reasons:

  1. Most chips do not use DMA
  2. Chips that use do DMA often use static mut buffers declared within the chip crate

However, if we look at what it would take to remove static mut buffers from the nrf52 crate (which does use DMA), we would need to pass in at least 4 buffers (maybe 5) buffers into the chip. Those need to be static_initd in main.rs. That type of initialization complexity is what we added components for; components enable encapsulating the setup to a single file.

I think we can introduce components into chips. Note, chips do not use the components. They simply provide them for the boards to use.

Testing Strategy

todo

TODO or Help Wanted

What do you think? I think this nicely decouples default peripherals from the chip. Chips could have any number of default peripheral combinations, and then the associate component to instantiate them.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

@github-actions github-actions bot added the nrf label Oct 11, 2025
@hudson-ayers
Copy link
Contributor

Won't this prevent us from ever adding forbid(unsafe) to chip crates?

@bradjc
Copy link
Contributor Author

bradjc commented Oct 12, 2025

Won't this prevent us from ever adding forbid(unsafe) to chip crates?

Components, when done well, don't use unsafe. Another goal we have is forbid unsafe in the board components crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants