[][src]Macro ruspiro_register::define_register

macro_rules! define_register {
    ($name:ident : ReadWrite<$t:ty> @ $addr:expr) => { ... };
    ($name:ident : ReadWrite<$t:ty> @ $addr:expr => [ $($field:ident OFFSET($offset:expr) $(BITS($bits:expr))?),* ]) => { ... };
    ($name:ident : ReadOnly<$t:ty> @ $addr:expr) => { ... };
    ($name:ident : ReadOnly<$t:ty> @ $addr:expr => [ $($field:ident OFFSET($offset:expr) $(BITS($bits:expr))?),* ]) => { ... };
    ($name:ident : WriteOnly<$t:ty> @ $addr:expr) => { ... };
    ($name:ident : WriteOnly<$t:ty> @ $addr:expr => [ $($field:ident OFFSET($offset:expr) $(BITS($bits:expr))?),* ]) => { ... };
}
👎 Deprecated since 0.3.0:

this macro definition syntax is deprectated to align the mmio syntax with the system register syntax. Please use define_mmio_register instead

Examples

This example is not tested
define_register!( GPFSEL0: ReadWrite<u32> @ 0x3F20_0000 );

let _ = GPFSEL0::Register.get();
This example is not tested
const GPIO_BASE:u32 = 0x3F00_0000;

define_register!( GPFSEL1: ReadWrite<u32> @ GPIO_BASE + 0x04 );

let _ = GPFSEL1::Register.get();

To pass a more specific definition of the fields the register represents they could be added in the [] of the definition like so:

This example is not tested

define_register!( GPFSEL2: ReadWrite<u32> @ 0x3F20_0000 => [
    FSEL20 OFFSET(0) BITS(3),
    FSEL21 OFFSET(3) BITS(3),
    FSEL22 OFFSET(6) BITS(3)
] );

GPFSEL2::Register.modify(GPFSEL2::FSEL21, 0b001);