libregister: add macro for multi-bit RO fields

feature/zcu111
Brad Bondurant 2022-11-17 08:33:57 -05:00
parent c3273a6ff8
commit 70489132fb
1 changed files with 13 additions and 0 deletions

View File

@ -290,6 +290,19 @@ macro_rules! register_bits {
}
}
);
($mod_name: ident, $(#[$outer:meta])* $name: ident, $type: ty, $bit_begin: expr, $bit_end: expr, RO) => (
impl $mod_name::Read {
#[allow(unused)]
#[inline]
$(#[$outer])*
pub fn $name(&self) -> $type {
use bit_field::BitField;
self.inner.get_bits($bit_begin..=$bit_end) as $type
}
}
);
}
/// Define a multi-bit field of a register, coerced to a certain type