forked from M-Labs/zynq-rs
libregister: add macro for multi-bit RO fields
This commit is contained in:
parent
c3273a6ff8
commit
70489132fb
|
@ -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
|
/// Define a multi-bit field of a register, coerced to a certain type
|
||||||
|
|
Loading…
Reference in New Issue