pub struct Cordic<'d, Dm: DriverMode = Blocking> { /* private fields */ }Expand description
A blocking CORDIC driver.
Implementations§
Source§impl<'d> Cordic<'d, Blocking>
impl<'d> Cordic<'d, Blocking>
Sourcepub fn new(peripheral: CORDIC<'d>, config: Config) -> Result<Self, ConfigError>
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.
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
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.
Sourcepub fn frequency(&self) -> Rate
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.
Sourcepub fn sin_cos_q15(&mut self, angle: i16) -> Result<(i16, i16), Error>
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.
Sourcepub fn sin_cos_q31(&mut self, angle: i32) -> Result<(i32, i32), Error>
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.
Sourcepub fn sin_q15(&mut self, angle: i16) -> Result<i16, Error>
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.
Sourcepub fn sin_q31(&mut self, angle: i32) -> Result<i32, Error>
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.
Sourcepub fn cos_q15(&mut self, angle: i16) -> Result<i16, Error>
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.
Sourcepub fn cos_q31(&mut self, angle: i32) -> Result<i32, Error>
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.
Sourcepub fn phase_modulus_q15(&mut self, x: i16, y: i16) -> Result<(i16, i16), Error>
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
Error::InvalidInputwhen the vector is zero or has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn phase_modulus_q31(&mut self, x: i32, y: i32) -> Result<(i32, i32), Error>
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
Error::InvalidInputwhen the vector is zero or has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn phase_q15(&mut self, x: i16, y: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen the vector is zero or has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn phase_q31(&mut self, x: i32, y: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen the vector is zero or has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn modulus_q15(&mut self, x: i16, y: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen the vector has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn modulus_q31(&mut self, x: i32, y: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen the vector has a modulus of at least one.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sinh_cosh_q15(&mut self, x_over_two: i16) -> Result<(i16, i16), Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sinh_cosh_q31(&mut self, x_over_two: i32) -> Result<(i32, i32), Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sinh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sinh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn cosh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn cosh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen|x / 2| > 0.559.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn atanh_q15(&mut self, x_over_two: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen|x / 2| > 0.403.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn atanh_q31(&mut self, x_over_two: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen|x / 2| > 0.403.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn ln_from_ratio_q15(&mut self, ratio: i16) -> Result<i16, Error>
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
Error::InvalidInputwhen|ratio| > 0.403.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn ln_from_ratio_q31(&mut self, ratio: i32) -> Result<i32, Error>
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
Error::InvalidInputwhen|ratio| > 0.403.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sqrt_q15(&mut self, x: i16) -> Result<i16, Error>
pub fn sqrt_q15(&mut self, x: i16) -> Result<i16, Error>
Returns sqrt(x) in Q1.15.
§Errors
Error::InvalidInputwhenxis negative.Error::UnsupportedPrecisionwhen the iteration count exceeds 12.Error::Timeoutwhen the calculation does not complete.
Sourcepub fn sqrt_q31(&mut self, x: i32) -> Result<i32, Error>
pub fn sqrt_q31(&mut self, x: i32) -> Result<i32, Error>
Returns sqrt(x) in Q1.31.
§Errors
Error::InvalidInputwhenxis negative.Error::UnsupportedPrecisionwhen the iteration count exceeds 12.Error::Timeoutwhen the calculation does not complete.