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

inner() for more peripherals #232

Open
mattico opened this issue Jul 9, 2021 · 0 comments · May be fixed by #306
Open

inner() for more peripherals #232

mattico opened this issue Jul 9, 2021 · 0 comments · May be fixed by #306

Comments

@mattico
Copy link
Contributor

mattico commented Jul 9, 2021

The Spi peripheral has Spi::inner() which is very useful for doing things that the HAL doesn't support yet. It's nicer, safer, and more discoverable than using unsafe { &*pac::UART8::ptr() }. We should add it to more peripherals, possibly all of them.

Open Questions

  1. When should we have &mut? The RegisterBlock's Regs don't need &mut, even for register writes. Traits that RegisterBlocks implement like TargetAddress don't need &mut either. However, we may want to use &mut to indicate that operations may semantically modify the peripheral, even though it is not required for memory safety. The HAL APIs generally use &mut self as such to help keep things sane. We could keep both inner() and inner_mut() and document that inner_mut() is useful to get the compiler to ensure exclusive access. We could only have inner_mut() to be on the safe side. I'm leaning towards keeping both.
  2. Which peripherals inner() functions should be unsafe. The DMA peripherals are obvious since they can be used to write to arbitrary memory. Are there any others?
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 a pull request may close this issue.

1 participant