pub struct ClockConfig {
pub div: u16,
}Expand description
Clock configuration structure.
Fields§
§div: u16Divisor value.
Implementations§
Source§impl ClockConfig
impl ClockConfig
Sourcepub fn new_autocalc_with_error(
clk_in: HertzU32,
baudrate: u32,
) -> Result<(Self, f32), ClockConfigError>
pub fn new_autocalc_with_error( clk_in: HertzU32, baudrate: u32, ) -> Result<(Self, f32), ClockConfigError>
This function calculates the required divisor values for a given input clock and baudrate as well as an baud error rate.
Sourcepub fn new_autocalc(
clk_in: HertzU32,
baudrate: u32,
) -> Result<Self, ClockConfigError>
pub fn new_autocalc( clk_in: HertzU32, baudrate: u32, ) -> Result<Self, ClockConfigError>
This function calculates the required divisor values for a given input clock and baudrate.
The function will not calculate the error rate. You can use Self::calculate_error_rate to check the error rate, or use the Self::new_autocalc_with_error function to get both the clock config and its baud error.
Sourcepub fn calculate_error_rate(
&self,
clk_in: HertzU32,
baudrate: u32,
) -> Result<f32, DivisorZeroError>
pub fn calculate_error_rate( &self, clk_in: HertzU32, baudrate: u32, ) -> Result<f32, DivisorZeroError>
Calculate the error rate of the baudrate with the given clock frequency, baudrate and the current clock config as a floating point value between 0.0 and 1.0.
Sourcepub const fn calc_div_with_integer_div(
clk_in: HertzU32,
baudrate: u32,
) -> Result<u32, DivisorZeroError>
pub const fn calc_div_with_integer_div( clk_in: HertzU32, baudrate: u32, ) -> Result<u32, DivisorZeroError>
Calculate the divisor from an input clock for a give target baudrate.
Trait Implementations§
Source§impl Clone for ClockConfig
impl Clone for ClockConfig
Source§fn clone(&self) -> ClockConfig
fn clone(&self) -> ClockConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClockConfig
impl Debug for ClockConfig
Source§impl PartialEq for ClockConfig
impl PartialEq for ClockConfig
impl Copy for ClockConfig
impl Eq for ClockConfig
impl StructuralPartialEq for ClockConfig
Auto Trait Implementations§
impl Freeze for ClockConfig
impl RefUnwindSafe for ClockConfig
impl Send for ClockConfig
impl Sync for ClockConfig
impl Unpin for ClockConfig
impl UnwindSafe for ClockConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more