#![allow(dead_code)]

#[derive(Debug, Clone)]
pub struct DeviceConfig {
    // Max of 0x7FFF
    pub max_frequency: u16,
    pub stl_enable: bool,
    pub ssm_enable: bool,
    pub device_mode: DeviceMode,
    pub pwm_range_select: PwmRangeSelect,
    pub clock_source: ClockSource,
    pub external_clock_enable: bool,
    pub external_clock_frequency: ExternalClockFrequency,
}

impl Default for DeviceConfig {
    fn default() -> Self {
        Self {
            max_frequency: 0,
            stl_enable: false,
            ssm_enable: false,
            device_mode: DeviceMode::Standby,
            pwm_range_select: PwmRangeSelect::Hertz325To95kHz,
            clock_source: ClockSource::InternalOscillator,
            external_clock_enable: false,
            external_clock_frequency: ExternalClockFrequency::KHertz8,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum DeviceMode {
    Standby = 0x0,
    Sleep = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum PwmRangeSelect {
    Hertz325To95kHz = 0x0,
    Hertz10To325Hz = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum ClockSource {
    InternalOscillator = 0x0,
    ExternalClock = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum ExternalClockFrequency {
    KHertz8 = 0x0,
    KHertz16 = 0x1,
    KHertz32 = 0x2,
    KHertz64 = 0x3,
    KHertz128 = 0x4,
    KHertz256 = 0x5,
    KHertz512 = 0x6,
    KHertz1024 = 0x7,
}
