Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yuriishutkin
Copy link
Contributor

Offsets and register file size could be defined as a constant expression like (AUX_OFFSET + 0x20).

test_fields! macro will fail for such structs as offsets go directly to concat! macro which accepts only literals.

To avoid this failure, stringify the offset and size first.

Example:

const BAR_OFFSET: usize = 256;
register_structs! {
    UartRegisters {
        (0x00 => foo: ReadWrite<u32>),
        (0x04 => _reserved),
        ((BAR_OFFSET) => bar: ReadWrite<u32>),
        ((BAR_OFFSET+0x04) => @END),
    }
}

  • Pre-Push checks all passed!

Offsets and register file size could be defined as a
constant expression like (AUX_OFFSET + 0x20).

test_fields! macro will fail for such structs as offsets go
directly to concat! macro which accepts only literals.

To avoid this failure, stringify the offset and size first.

Example:
const BAR_OFFSET: usize = 256;
register_structs! {
    UartRegisters {
        (0x00 => foo: ReadWrite<u32>),
        (0x04 => _reserved),
        ((BAR_OFFSET) => bar: ReadWrite<u32>),
        ((BAR_OFFSET+0x04) => @EnD),
    }
}
@github-actions github-actions bot added the tock-libraries This affects libraries supported by the Tock project label Mar 5, 2024
@brghena brghena added this pull request to the merge queue Mar 6, 2024
@brghena
Copy link
Contributor

brghena commented Mar 6, 2024

@yuriishutkin Thanks for the improvement!

I'm not sure how you're using Tock registers. If it's in Tock, you should be good after this merges. If it's external to Tock and you need an update to the tock-registers crate, let us know.

Merged via the queue into tock:master with commit a510ac0 Mar 6, 2024
@lschuermann lschuermann mentioned this pull request Jun 27, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tock-libraries This affects libraries supported by the Tock project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants