Skip to main content

PeriodicResyncConfig

Struct PeriodicResyncConfig 

Source
pub struct PeriodicResyncConfig {
    pub period: u32,
    pub max_drift_ulps: i32,
}
Expand description

Configuration for periodic fixed-point accumulator resynchronisation.

§Usage

At every observation step, call should_resync(obs_count % period). When true, call apply_periodic_resync() on each Q16.16 accumulator that carries a running sum over an extended session.

§Default

period = 65536 (one full Q16.16 fractional cycle, ≈ 1 s at 64 kSPS). max_drift_ulps = 32 (½ LSB of a 16-bit ADC ≈ 7.6 × 10⁻⁶).

§Examples

use dsfb_rf::fixedpoint::{PeriodicResyncConfig, apply_periodic_resync,
                            quantize_f32};
let cfg = PeriodicResyncConfig { period: 1000, max_drift_ulps: 50 };
let rho_q = quantize_f32(0.10);
let drifted = rho_q + 80;
if cfg.should_resync(999) {
    let (v, _) = apply_periodic_resync(drifted, rho_q, cfg.max_drift_ulps);
    let _ = v; // re-zeroed value
}

Fields§

§period: u32

Number of observations between resync opportunities.

§max_drift_ulps: i32

Maximum allowed accumulator drift in Q16.16 ULPs before correction. 1 ULP = 1/65536 ≈ 1.53 × 10⁻⁵ in f32 terms.

Implementations§

Source§

impl PeriodicResyncConfig

Source

pub const DEFAULT: Self

Default configuration: period 65536, tolerance 32 ULPs.

Source

pub fn should_resync(&self, obs_mod_period: u32) -> bool

Returns true when obs_mod_period == period - 1 (epoch boundary).

Call as: cfg.should_resync(obs_count % cfg.period).

Trait Implementations§

Source§

impl Clone for PeriodicResyncConfig

Source§

fn clone(&self) -> PeriodicResyncConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeriodicResyncConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for PeriodicResyncConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.