mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-02-16 17:02:30 +00:00
stm32 CORDIC: typo fix
This commit is contained in:
parent
0d065ab2d6
commit
fac4f9aa2f
@ -25,7 +25,7 @@ pub enum Precision {
|
|||||||
Iters16,
|
Iters16,
|
||||||
Iters20,
|
Iters20,
|
||||||
#[default]
|
#[default]
|
||||||
Iters24, // this value is recomended by Reference Manual
|
Iters24, // this value is recommended by Reference Manual
|
||||||
Iters28,
|
Iters28,
|
||||||
Iters32,
|
Iters32,
|
||||||
Iters36,
|
Iters36,
|
||||||
|
@ -45,7 +45,7 @@ impl defmt::Format for CordicError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error dring parsing [Cordic::Config](super::Config)
|
/// Error during parsing [Cordic::Config](super::Config)
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConfigError {
|
pub struct ConfigError {
|
||||||
|
@ -91,8 +91,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
/// Create a Cordic driver instance
|
/// Create a Cordic driver instance
|
||||||
///
|
///
|
||||||
/// Note:
|
/// Note:
|
||||||
/// If you need a periperhal -> CORDIC -> peripehral mode,
|
/// If you need a peripheral -> CORDIC -> peripheral mode,
|
||||||
/// you may want to set Cordic into [Mode::ZeroOverhead] mode, and add extra arguemnts with [Self::extra_config]
|
/// you may want to set Cordic into [Mode::ZeroOverhead] mode, and add extra arguments with [Self::extra_config]
|
||||||
pub fn new(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self {
|
pub fn new(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self {
|
||||||
T::enable_and_reset();
|
T::enable_and_reset();
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
self.peri.set_scale(self.config.scale);
|
self.peri.set_scale(self.config.scale);
|
||||||
|
|
||||||
// we don't set NRES in here, but to make sure NRES is set each time user call "calc"-ish functions,
|
// we don't set NRES in here, but to make sure NRES is set each time user call "calc"-ish functions,
|
||||||
// since each "calc"-ish functions can have different ARGSIZE and RESSIZE, thus NRES should be change accrodingly.
|
// since each "calc"-ish functions can have different ARGSIZE and RESSIZE, thus NRES should be change accordingly.
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn launch_a_dma_transfer(
|
async fn launch_a_dma_transfer(
|
||||||
@ -256,7 +256,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
self.blocking_write_f64(input_left[0])?;
|
self.blocking_write_f64(input_left[0])?;
|
||||||
|
|
||||||
for &arg in input_left.iter().skip(1) {
|
for &arg in input_left.iter().skip(1) {
|
||||||
// this line write arg for next round caculation to cordic,
|
// this line write arg for next round calculation to cordic,
|
||||||
// and read result from last round
|
// and read result from last round
|
||||||
self.blocking_write_f64(arg)?;
|
self.blocking_write_f64(arg)?;
|
||||||
self.blocking_read_f64_to_buf(output, &mut output_count);
|
self.blocking_read_f64_to_buf(output, &mut output_count);
|
||||||
@ -426,8 +426,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
write_dma: impl Peripheral<P = impl WriteDma<T>>,
|
write_dma: impl Peripheral<P = impl WriteDma<T>>,
|
||||||
read_dma: impl Peripheral<P = impl ReadDma<T>>,
|
read_dma: impl Peripheral<P = impl ReadDma<T>>,
|
||||||
double_input: bool, // gether extra info to calc output_buf size
|
double_input: bool, // gether extra info to calc output_buf size
|
||||||
input_buf: &[u32], // input_buf, its content should be extact values and length for calculation
|
input_buf: &[u32], // input_buf, its content should be exact length for calculation
|
||||||
output: &mut [f64], // caller uses should this as a final output array
|
output: &mut [f64], // caller should uses this buf as a final output array
|
||||||
output_start_index: &mut usize, // the index of start point of the output for this round of calculation
|
output_start_index: &mut usize, // the index of start point of the output for this round of calculation
|
||||||
) {
|
) {
|
||||||
// output_buf is the place to store raw value from CORDIC (via DMA).
|
// output_buf is the place to store raw value from CORDIC (via DMA).
|
||||||
@ -581,7 +581,7 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
// In q1.15 mode, we always fill 1 pair of 16bit value into WDATA register.
|
// In q1.15 mode, we always fill 1 pair of 16bit value into WDATA register.
|
||||||
// If arg2s is None or empty array, we assume arg2 value always 1.0 (as reset value for ARG2).
|
// If arg2s is None or empty array, we assume arg2 value always 1.0 (as reset value for ARG2).
|
||||||
// If arg2s has some value, and but not as long as arg1s,
|
// If arg2s has some value, and but not as long as arg1s,
|
||||||
// we fill the reset of arg2 values with last value from arg2s (as q1.31 version does)
|
// we fill the reset of arg2 values with last value from arg2s (as CORDIC behavior on q1.31 format)
|
||||||
|
|
||||||
let arg2_default_value = match arg2s {
|
let arg2_default_value = match arg2s {
|
||||||
Some(arg2s) if !arg2s.is_empty() => arg2s[arg2s.len() - 1],
|
Some(arg2s) if !arg2s.is_empty() => arg2s[arg2s.len() - 1],
|
||||||
@ -624,8 +624,8 @@ impl<'d, T: Instance> Cordic<'d, T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
write_dma: impl Peripheral<P = impl WriteDma<T>>,
|
write_dma: impl Peripheral<P = impl WriteDma<T>>,
|
||||||
read_dma: impl Peripheral<P = impl ReadDma<T>>,
|
read_dma: impl Peripheral<P = impl ReadDma<T>>,
|
||||||
input_buf: &[u32], // input_buf, its content should be extact values and length for calculation
|
input_buf: &[u32], // input_buf, its content should be exact length for calculation
|
||||||
output: &mut [f32], // caller uses should this as a final output array
|
output: &mut [f32], // caller should uses this buf as a final output array
|
||||||
output_start_index: &mut usize, // the index of start point of the output for this round of calculation
|
output_start_index: &mut usize, // the index of start point of the output for this round of calculation
|
||||||
) {
|
) {
|
||||||
// output_buf is the place to store raw value from CORDIC (via DMA).
|
// output_buf is the place to store raw value from CORDIC (via DMA).
|
||||||
|
@ -25,7 +25,7 @@ macro_rules! floating_fixed_convert {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// It's necessary to cast the float value to signed integer, before convert it to a unsigned value.
|
// It's necessary to cast the float value to signed integer, before convert it to a unsigned value.
|
||||||
// Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as unsgined value.
|
// 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.
|
||||||
// see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
|
// see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
|
||||||
Ok((value * ((1 as $unsigned_bin_typ << $offset) as $float_ty)) as $signed_bin_typ as $unsigned_bin_typ)
|
Ok((value * ((1 as $unsigned_bin_typ << $offset) as $float_ty)) as $signed_bin_typ as $unsigned_bin_typ)
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ macro_rules! floating_fixed_convert {
|
|||||||
/// convert fixed point to float point format
|
/// convert fixed point to float point format
|
||||||
pub fn $q_to_f(value: $unsigned_bin_typ) -> $float_ty {
|
pub fn $q_to_f(value: $unsigned_bin_typ) -> $float_ty {
|
||||||
// It's necessary to cast the unsigned integer to signed integer, before convert it to a float value.
|
// It's necessary to cast the unsigned integer to signed integer, before convert it to a float value.
|
||||||
// Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as signed value.
|
// Since value from register is actually a "signed value", a "as" cast will keep original binary format but mark it as a signed value.
|
||||||
// see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
|
// see https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast
|
||||||
(value as $signed_bin_typ as $float_ty) / ((1 as $unsigned_bin_typ << $offset) as $float_ty)
|
(value as $signed_bin_typ as $float_ty) / ((1 as $unsigned_bin_typ << $offset) as $float_ty)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user