fn i2c_sdadel_minimum() {
        i2c_timing_testcase(|i2c_clk: u32, freq: u32| {
            let (presc_reg, _, _, sdadel, _) = 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_sdadel = (sdadel 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_fall_max = match freq {
                x if x <= 100_000. => 300e-9, // Standard mode (Sm)
                x if x <= 400_000. => 300e-9, // Fast mode (Fm)
                _ => 120e-9,                  // Fast mode Plus (Fm+)
            };

            let t_af_min = 50e-9_f32; // Analog filter min 50ns. From H7 Datasheet
            let hddat_min = 0.;

            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSDADEL >= {tf + tHD;DAT(min) - tAF(min) - [(DNF + 3) x tI2CCLK]}
            let t_sdadel_minimim =
                t_fall_max + hddat_min - t_af_min - (3. * t_i2c_clk);

            println!("Target {} Hz; SDADEL {}", freq, sdadel);
            println!(
                "T SDA DELAY {:.2e} MINIMUM {:.2e}",
                t_sdadel, t_sdadel_minimim
            );
            assert!(sdadel <= 15);
            assert!(t_sdadel >= t_sdadel_minimim);
        });
    }
/// Test the SDADEL value is greater than the minimum specification
Test the SDADEL value is greater than the minimum specification
Test the SDADEL value is greater than the minimum specification
fn i2c_sdadel_minimum() {
        i2c_timing_testcase(|i2c_clk: u32, freq: u32| {
            let (presc_reg, _, _, sdadel, _) = 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_sdadel = (sdadel 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_fall_max = match freq {
                x if x <= 100_000. => 300e-9, // Standard mode (Sm)
                x if x <= 400_000. => 300e-9, // Fast mode (Fm)
                _ => 120e-9,                  // Fast mode Plus (Fm+)
            };
            let t_af_min = 50e-9_f32; // Analog filter min 50ns. From H7 Datasheet
            let hddat_min = 0.;
            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSDADEL >= {tf + tHD;DAT(min) - tAF(min) - [(DNF + 3) x tI2CCLK]}
            let t_sdadel_minimim =
                t_fall_max + hddat_min - t_af_min - (3. * t_i2c_clk);
            println!("Target {} Hz; SDADEL {}", freq, sdadel);
            println!(
                "T SDA DELAY {:.2e} MINIMUM {:.2e}",
                t_sdadel, t_sdadel_minimim
            );
            assert!(sdadel <= 15);
            assert!(t_sdadel >= t_sdadel_minimim);
        });
    }
fn i2c_sdadel_minimum ( ) { i2c_timing_testcase ( | i2c_clk : u32 , freq : u32 | { let ( presc_reg , _ , _ , sdadel , _ ) = 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_sdadel = ( sdadel 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_fall_max = match freq { x if x <= 100_000. => 300e-9 , // Standard mode (Sm) x if x <= 400_000. => 300e-9 , // Fast mode (Fm) _ => 120e-9 , // Fast mode Plus (Fm+) } ; let t_af_min = 50e-9_f32 ; // Analog filter min 50ns. From H7 Datasheet let hddat_min = 0. ; // From RM0433 Rev 7 Section 47.4.5 // // tSDADEL >= {tf + tHD;DAT(min) - tAF(min) - [(DNF + 3) x tI2CCLK]} let t_sdadel_minimim = t_fall_max + hddat_min - t_af_min - ( 3. * t_i2c_clk ) ; println ! ( " " freq sdadel ) ; println ! ( " " t_sdadel t_sdadel_minimim ) ; assert ! ( sdadel 15 ) ; assert ! ( t_sdadel t_sdadel_minimim ) ; } ) ; }
Test the SDADEL value is greater than the minimum specification
Test the SDADEL value is greater than the minimum specification