You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 9, 2018. It is now read-only.
Currently, register::GPIOA and bb::gpio::GPIOA appear to be unrelated but they actually alias the same physical memory. This should be reflected in the API: Accessing register::GPIOA using its bitband region bb::gpio::GPIOA should freeze the former struct.
Here's one way to do that:
mod bb {mod gpio {pubstructBlock{pubcrl:[u32;32],// ...}}}mod gpio {pubstructBlock{pubcrl:u32,}// Just to have different types for GPIOA, GPIOB, etcpubstructA{block: gpio::Block,// ...}// NOTE: Fake subtyping -- with this we can use GPIOA as a gpio::Block// Do the same with DerefMutimplDerefforA{typeTarget = Block;fnderef(&self) -> &Block{&self.block}}}traitBitBand{typeView;fnbb(&self) -> &Self::View;}implBitBandfor gpio::A{typeView = bb::gpio::Block;fnbb(&self) -> &bb::gpio::Block{&__BB_GPIOA
}}extern{static __GPIOA: gpio::A;static __BB_GPIOA: bb::gpio::Block;}
The gpio::A newtype is to make GPIOA and GPIOB have different types so the .bb() method call can be performed without arithmetic by directly returning the start address of the bitband region.
Currently,
register::GPIOAandbb::gpio::GPIOAappear to be unrelated but they actually alias the same physical memory. This should be reflected in the API: Accessingregister::GPIOAusing its bitband regionbb::gpio::GPIOAshould freeze the former struct.Here's one way to do that:
The
gpio::Anewtype is to makeGPIOAandGPIOBhave different types so the.bb()method call can be performed without arithmetic by directly returning the start address of the bitband region.