#[derive(Copy, Clone, Debug)]
pub enum ClkOut {
Frequency32_768Hz = 0x0,
Frequency16_384Hz = 0x1,
Frequency8_192Hz = 0x2,
Frequency4_096Hz = 0x3,
Frequency1_024Hz = 0x4,
Frequency32Hz = 0x5,
Frequency1Hz = 0x6,
Frequency0Hz = 0x7,
}
#[derive(Copy, Clone, Debug)]
pub enum CorrectionMode {
Fast = 0x1,
Slow = 0x0,
}
#[derive(Copy, Clone, Debug)]
pub enum PowerManagement {
SwitchOverStandardOnLowDetectionOn = 0x0,
SwitchOverDirectOnLowDetectionOn = 0x1,
SwitchOverOffLowDetectionOn = 0x2,
SwitchOverStandardOnLowDetectionOff = 0x4,
SwitchOverDirectOnLowDetectionOff = 0x5,
SwitchOverOffLowDetectionOff = 0x7,
}
impl TryFrom<u8> for PowerManagement {
type Error = ();
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0x0 => Ok(PowerManagement::SwitchOverStandardOnLowDetectionOn),
0x1 => Ok(PowerManagement::SwitchOverDirectOnLowDetectionOn),
0x2 => Ok(PowerManagement::SwitchOverOffLowDetectionOn),
0x4 => Ok(PowerManagement::SwitchOverStandardOnLowDetectionOff),
0x5 => Ok(PowerManagement::SwitchOverDirectOnLowDetectionOff),
0x7 => Ok(PowerManagement::SwitchOverOffLowDetectionOff),
_ => Err(()),
}
}
}
#[derive(Copy, Clone, Debug)]
pub enum TimerSourceClock {
Frequency4096Hz = 0x0,
Frequency64Hz = 0x1,
Frequency1Hz = 0x2,
Frequency1_60Hz = 0x3,
Frequency1_3600Hz = 0x4,
}
#[derive(Copy, Clone, Debug)]
pub enum LowPulseWidth {
Width46_875ms = 0x0,
Width62_500ms = 0x1,
Width78_125ms = 0x2,
Width93_750ms = 0x3,
Width125ms = 0x4,
Width156_250ms = 0x5,
Width187_500ms = 0x6,
Width218_750ms = 0x7,
}
#[derive(Debug)]
pub struct Pcf8523T {}
#[derive(Debug)]
pub struct Pcf8523TK {}
#[derive(Debug)]
pub struct Pcf8523TS {}
#[derive(Debug)]
pub struct Pcf8523U {}
pub trait Variant {}
impl Variant for Pcf8523T {}
impl Variant for Pcf8523TK {}
impl Variant for Pcf8523TS {}
impl Variant for Pcf8523U {}
pub trait Int2Pin {}
impl Int2Pin for Pcf8523TS {}
impl Int2Pin for Pcf8523U {}
#[derive(Copy, Clone, Debug)]
pub enum TimerInterruptMode {
PermanentlyActive,
Pulsed,
}
impl From<TimerInterruptMode> for u8 {
fn from(value: TimerInterruptMode) -> Self {
match value {
TimerInterruptMode::PermanentlyActive => 0x0,
TimerInterruptMode::Pulsed => 0x1,
}
}
}
#[derive(Copy, Clone, Debug)]
pub enum TimerBInterruptMode {
PermanentlyActive,
Pulsed(LowPulseWidth),
}
impl From<TimerBInterruptMode> for u8 {
fn from(value: TimerBInterruptMode) -> Self {
match value {
TimerBInterruptMode::PermanentlyActive => 0x0,
TimerBInterruptMode::Pulsed(_) => 0x1,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum TimerMode {
Countdown,
Watchdog,
}
impl From<TimerMode> for u8 {
fn from(value: TimerMode) -> Self {
match value {
TimerMode::Countdown => 0x1,
TimerMode::Watchdog => 0x2,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct TimerA {
pub countdown: u8,
pub interrupt_mode: TimerInterruptMode,
pub mode: TimerMode,
pub source_clock: TimerSourceClock,
}
impl TimerA {
pub fn new(
countdown: u8,
interrupt_mode: TimerInterruptMode,
mode: TimerMode,
source_clock: TimerSourceClock,
) -> Self {
Self {
countdown,
interrupt_mode,
mode,
source_clock,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct TimerB {
pub countdown: u8,
pub interrupt_mode: TimerBInterruptMode,
pub source_clock: TimerSourceClock,
}
impl TimerB {
pub fn new(
countdown: u8,
interrupt_mode: TimerBInterruptMode,
source_clock: TimerSourceClock,
) -> Self {
Self {
countdown,
interrupt_mode,
source_clock,
}
}
}