Skip to content

inner() for more peripherals #232

Open
@mattico

Description

@mattico

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions