use kernel::utilities::registers::interfaces::Writeable;
use kernel::utilities::registers::{register_bitfields, ReadWrite};
use kernel::utilities::StaticRef;
#[repr(C)]
pub struct RtcRegisters {
rtccfg: ReadWrite<u32, rtccfg::Register>,
_reserved1: [u8; 4],
rtclo: ReadWrite<u32, rtclo::Register>,
rtchi: ReadWrite<u32>,
rtcs: ReadWrite<u32>,
_reserved2: [u8; 12],
rtccmp: ReadWrite<u32, rtccmp::Register>,
}
register_bitfields![u32,
rtccfg [
cmpip OFFSET(28) NUMBITS(1) [],
enalways OFFSET(12) NUMBITS(1) [],
scale OFFSET(0) NUMBITS(4) []
],
rtclo [
rtclo OFFSET(0) NUMBITS(32) []
],
rtchi [
rtchi OFFSET(0) NUMBITS(16) []
],
rtccmp [
rtccmp OFFSET(0) NUMBITS(32) []
]
];
pub struct Rtc {
registers: StaticRef<RtcRegisters>,
}
impl Rtc {
pub const fn new(base: StaticRef<RtcRegisters>) -> Rtc {
Rtc { registers: base }
}
pub fn disable(&self) {
let regs = self.registers;
regs.rtccfg.write(rtccfg::enalways::CLEAR);
regs.rtccmp.set(0xFFFF_FFFF);
}
}