fn i2c_scldel_minimum() {
        i2c_timing_testcase(|i2c_clk: u32, freq: u32| {
            let (presc_reg, _, _, _, scldel) = i2c_timing!(i2c_clk, freq);

            // Timing parameters
            let presc = (presc_reg + 1) as f32;
            let t_i2c_clk = 1. / (i2c_clk as f32);
            let freq = freq as f32;
            let t_scldel = (scldel as f32) * presc * t_i2c_clk;

            // From I2C Specification Table 10
            //
            // UM10204 rev 6.: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
            let t_rise_max = match freq {
                x if x <= 100_000. => 1000e-9, // Standard mode (Sm)
                x if x <= 400_000. => 300e-9,  // Fast mode (Fm)
                _ => 120e-9,                   // Fast mode Plus (Fm+)
            };
            let t_sudat_min = match freq {
                x if x <= 100_000. => 250e-9, // Standard mode (Sm)
                x if x <= 400_000. => 100e-9, // Fast mode (Fm)
                _ => 50e-9,                   // Fast mode Plus (Fm+)
            };

            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSCLDEL >= tr + tSU;DAT(min)
            let t_scldel_minimum = t_rise_max + t_sudat_min;

            println!("Target {} Hz; SCLDEL {}", freq, scldel);
            println!(
                "T SCL DELAY {:.2e} MINIMUM {:.2e}",
                t_scldel, t_scldel_minimum
            );
            assert!(scldel <= 15);
            assert!(t_scldel >= t_scldel_minimum);
        });
    }
/// Test the SCLDEL value is greater than the minimum specification
Test the SCLDEL value is greater than the minimum specification
Test the SCLDEL value is greater than the minimum specification
fn i2c_scldel_minimum() {
        i2c_timing_testcase(|i2c_clk: u32, freq: u32| {
            let (presc_reg, _, _, _, scldel) = i2c_timing!(i2c_clk, freq);
            // Timing parameters
            let presc = (presc_reg + 1) as f32;
            let t_i2c_clk = 1. / (i2c_clk as f32);
            let freq = freq as f32;
            let t_scldel = (scldel as f32) * presc * t_i2c_clk;
            // From I2C Specification Table 10
            //
            // UM10204 rev 6.: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
            let t_rise_max = match freq {
                x if x <= 100_000. => 1000e-9, // Standard mode (Sm)
                x if x <= 400_000. => 300e-9,  // Fast mode (Fm)
                _ => 120e-9,                   // Fast mode Plus (Fm+)
            };
            let t_sudat_min = match freq {
                x if x <= 100_000. => 250e-9, // Standard mode (Sm)
                x if x <= 400_000. => 100e-9, // Fast mode (Fm)
                _ => 50e-9,                   // Fast mode Plus (Fm+)
            };
            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSCLDEL >= tr + tSU;DAT(min)
            let t_scldel_minimum = t_rise_max + t_sudat_min;
            println!("Target {} Hz; SCLDEL {}", freq, scldel);
            println!(
                "T SCL DELAY {:.2e} MINIMUM {:.2e}",
                t_scldel, t_scldel_minimum
            );
            assert!(scldel <= 15);
            assert!(t_scldel >= t_scldel_minimum);
        });
    }
fn i2c_scldel_minimum ( ) { i2c_timing_testcase ( | i2c_clk : u32 , freq : u32 | { let ( presc_reg , _ , _ , _ , scldel ) = i2c_timing ! ( i2c_clk freq ) ; // Timing parameters let presc = ( presc_reg + 1 ) as f32 ; let t_i2c_clk = 1. / ( i2c_clk as f32 ) ; let freq = freq as f32 ; let t_scldel = ( scldel as f32 ) * presc * t_i2c_clk ; // From I2C Specification Table 10 // // UM10204 rev 6.: https://www.nxp.com/docs/en/user-guide/UM10204.pdf let t_rise_max = match freq { x if x <= 100_000. => 1000e-9 , // Standard mode (Sm) x if x <= 400_000. => 300e-9 , // Fast mode (Fm) _ => 120e-9 , // Fast mode Plus (Fm+) } ; let t_sudat_min = match freq { x if x <= 100_000. => 250e-9 , // Standard mode (Sm) x if x <= 400_000. => 100e-9 , // Fast mode (Fm) _ => 50e-9 , // Fast mode Plus (Fm+) } ; // From RM0433 Rev 7 Section 47.4.5 // // tSCLDEL >= tr + tSU;DAT(min) let t_scldel_minimum = t_rise_max + t_sudat_min ; println ! ( " " freq scldel ) ; println ! ( " " t_scldel t_scldel_minimum ) ; assert ! ( scldel 15 ) ; assert ! ( t_scldel t_scldel_minimum ) ; } ) ; }
Test the SCLDEL value is greater than the minimum specification
Test the SCLDEL value is greater than the minimum specification