use bit_field::BitField;
use riscv::{clear, read_csr_as, set, set_clear_csr, write_csr};
#[derive(Copy, Clone, Debug)]
pub struct Vsip {
bits: usize,
}
impl Vsip {
#[inline]
pub fn bits(&self) -> usize {
self.bits
}
#[inline]
pub fn from_bits(x: usize) -> Self {
Vsip { bits: x }
}
#[inline]
pub unsafe fn write(&self) {
unsafe { _write(self.bits) };
}
#[inline]
pub fn ssip(&self) -> bool {
self.bits.get_bit(1)
}
#[inline]
pub fn set_ssip(&mut self, val: bool) {
self.bits.set_bit(1, val);
}
#[inline]
pub fn stip(&self) -> bool {
self.bits.get_bit(5)
}
#[inline]
pub fn set_stip(&mut self, val: bool) {
self.bits.set_bit(5, val);
}
#[inline]
pub fn seip(&self) -> bool {
self.bits.get_bit(9)
}
#[inline]
pub fn set_seip(&mut self, val: bool) {
self.bits.set_bit(9, val);
}
}
read_csr_as!(Vsip, 0x244);
write_csr!(0x244);
set!(0x244);
clear!(0x244);
set_clear_csr!(
, set_ssip, clear_ssip, 1 << 1);
set_clear_csr!(
, set_stip, clear_stip, 1 << 5);
set_clear_csr!(
, set_seip, clear_seip, 1 << 9);