#![allow(dead_code)]

#[derive(Debug, Clone)]
pub struct PinConfig1 {
    pub dacout1_address: u16,
    pub dacout2_address: u16,
    pub brake_input_config: BrakeInputConfig,
    pub direction_input_config: DirectionInputConfig,
    pub speed_input_config: SpeedInputConfig,
}

impl Default for PinConfig1 {
    fn default() -> Self {
        Self {
            dacout1_address: 0,
            dacout2_address: 0,
            brake_input_config: BrakeInputConfig::HardwarePinBrake,
            direction_input_config: DirectionInputConfig::HardwarePinDirection,
            speed_input_config: SpeedInputConfig::Analog,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum BrakeInputConfig {
    HardwarePinBrake = 0x0,
    BrakeActive = 0x1,
    BrakeDisabled = 0x2,
}

#[derive(Debug, Copy, Clone)]
pub enum DirectionInputConfig {
    HardwarePinDirection = 0x0,
    Clockwise = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum SpeedInputConfig {
    Analog = 0x0,
    Pwm = 0x1,
    I2c = 0x2,
    Frequency = 0x3,
}

#[derive(Debug, Clone)]
pub struct PinConfig2 {
    pub pin36config: Pin36Config,
    pub pin37_38config: Pin37_38Config,
    pub sleep_time: SleepTime,
    pub enable_external_watchdog: bool,
    pub external_watchdog_source: ExternalWatchdogSource,
    pub external_watchdog_fault_mode: ExternalWatchdogFaultMode,
    pub external_watchdog_frequency: ExternalWatchdogFrequency,
}

impl Default for PinConfig2 {
    fn default() -> Self {
        Self {
            pin36config: Pin36Config::Dacout2,
            pin37_38config: Pin37_38Config::Pin37Dacout1Pin38Dacout2,
            sleep_time: SleepTime::Sleep50micros,
            enable_external_watchdog: false,
            external_watchdog_source: ExternalWatchdogSource::I2c,
            external_watchdog_fault_mode: ExternalWatchdogFaultMode::ReportOnly,
            external_watchdog_frequency: ExternalWatchdogFrequency::Hertz10,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum Pin36Config {
    Dacout2 = 0x0,
    SoA = 0x1,
    SoB = 0x2,
    SoC = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum Pin37_38Config {
    Pin37Dacout1Pin38Dacout2 = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum SleepTime {
    Sleep50micros = 0x0,
    Sleep200micros = 0x1,
    Sleep50millis = 0x2,
    Sleep200millis = 0x3,
}

#[derive(Debug, Copy, Clone)]
pub enum ExternalWatchdogSource {
    I2c = 0x0,
    Gpio = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum ExternalWatchdogFaultMode {
    ReportOnly = 0x0,
    LatchHighImpedance = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum ExternalWatchdogFrequency {
    Hertz10 = 0x0,
    Hertz50 = 0x1,
    Hertz2 = 0x2,
    Hertz1 = 0x3,
}
