Skip to main content

Cordic

Struct Cordic 

Source
pub struct Cordic<'d, Dm: DriverMode = Blocking> { /* private fields */ }
Expand description

A blocking CORDIC driver.

Implementations§

Source§

impl<'d> Cordic<'d, Blocking>

Source

pub fn new(peripheral: CORDIC<'d>, config: Config) -> Result<Self, ConfigError>

Creates a new CORDIC driver.

§Errors

ConfigError::UnreachableClockRate when the requested clock rate is unsupported.

Source

pub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>

Applies a new clock and precision configuration.

§Errors

ConfigError::UnreachableClockRate when the requested clock rate is unsupported. The current configuration is retained in that case.

Source

pub fn frequency(&self) -> Rate

Returns the calculation clock rate derived from the selected source and divider.

The actual rate can differ when using the internal RC oscillator.

Source

pub fn sin_cos_q15(&mut self, angle: i16) -> Result<(i16, i16), Error>

Returns (sin(θ), cos(θ)) in Q1.15 for input θ / π.

A result of +1 is represented by [i16::MAX].

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn sin_cos_q31(&mut self, angle: i32) -> Result<(i32, i32), Error>

Returns (sin(θ), cos(θ)) in Q1.31 for input θ / π.

A result of +1 is represented by [i32::MAX].

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn sin_q15(&mut self, angle: i16) -> Result<i16, Error>

Returns sin(θ) in Q1.15 for input θ / π.

A result of +1 is represented by [i16::MAX]. Self::sin_cos_q15 computes sine and cosine in one operation.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn sin_q31(&mut self, angle: i32) -> Result<i32, Error>

Returns sin(θ) in Q1.31 for input θ / π.

A result of +1 is represented by [i32::MAX]. Self::sin_cos_q31 computes sine and cosine in one operation.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn cos_q15(&mut self, angle: i16) -> Result<i16, Error>

Returns cos(θ) in Q1.15 for input θ / π.

A result of +1 is represented by [i16::MAX]. Self::sin_cos_q15 computes sine and cosine in one operation.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn cos_q31(&mut self, angle: i32) -> Result<i32, Error>

Returns cos(θ) in Q1.31 for input θ / π.

A result of +1 is represented by [i32::MAX]. Self::sin_cos_q31 computes sine and cosine in one operation.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn phase_modulus_q15(&mut self, x: i16, y: i16) -> Result<(i16, i16), Error>

Returns (atan2(y, x) / π, hypot(x, y)) in Q1.15.

For x < 0 and y = 0, the phase approximates +1.

§Errors
Source

pub fn phase_modulus_q31(&mut self, x: i32, y: i32) -> Result<(i32, i32), Error>

Returns (atan2(y, x) / π, hypot(x, y)) in Q1.31.

For x < 0 and y = 0, the phase approximates +1.

§Errors
Source

pub fn phase_q15(&mut self, x: i16, y: i16) -> Result<i16, Error>

Returns atan2(y, x) / π in Q1.15.

For x < 0 and y = 0, the phase approximates +1. Self::phase_modulus_q15 computes the phase and modulus in one operation.

§Errors
Source

pub fn phase_q31(&mut self, x: i32, y: i32) -> Result<i32, Error>

Returns atan2(y, x) / π in Q1.31.

For x < 0 and y = 0, the phase approximates +1. Self::phase_modulus_q31 computes the phase and modulus in one operation.

§Errors
Source

pub fn modulus_q15(&mut self, x: i16, y: i16) -> Result<i16, Error>

Returns hypot(x, y) in Q1.15.

Self::phase_modulus_q15 computes the phase and modulus in one operation.

§Errors
Source

pub fn modulus_q31(&mut self, x: i32, y: i32) -> Result<i32, Error>

Returns hypot(x, y) in Q1.31.

Self::phase_modulus_q31 computes the phase and modulus in one operation.

§Errors
Source

pub fn atan_q15(&mut self, x: i16) -> Result<i16, Error>

Returns atan(x) / π in Q1.15.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn atan_q31(&mut self, x: i32) -> Result<i32, Error>

Returns atan(x) / π in Q1.31.

§Errors

Error::Timeout when the calculation does not complete.

Source

pub fn sinh_cosh_q15(&mut self, x_over_two: i16) -> Result<(i16, i16), Error>

Returns (sinh(x) / 2, cosh(x) / 2) in Q1.15 for input x / 2.

§Errors
Source

pub fn sinh_cosh_q31(&mut self, x_over_two: i32) -> Result<(i32, i32), Error>

Returns (sinh(x) / 2, cosh(x) / 2) in Q1.31 for input x / 2.

§Errors
Source

pub fn sinh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>

Returns sinh(x) / 2 in Q1.15 for input x / 2.

Self::sinh_cosh_q15 computes sinh and cosh in one operation.

§Errors
Source

pub fn sinh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>

Returns sinh(x) / 2 in Q1.31 for input x / 2.

Self::sinh_cosh_q31 computes sinh and cosh in one operation.

§Errors
Source

pub fn cosh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>

Returns cosh(x) / 2 in Q1.15 for input x / 2.

Self::sinh_cosh_q15 computes sinh and cosh in one operation.

§Errors
Source

pub fn cosh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>

Returns cosh(x) / 2 in Q1.31 for input x / 2.

Self::sinh_cosh_q31 computes sinh and cosh in one operation.

§Errors
Source

pub fn atanh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>

Returns atanh(x) / 2 in Q1.15 for input x / 2.

§Errors
Source

pub fn atanh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>

Returns atanh(x) / 2 in Q1.31 for input x / 2.

§Errors
Source

pub fn ln_from_ratio_q15(&mut self, ratio: i16) -> Result<i16, Error>

Returns ln(x) / 4 from the ratio (x - 1) / (2 * (x + 1)) for positive x, with the input and result in Q1.15.

§Errors
Source

pub fn ln_from_ratio_q31(&mut self, ratio: i32) -> Result<i32, Error>

Returns ln(x) / 4 from the ratio (x - 1) / (2 * (x + 1)) for positive x, with the input and result in Q1.31.

§Errors
Source

pub fn sqrt_q15(&mut self, x: i16) -> Result<i16, Error>

Returns sqrt(x) in Q1.15.

§Errors
Source

pub fn sqrt_q31(&mut self, x: i32) -> Result<i32, Error>

Returns sqrt(x) in Q1.31.

§Errors

Trait Implementations§

Source§

impl<'d, Dm: Debug + DriverMode> Debug for Cordic<'d, Dm>

Available on crate feature unstable only.
Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'d, Dm = Blocking> !UnwindSafe for Cordic<'d, Dm>

§

impl<'d, Dm> Forget for Cordic<'d, Dm>

§

impl<'d, Dm> Freeze for Cordic<'d, Dm>
where PhantomData<Dm>: Freeze,

§

impl<'d, Dm> Move for Cordic<'d, Dm>

§

impl<'d, Dm> RefUnwindSafe for Cordic<'d, Dm>
where PhantomData<Dm>: RefUnwindSafe,

§

impl<'d, Dm> Send for Cordic<'d, Dm>
where PhantomData<Dm>: Send,

§

impl<'d, Dm> Sync for Cordic<'d, Dm>
where PhantomData<Dm>: Sync,

§

impl<'d, Dm> Unpin for Cordic<'d, Dm>
where PhantomData<Dm>: Unpin,

§

impl<'d, Dm> UnsafeUnpin for Cordic<'d, Dm>
where PhantomData<Dm>: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.