Refactoring: use get_bit() instead of shifts
This commit is contained in:
parent
ab15a6a8c7
commit
b665adeb95
|
@ -1,5 +1,7 @@
|
||||||
//! mie register
|
//! mie register
|
||||||
|
|
||||||
|
use bit_field::BitField;
|
||||||
|
|
||||||
/// mie register
|
/// mie register
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Mie {
|
pub struct Mie {
|
||||||
|
@ -16,55 +18,55 @@ impl Mie {
|
||||||
/// User Software Interrupt Enable
|
/// User Software Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn usoft(&self) -> bool {
|
pub fn usoft(&self) -> bool {
|
||||||
self.bits & (1 << 0) == 1 << 0
|
self.bits.get_bit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor Software Interrupt Enable
|
/// Supervisor Software Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ssoft(&self) -> bool {
|
pub fn ssoft(&self) -> bool {
|
||||||
self.bits & (1 << 1) == 1 << 1
|
self.bits.get_bit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine Software Interrupt Enable
|
/// Machine Software Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn msoft(&self) -> bool {
|
pub fn msoft(&self) -> bool {
|
||||||
self.bits & (1 << 3) == 1 << 3
|
self.bits.get_bit(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User Timer Interrupt Enable
|
/// User Timer Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn utimer(&self) -> bool {
|
pub fn utimer(&self) -> bool {
|
||||||
self.bits & (1 << 4) == 1 << 4
|
self.bits.get_bit(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor Timer Interrupt Enable
|
/// Supervisor Timer Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn stimer(&self) -> bool {
|
pub fn stimer(&self) -> bool {
|
||||||
self.bits & (1 << 5) == 1 << 5
|
self.bits.get_bit(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine Timer Interrupt Enable
|
/// Machine Timer Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mtimer(&self) -> bool {
|
pub fn mtimer(&self) -> bool {
|
||||||
self.bits & (1 << 7) == 1 << 7
|
self.bits.get_bit(7)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User External Interrupt Enable
|
/// User External Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn uext(&self) -> bool {
|
pub fn uext(&self) -> bool {
|
||||||
self.bits & (1 << 8) == 1 << 8
|
self.bits.get_bit(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor External Interrupt Enable
|
/// Supervisor External Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sext(&self) -> bool {
|
pub fn sext(&self) -> bool {
|
||||||
self.bits & (1 << 9) == 1 << 9
|
self.bits.get_bit(9)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine External Interrupt Enable
|
/// Machine External Interrupt Enable
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mext(&self) -> bool {
|
pub fn mext(&self) -> bool {
|
||||||
self.bits & (1 << 11) == 1 << 11
|
self.bits.get_bit(11)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! mip register
|
//! mip register
|
||||||
|
|
||||||
|
use bit_field::BitField;
|
||||||
|
|
||||||
/// mip register
|
/// mip register
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Mip {
|
pub struct Mip {
|
||||||
|
@ -16,55 +18,55 @@ impl Mip {
|
||||||
/// User Software Interrupt Pending
|
/// User Software Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn usoft(&self) -> bool {
|
pub fn usoft(&self) -> bool {
|
||||||
self.bits & (1 << 0) == 1 << 0
|
self.bits.get_bit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor Software Interrupt Pending
|
/// Supervisor Software Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ssoft(&self) -> bool {
|
pub fn ssoft(&self) -> bool {
|
||||||
self.bits & (1 << 1) == 1 << 1
|
self.bits.get_bit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine Software Interrupt Pending
|
/// Machine Software Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn msoft(&self) -> bool {
|
pub fn msoft(&self) -> bool {
|
||||||
self.bits & (1 << 3) == 1 << 3
|
self.bits.get_bit(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User Timer Interrupt Pending
|
/// User Timer Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn utimer(&self) -> bool {
|
pub fn utimer(&self) -> bool {
|
||||||
self.bits & (1 << 4) == 1 << 4
|
self.bits.get_bit(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor Timer Interrupt Pending
|
/// Supervisor Timer Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn stimer(&self) -> bool {
|
pub fn stimer(&self) -> bool {
|
||||||
self.bits & (1 << 5) == 1 << 5
|
self.bits.get_bit(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine Timer Interrupt Pending
|
/// Machine Timer Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mtimer(&self) -> bool {
|
pub fn mtimer(&self) -> bool {
|
||||||
self.bits & (1 << 7) == 1 << 7
|
self.bits.get_bit(7)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User External Interrupt Pending
|
/// User External Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn uext(&self) -> bool {
|
pub fn uext(&self) -> bool {
|
||||||
self.bits & (1 << 8) == 1 << 8
|
self.bits.get_bit(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Supervisor External Interrupt Pending
|
/// Supervisor External Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sext(&self) -> bool {
|
pub fn sext(&self) -> bool {
|
||||||
self.bits & (1 << 9) == 1 << 9
|
self.bits.get_bit(9)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Machine External Interrupt Pending
|
/// Machine External Interrupt Pending
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mext(&self) -> bool {
|
pub fn mext(&self) -> bool {
|
||||||
self.bits & (1 << 11) == 1 << 11
|
self.bits.get_bit(11)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue