[del] tock-registers: Implement mask() accessor for Field

This commit is contained in:
Berkus Decker 2020-11-22 04:56:08 +02:00
parent b2c99f52c7
commit 0cf8a88f12
1 changed files with 5 additions and 0 deletions

View File

@ -514,6 +514,11 @@ pub struct Field<T: IntLike, R: RegisterLongName> {
}
impl<T: IntLike, R: RegisterLongName> Field<T, R> {
/// Get the raw bitmask used by this Field.
pub fn mask(&self) -> T {
(self.mask as T) << self.shift
}
#[inline]
pub fn read(self, val: T) -> T {
(val & (self.mask << self.shift)) >> self.shift