aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/cordic/enums.rs2
-rw-r--r--embassy-stm32/src/cordic/errors.rs2
-rw-r--r--embassy-stm32/src/cordic/mod.rs18
-rw-r--r--embassy-stm32/src/cordic/utils.rs4
4 files changed, 13 insertions, 13 deletions
diff --git a/embassy-stm32/src/cordic/enums.rs b/embassy-stm32/src/cordic/enums.rs
index 4b92a6cf8..e8695fac7 100644
--- a/embassy-stm32/src/cordic/enums.rs
+++ b/embassy-stm32/src/cordic/enums.rs
@@ -25,7 +25,7 @@ pub enum Precision {
25 Iters16, 25 Iters16,
26 Iters20, 26 Iters20,
27 #[default] 27 #[default]
28 Iters24, // this value is recomended by Reference Manual 28 Iters24, // this value is recommended by Reference Manual
29 Iters28, 29 Iters28,
30 Iters32, 30 Iters32,
31 Iters36, 31 Iters36,
diff --git a/embassy-stm32/src/cordic/errors.rs b/embassy-stm32/src/cordic/errors.rs
index 9020d8467..653014290 100644
--- a/embassy-stm32/src/cordic/errors.rs
+++ b/embassy-stm32/src/cordic/errors.rs
@@ -45,7 +45,7 @@ impl defmt::Format for CordicError {
45 } 45 }
46} 46}
47 47
48/// Error dring parsing [Cordic::Config](super::Config) 48/// Error during parsing [Cordic::Config](super::Config)
49#[allow(dead_code)] 49#[allow(dead_code)]
50#[derive(Debug)] 50#[derive(Debug)]
51pub struct ConfigError { 51pub struct ConfigError {
diff --git a/embassy-stm32/src/cordic/mod.rs b/embassy-stm32/src/cordic/mod.rs
index b0db3f060..f12efe2eb 100644
--- a/embassy-stm32/src/cordic/mod.rs
+++ b/embassy-stm32/src/cordic/mod.rs
@@ -91,8 +91,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
91 /// Create a Cordic driver instance 91 /// Create a Cordic driver instance
92 /// 92 ///
93 /// Note: 93 /// Note:
94 /// If you need a periperhal -> CORDIC -> peripehral mode, 94 /// If you need a peripheral -> CORDIC -> peripheral mode,
95 /// you may want to set Cordic into [Mode::ZeroOverhead] mode, and add extra arguemnts with [Self::extra_config] 95 /// you may want to set Cordic into [Mode::ZeroOverhead] mode, and add extra arguments with [Self::extra_config]
96 pub fn new(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self { 96 pub fn new(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self {
97 T::enable_and_reset(); 97 T::enable_and_reset();
98 98
@@ -123,7 +123,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
123 self.peri.set_scale(self.config.scale); 123 self.peri.set_scale(self.config.scale);
124 124
125 // we don't set NRES in here, but to make sure NRES is set each time user call "calc"-ish functions, 125 // we don't set NRES in here, but to make sure NRES is set each time user call "calc"-ish functions,
126 // since each "calc"-ish functions can have different ARGSIZE and RESSIZE, thus NRES should be change accrodingly. 126 // since each "calc"-ish functions can have different ARGSIZE and RESSIZE, thus NRES should be change accordingly.
127 } 127 }
128 128
129 async fn launch_a_dma_transfer( 129 async fn launch_a_dma_transfer(
@@ -256,7 +256,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
256 self.blocking_write_f64(input_left[0])?; 256 self.blocking_write_f64(input_left[0])?;
257 257
258 for &arg in input_left.iter().skip(1) { 258 for &arg in input_left.iter().skip(1) {
259 // this line write arg for next round caculation to cordic, 259 // this line write arg for next round calculation to cordic,
260 // and read result from last round 260 // and read result from last round
261 self.blocking_write_f64(arg)?; 261 self.blocking_write_f64(arg)?;
262 self.blocking_read_f64_to_buf(output, &mut output_count); 262 self.blocking_read_f64_to_buf(output, &mut output_count);
@@ -426,8 +426,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
426 write_dma: impl Peripheral<P = impl WriteDma<T>>, 426 write_dma: impl Peripheral<P = impl WriteDma<T>>,
427 read_dma: impl Peripheral<P = impl ReadDma<T>>, 427 read_dma: impl Peripheral<P = impl ReadDma<T>>,
428 double_input: bool, // gether extra info to calc output_buf size 428 double_input: bool, // gether extra info to calc output_buf size
429 input_buf: &[u32], // input_buf, its content should be extact values and length for calculation 429 input_buf: &[u32], // input_buf, its content should be exact length for calculation
430 output: &mut [f64], // caller uses should this as a final output array 430 output: &mut [f64], // caller should uses this buf as a final output array
431 output_start_index: &mut usize, // the index of start point of the output for this round of calculation 431 output_start_index: &mut usize, // the index of start point of the output for this round of calculation
432 ) { 432 ) {
433 // output_buf is the place to store raw value from CORDIC (via DMA). 433 // output_buf is the place to store raw value from CORDIC (via DMA).
@@ -581,7 +581,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
581 // In q1.15 mode, we always fill 1 pair of 16bit value into WDATA register. 581 // In q1.15 mode, we always fill 1 pair of 16bit value into WDATA register.
582 // If arg2s is None or empty array, we assume arg2 value always 1.0 (as reset value for ARG2). 582 // If arg2s is None or empty array, we assume arg2 value always 1.0 (as reset value for ARG2).
583 // If arg2s has some value, and but not as long as arg1s, 583 // If arg2s has some value, and but not as long as arg1s,
584 // we fill the reset of arg2 values with last value from arg2s (as q1.31 version does) 584 // we fill the reset of arg2 values with last value from arg2s (as CORDIC behavior on q1.31 format)
585 585
586 let arg2_default_value = match arg2s { 586 let arg2_default_value = match arg2s {
587 Some(arg2s) if !arg2s.is_empty() => arg2s[arg2s.len() - 1], 587 Some(arg2s) if !arg2s.is_empty() => arg2s[arg2s.len() - 1],
@@ -624,8 +624,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
624 &mut self, 624 &mut self,
625 write_dma: impl Peripheral<P = impl WriteDma<T>>, 625 write_dma: impl Peripheral<P = impl WriteDma<T>>,
626 read_dma: impl Peripheral<P = impl ReadDma<T>>, 626 read_dma: impl Peripheral<P = impl ReadDma<T>>,
627 input_buf: &[u32], // input_buf, its content should be extact values and length for calculation 627 input_buf: &[u32], // input_buf, its content should be exact length for calculation
628 output: &mut [f32], // caller uses should this as a final output array 628 output: &mut [f32], // caller should uses this buf as a final output array
629 output_start_index: &mut usize, // the index of start point of the output for this round of calculation 629 output_start_index: &mut usize, // the index of start point of the output for this round of calculation
630 ) { 630 ) {
631 // output_buf is the place to store raw value from CORDIC (via DMA). 631 // output_buf is the place to store raw value from CORDIC (via DMA).
diff --git a/embassy-stm32/src/cordic/utils.rs b/embassy-stm32/src/cordic/utils.rs
index 3c3ed224f..41821d6e2 100644
--- a/embassy-stm32/src/cordic/utils.rs
+++ b/embassy-stm32/src/cordic/utils.rs
@@ -25,7 +25,7 @@ macro_rules! floating_fixed_convert {
25 }; 25 };
26 26
27 // It's necessary to cast the float value to signed integer, before convert it to a unsigned value. 27 // It's necessary to cast the float value to signed integer, before convert it to a unsigned value.
28 // Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as unsgined value. 28 // Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as a unsigned value for register writing.
29 // see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast 29 // see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
30 Ok((value * ((1 as $unsigned_bin_typ << $offset) as $float_ty)) as $signed_bin_typ as $unsigned_bin_typ) 30 Ok((value * ((1 as $unsigned_bin_typ << $offset) as $float_ty)) as $signed_bin_typ as $unsigned_bin_typ)
31 } 31 }
@@ -34,7 +34,7 @@ macro_rules! floating_fixed_convert {
34 /// convert fixed point to float point format 34 /// convert fixed point to float point format
35 pub fn $q_to_f(value: $unsigned_bin_typ) -> $float_ty { 35 pub fn $q_to_f(value: $unsigned_bin_typ) -> $float_ty {
36 // It's necessary to cast the unsigned integer to signed integer, before convert it to a float value. 36 // It's necessary to cast the unsigned integer to signed integer, before convert it to a float value.
37 // Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as signed value. 37 // Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as a signed value.
38 // see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast 38 // see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
39 (value as $signed_bin_typ as $float_ty) / ((1 as $unsigned_bin_typ << $offset) as $float_ty) 39 (value as $signed_bin_typ as $float_ty) / ((1 as $unsigned_bin_typ << $offset) as $float_ty)
40 } 40 }