pub struct Npu<'d, T: Instance> { /* private fields */ }Expand description
Neural-ART NPU driver.
Implementations§
Source§impl<'d, T: Instance> Npu<'d, T>
impl<'d, T: Instance> Npu<'d, T>
Sourcepub fn new(
peri: Peri<'d, T>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
) -> Self
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()).
Sourcepub async fn run_epoch_blob(&mut self, blob: &[u64]) -> Result<(), Error>
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.
Sourcepub async fn run_streaming_epoch(
&mut self,
streng_mask: u16,
start: Option<fn()>,
end: Option<fn()>,
) -> Result<(), Error>
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.
Sourcepub async fn run_network(
&mut self,
epochs: &[EpochBlock<'_>],
) -> Result<(), Error>
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.