fn i2c_sdadel_maximum() {
        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;

            let t_hddat_max = match freq {
                x if x <= 100_000. => 3.45e-6, // Standard mode (Sm)
                x if x <= 400_000. => 0.9e-6,  // Fast mode (Fm)
                _ => 0.45e-6,                  // Fast mode Plus (Fm+)
            };
            let t_af_max = 80e-9_f32; // Analog filter max 80ns. From H7 Datasheet

            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSDADEL <= {tHD;DAT(max) - tAF(max) - [(DNF + 4) x tI2CCLK]}
            let t_sdadel_maximum = t_hddat_max - t_af_max - (4. * t_i2c_clk);

            println!("Target {} Hz; SDADEL {}", freq, sdadel);
            println!(
                "T SDA DELAY {:.2e} MAXIMUM {:.2e}",
                t_sdadel, t_sdadel_maximum
            );
            assert!(sdadel <= 15);
            assert!(t_sdadel <= t_sdadel_maximum);
        });
    }
/// Test the SDADEL value is less than the maximum specification
Test the SDADEL value is less than the maximum specification
Test the SDADEL value is less than the maximum specification
fn i2c_sdadel_maximum() {
        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;
            let t_hddat_max = match freq {
                x if x <= 100_000. => 3.45e-6, // Standard mode (Sm)
                x if x <= 400_000. => 0.9e-6,  // Fast mode (Fm)
                _ => 0.45e-6,                  // Fast mode Plus (Fm+)
            };
            let t_af_max = 80e-9_f32; // Analog filter max 80ns. From H7 Datasheet
            // From RM0433 Rev 7 Section 47.4.5
            //
            // tSDADEL <= {tHD;DAT(max) - tAF(max) - [(DNF + 4) x tI2CCLK]}
            let t_sdadel_maximum = t_hddat_max - t_af_max - (4. * t_i2c_clk);
            println!("Target {} Hz; SDADEL {}", freq, sdadel);
            println!(
                "T SDA DELAY {:.2e} MAXIMUM {:.2e}",
                t_sdadel, t_sdadel_maximum
            );
            assert!(sdadel <= 15);
            assert!(t_sdadel <= t_sdadel_maximum);
        });
    }
fn i2c_sdadel_maximum ( ) { 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 ; let t_hddat_max = match freq { x if x <= 100_000. => 3.45e-6 , // Standard mode (Sm) x if x <= 400_000. => 0.9e-6 , // Fast mode (Fm) _ => 0.45e-6 , // Fast mode Plus (Fm+) } ; let t_af_max = 80e-9_f32 ; // Analog filter max 80ns. From H7 Datasheet // From RM0433 Rev 7 Section 47.4.5 // // tSDADEL <= {tHD;DAT(max) - tAF(max) - [(DNF + 4) x tI2CCLK]} let t_sdadel_maximum = t_hddat_max - t_af_max - ( 4. * t_i2c_clk ) ; println ! ( " " freq sdadel ) ; println ! ( " " t_sdadel t_sdadel_maximum ) ; assert ! ( sdadel 15 ) ; assert ! ( t_sdadel t_sdadel_maximum ) ; } ) ; }
Test the SDADEL value is less than the maximum specification
Test the SDADEL value is less than the maximum specification