#![allow(dead_code)]

// This comes from the ICD
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone)]
pub struct IsdConfig {
    pub enable_isd: bool,
    pub enable_brake: bool,
    pub enable_high_impedance: bool,
    pub enable_reverse_drive: bool,
    pub enable_resynchronization: bool,
    pub enable_stationary_brake: bool,
    pub stationary_detect_threshold: Threshold,
    pub brake_mode: BrakeMode,
    pub brake_config: BrakeConfig,
    pub brake_current_threshold: Threshold,
    pub brake_time: IsdConfigTimeValue,
    pub high_impedence_time: IsdConfigTimeValue,
    pub startup_break_time: StartupBreakTime,
    pub resync_minimum_threshold: ResyncMinimumThreshold,
}

impl Default for IsdConfig {
    fn default() -> Self {
        Self {
            enable_isd: false,
            enable_brake: false,
            enable_high_impedance: false,
            enable_reverse_drive: false,
            enable_resynchronization: false,
            enable_stationary_brake: false,
            stationary_detect_threshold: Threshold::MilliVolt5,
            brake_mode: BrakeMode::LowOn,
            brake_config: BrakeConfig::BrakeTimeExit,
            brake_current_threshold: Threshold::MilliVolt5,
            brake_time: IsdConfigTimeValue::Millisecond10,
            high_impedence_time: IsdConfigTimeValue::Millisecond10,
            startup_break_time: StartupBreakTime::Millisecond1,
            resync_minimum_threshold: ResyncMinimumThreshold::Computed,
        }
    }
}

#[derive(Debug, Copy, Clone)]
pub enum Threshold {
    MilliVolt5 = 0x0,
    MilliVolt10 = 0x1,
    MilliVolt15 = 0x2,
    MilliVolt20 = 0x3,
    MilliVolt25 = 0x4,
    MilliVolt30 = 0x5,
    MilliVolt50 = 0x6,
    MilliVolt100 = 0x7,
}

#[derive(Debug, Copy, Clone)]
pub enum BrakeMode {
    LowOn = 0x0,
    HighOn = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum BrakeConfig {
    BrakeTimeExit = 0x0,
    CurrentThresholdExit = 0x1,
}

#[derive(Debug, Copy, Clone)]
pub enum IsdConfigTimeValue {
    Millisecond10 = 0x0,
    Millisecond50 = 0x1,
    Millisecond100 = 0x2,
    Millisecond200 = 0x3,
    Millisecond300 = 0x4,
    Millisecond400 = 0x5,
    Millisecond500 = 0x6,
    Millisecond750 = 0x7,
    Second1 = 0x8,
    Second2 = 0x9,
    Second3 = 0xA,
    Second4 = 0xB,
    Second5 = 0xC,
    Second7_5 = 0xD,
    Second10 = 0xE,
    Second15 = 0xF,
}

#[derive(Debug, Copy, Clone)]
pub enum StartupBreakTime {
    Millisecond1 = 0x0,
    Millisecond10 = 0x1,
    Millisecond25 = 0x2,
    Millisecond50 = 0x3,
    Millisecond100 = 0x4,
    Millisecond250 = 0x5,
    Millisecond500 = 0x6,
    Millisecond1000 = 0x7,
}

#[derive(Debug, Copy, Clone)]
pub enum ResyncMinimumThreshold {
    Computed = 0x0,
    MilliVolt300 = 0x1,
    MilliVolt400 = 0x2,
    MilliVolt500 = 0x3,
    MilliVolt600 = 0x4,
    MilliVolt800 = 0x5,
    MilliVolt1000 = 0x6,
    MilliVolt1250 = 0x7,
}
