embassy-stm32

Crates

git

Versions

stm32u595zj

Flavors

Cordic

Struct Cordic 

Source
pub struct Cordic<'d, T: Instance> { /* private fields */ }
Expand description

CORDIC driver

Implementations§

Source§

impl<'d, T: Instance> Cordic<'d, T>

Source

pub fn new(peri: Peri<'d, T>, config: Config) -> Self

Create a Cordic driver instance

Source

pub fn set_config(&mut self, config: Config)

Set a new config for Cordic driver.

This calls Self::reconfigure, which resets ARG2 to +1. To change only arg_count/res_count without resetting ARG2, use Self::set_access_counts instead.

Source

pub fn set_access_counts( &mut self, arg_count: AccessCount, res_count: AccessCount, )

Change arg_count and res_count without resetting ARG2.

This is a lightweight CSR update for switching between 1-arg and 2-arg modes within the same function configuration (e.g. after an initial 2-arg call sets ARG2, switch to 1-arg mode for the hot loop).

Source

pub fn reconfigure(&mut self)

Disable IRQ and DMA, clean RRDY, and set ARG2 to +1 (0x7FFFFFFF)

Source§

impl<'d, T: Instance> Cordic<'d, T>

Source

pub fn blocking_calc_32bit( &mut self, arg: &[u32], res: &mut [u32], ) -> Result<usize, CordicError>

Run a blocking CORDIC calculation in q1.31 format.

Uses arg_count and res_count from the current Config. If arg_count is One, ARG2 must have been set to the desired value beforehand (e.g. via a prior Two-arg call or Self::reconfigure).

Source

pub async fn async_calc_32bit<'a, W, R>( &mut self, write_dma: Peri<'a, W>, read_dma: Peri<'a, R>, irq: impl Binding<W::Interrupt, InterruptHandler<W>> + Binding<R::Interrupt, InterruptHandler<R>> + 'a, arg: &[u32], res: &mut [u32], ) -> Result<usize, CordicError>
where W: WriteDma<T>, R: ReadDma<T>,

Run an async CORDIC calculation in q1.31 format.

Uses arg_count and res_count from the current Config. If arg_count is One, ARG2 must have been set to the desired value beforehand (e.g. via a prior Two-arg call or Self::reconfigure).

Source§

impl<'d, T: Instance> Cordic<'d, T>

Source

pub fn blocking_calc_16bit( &mut self, arg: &[u32], res: &mut [u32], ) -> Result<usize, CordicError>

Run a blocking CORDIC calculation in q1.15 format.

In q1.15 mode, each WDATA write / RDATA read contains two packed 16-bit values, so nargs and nres are always 1 (one register access = two values).

After this call, the CSR is restored to the 32-bit state from the current Config.

Source

pub async fn async_calc_16bit<'a, W, R>( &mut self, write_dma: Peri<'a, W>, read_dma: Peri<'a, R>, irq: impl Binding<W::Interrupt, InterruptHandler<W>> + Binding<R::Interrupt, InterruptHandler<R>> + 'a, arg: &[u32], res: &mut [u32], ) -> Result<usize, CordicError>
where W: WriteDma<T>, R: ReadDma<T>,

Run an async CORDIC calculation in q1.15 format.

In q1.15 mode, each WDATA write / RDATA read contains two packed 16-bit values, so nargs and nres are always 1 (one register access = two values).

After this call, the CSR is restored to the 32-bit state from the current Config.

Source§

impl<'d, T: Instance> Cordic<'d, T>

Source

pub fn check_f64_arg1(&self, arg: &f64) -> Result<(), ArgError>

check input value ARG1, SCALE and FUNCTION are compatible with each other

Source

pub fn check_f64_arg2(&self, arg: &f64) -> Result<(), ArgError>

check input value ARG2 and FUNCTION are compatible with each other

Source§

impl<'d, T: Instance> Cordic<'d, T>

Source

pub fn check_f32_arg1(&self, arg: &f32) -> Result<(), ArgError>

check input value ARG1, SCALE and FUNCTION are compatible with each other

Source

pub fn check_f32_arg2(&self, arg: &f32) -> Result<(), ArgError>

check input value ARG2 and FUNCTION are compatible with each other

Trait Implementations§

Source§

impl<'d, T: Instance> Drop for Cordic<'d, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d, T> Freeze for Cordic<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for Cordic<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for Cordic<'d, T>
where T: Send,

§

impl<'d, T> Sync for Cordic<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for Cordic<'d, T>
where T: Unpin,

§

impl<'d, T> !UnwindSafe for Cordic<'d, T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.