pub struct Timing { /* private fields */ }
Expand description
LPI2C timing parameters.
The implementation computes BUSIDLE based on the clock configuration values, but you can override this after construction.
The simplest way to construct a Timing
is to use ideal()
.
Implementations§
source§impl Timing
impl Timing
sourcepub const fn ideal(clock_hz: u32, clock_speed: ClockSpeed) -> Self
pub const fn ideal(clock_hz: u32, clock_speed: ClockSpeed) -> Self
Compute timing parameters assuming an ideal I2C bus.
This constructor assumes that
- the SDA / SCL rise times are negligible (take less than one functional clock cycle).
- there’s no need for glitch filters (FLITSCL = FILTSDA = 0).
These assumptions may not hold true for high clock speeds and I2C bus loadings. If that’s the case, you may find it’s better to define timing parameters yourself.
Note that this function can run at compile time. Consider evaluating in a const context to avoid the possibility of panics.
Panics
After evaluating all prescalars, this function panics if the computed clock period cannot be represented in the 6 bits available for the configuration.
sourcepub const fn new(
clock_configuration: ClockConfiguration,
prescaler: Prescaler
) -> Self
pub const fn new( clock_configuration: ClockConfiguration, prescaler: Prescaler ) -> Self
Computes timing parameters assuming an ideal circuit.
Define LPI2C timings by the clock configuration values, and a prescaler.
sourcepub const fn clock_configuration(&self) -> ClockConfiguration
pub const fn clock_configuration(&self) -> ClockConfiguration
Returns the clock configuration.
sourcepub const fn override_busidle(self, busidle: u32) -> Self
pub const fn override_busidle(self, busidle: u32) -> Self
Override the BUSIDLE parameter.
The minimum BUSIDLE is computed by CLKLO, SETHOLD, and CLKHI. Use this method to override the value.