embassy-stm32

Crates

git

Versions

stm32n657l0

Flavors

Skip to main content

Npu

Struct Npu 

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

Neural-ART NPU driver.

Implementations§

Source§

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

Source

pub fn new( peri: Peri<'d, T>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Self

Enable and initialize the NPU.

Enables the NPU kernel clock, resets the IP, ungates all ATON-internal unit clocks, enables the bus interfaces and configures the interrupt controller (the equivalent of LL_ATON_RT_RuntimeInit()).

Source

pub async fn run_epoch_blob(&mut self, blob: &[u64]) -> Result<(), Error>

Execute one epoch controller blob and wait for its completion.

blob must contain a loaded blob — magic word, length, instructions — as produced by ecloader::EcBinary::load_blob (or a fully linked blob straight from <network>_ecblobs.h). The slice’s 8-byte alignment satisfies the epoch controller’s address requirement.

If the blob (or any data it reads) was written by the CPU into MCU-cacheable memory, clean the MCU cache first (see cache).

The future completes when the epoch controller raises its end-of-epoch interrupt. No hardware timeout is applied; wrap the future in embassy_time::with_timeout if needed.

Source

pub async fn run_streaming_epoch( &mut self, streng_mask: u16, start: Option<fn()>, end: Option<fn()>, ) -> Result<(), Error>

Run one streaming-engine epoch and wait until every engine in streng_mask reports end-of-transfer.

streng_mask bit n waits for streaming engine n. Bits above engine 9, and a mask of zero, return Error::InvalidWaitMask.

The wait is armed before start runs. start is the generated pre-op: it programs the units and enables the output engines. Enabling those engines before this call drops the completion on the floor, because engine-completion events are masked until the wait is armed. end is the generated post-op and runs only after every waited engine has completed. On error the units are left as start configured them, and the interrupt masks are restored to idle.

No hardware timeout is applied; wrap the future in embassy_time::with_timeout if needed.

Source

pub async fn run_network( &mut self, epochs: &[EpochBlock<'_>], ) -> Result<(), Error>

Run a network: execute a list of epoch blocks in order — the equivalent of looping LL_ATON_RT_RunEpochBlock() until LL_ATON_RT_DONE.

An epoch-controller block runs start, the blob, then end. A streaming-engine block (EpochBlock::streaming) arms its wait mask, runs start as the pre-op, waits for the output engines, then runs end as the post-op. A block with neither a blob nor a wait mask runs start and end on the CPU.

Stops at the first hardware error. A block that sets both blob and streng_mask returns Error::ConflictingEpoch before it starts.

Trait Implementations§

Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

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

§

impl<'d, T> Forget for Npu<'d, T>

§

impl<'d, T> Freeze for Npu<'d, T>
where Peri<'d, T>: Freeze,

§

impl<'d, T> Move for Npu<'d, T>

§

impl<'d, T> RefUnwindSafe for Npu<'d, T>
where Peri<'d, T>: RefUnwindSafe,

§

impl<'d, T> Send for Npu<'d, T>
where Peri<'d, T>: Send,

§

impl<'d, T> Sync for Npu<'d, T>
where Peri<'d, T>: Sync,

§

impl<'d, T> Unpin for Npu<'d, T>
where Peri<'d, T>: Unpin,

§

impl<'d, T> UnsafeUnpin for Npu<'d, T>
where Peri<'d, T>: UnsafeUnpin,

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 = !

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

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

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.