pub struct Instance<T, const N: u8> { /* private fields */ }Expand description
An owned peripheral of type T, instance N.
Fabricating an Instance is always unsafe. An owner of an
Instance may assume that
- the underlying pointer points to a static register block of type 
T. - the instance number 
Nproperly describes the peripheral instance. - they own all registers pointed at by 
T. 
Owners use this guarantee to safely access the peripheral registers. However, nothing guarantees any of these except for your diligence.
Constructing an Instance is zero cost. Additionally, Instance is transparent
and amenable to null-pointer optimizations.
See the package-level documentation for more information on fabricating instances.
§Safety of new().
By calling new(), you claim
ptrpoints to static memory that can be described by a typeT.- The instance number 
Ncorrectly describesptr. - You are becoming the sole owner of this instance.
 
§Safety of instance()
The various instance() methods handle safety concerns 1 and 2 from new().
By their construction, each instance() implementation provides a pointer to valid
peripheral memory, and associates the correct N with that pointer. Therefore,
you’re only responsible for ensuring safety concern 3 from new().