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

Allow using #[cfg(...)] attributes on register fields #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeandudey
Copy link

@jeandudey jeandudey commented Jul 21, 2021

Small non-breaking change to the reg! macro. It now allows the usage of #[cfg(...)] attributes on register fields. This is particularly useful for drone-os/drone-cortexm#5 as it allows to restrict the STKALIGN field to a read-only field on Cortex-M7 CPUs.

Also, I've got another usage for this, adding the IC and DC fields to SCB_CCR which is present on some Cortex-M7 (optionally).

For example:

reg! {
    /// Configuration and control register.
    pub SCB CCR => {
        address => 0xE000_ED14;
        size => 0x20;
        reset => 0x0000_0200;
        traits => { RReg WReg };
        fields => {
            #[cfg(not(cortexm_core = "cortexm7_r0p1"))]
            /// Force exception stacking start in double word aligned address.
            STKALIGN => { offset => 9; width => 1; traits => { RRRegField WWRegField } }
            #[cfg(cortexm_core = "cortexm7_r0p1")]
            /// Force exception stacking start in double word aligned address.
            STKALIGN => { ... }
            ...
        };
}

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 this pull request may close these issues.

None yet

1 participant