autd3_driver/firmware/driver/
mod.rs

1/// Asynchronous module.
2#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
3#[cfg(feature = "async")]
4pub mod r#async;
5
6pub(crate) mod operation;
7mod option;
8mod parallel_mode;
9mod strategy;
10
11pub(crate) use operation::{DOperationGenerator, DynOperationGenerator, NullOp, write_to_tx};
12
13// `BoxedOperation` must be pub for capi
14pub use operation::{BoxedDatagram, BoxedOperation, Operation, OperationHandler, Version};
15pub use option::SenderOption;
16pub use parallel_mode::ParallelMode;
17pub use strategy::{FixedDelay, FixedSchedule, TimerStrategy};
18
19use autd3_core::{
20    derive::FirmwareLimits,
21    geometry::Geometry,
22    link::{MsgId, RxMessage},
23};
24
25use crate::{error::AUTDDriverError, firmware::version::FirmwareVersion};
26
27#[doc(hidden)]
28pub trait Sender<'a, L, S, T> {
29    fn initialize_devices(self) -> Result<(), AUTDDriverError>;
30    fn firmware_version(self) -> Result<Vec<FirmwareVersion>, AUTDDriverError>;
31    fn close(self) -> Result<(), AUTDDriverError>;
32}
33
34#[doc(hidden)]
35pub trait FPGAState
36where
37    Self: Sized,
38{
39    fn from_rx(rx: &RxMessage) -> Option<Self>;
40}
41
42#[doc(hidden)]
43pub trait Driver {
44    type Sender<'a, L, S, T>: Sender<'a, L, S, T>
45    where
46        L: autd3_core::link::Link + 'a,
47        S: autd3_core::sleep::Sleep,
48        T: TimerStrategy<S>;
49    type FPGAState: FPGAState;
50
51    fn new() -> Self;
52
53    fn detect_version<'a, L>(
54        &mut self,
55        _msg_id: &'a mut autd3_core::link::MsgId,
56        _link: &'a mut L,
57        _geometry: &'a autd3_core::derive::Geometry,
58        _sent_flags: &'a mut [bool],
59        _rx: &'a mut [autd3_core::link::RxMessage],
60    ) -> Result<(), AUTDDriverError>
61    where
62        L: autd3_core::link::Link + 'a,
63    {
64        Ok(())
65    }
66
67    #[allow(clippy::too_many_arguments)]
68    fn sender<'a, L, S, T>(
69        &self,
70        msg_id: &'a mut MsgId,
71        link: &'a mut L,
72        geometry: &'a Geometry,
73        sent_flags: &'a mut [bool],
74        rx: &'a mut [RxMessage],
75        option: SenderOption,
76        timer_strategy: T,
77    ) -> Self::Sender<'a, L, S, T>
78    where
79        L: autd3_core::link::Link + 'a,
80        S: autd3_core::sleep::Sleep,
81        T: TimerStrategy<S>;
82    fn firmware_limits(&self) -> FirmwareLimits;
83}