autd3_driver/firmware/driver/
mod.rs1#[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
13pub 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 environment::Environment,
21 firmware::FirmwareLimits,
22 geometry::Geometry,
23 link::{MsgId, RxMessage},
24};
25
26use crate::{error::AUTDDriverError, firmware::version::FirmwareVersion};
27
28#[doc(hidden)]
29pub trait Sender<'a, L, S, T> {
30 fn initialize_devices(self) -> Result<(), AUTDDriverError>;
31 fn firmware_version(self) -> Result<Vec<FirmwareVersion>, AUTDDriverError>;
32 fn close(self) -> Result<(), AUTDDriverError>;
33}
34
35#[doc(hidden)]
36pub trait FPGAState
37where
38 Self: Sized,
39{
40 fn from_rx(rx: &RxMessage) -> Option<Self>;
41}
42
43#[doc(hidden)]
44pub trait Driver {
45 type Sender<'a, L, S, T>: Sender<'a, L, S, T>
46 where
47 L: autd3_core::link::Link + 'a,
48 S: autd3_core::sleep::Sleep,
49 T: TimerStrategy<S>;
50 type FPGAState: FPGAState;
51
52 fn new() -> Self;
53
54 fn detect_version<'a, L>(
55 &mut self,
56 _msg_id: &'a mut autd3_core::link::MsgId,
57 _link: &'a mut L,
58 _geometry: &'a autd3_core::geometry::Geometry,
59 _sent_flags: &'a mut [bool],
60 _rx: &'a mut [autd3_core::link::RxMessage],
61 _env: &'a Environment,
62 ) -> Result<(), AUTDDriverError>
63 where
64 L: autd3_core::link::Link + 'a,
65 {
66 Ok(())
67 }
68
69 #[allow(clippy::too_many_arguments)]
70 fn sender<'a, L, S, T>(
71 &self,
72 msg_id: &'a mut MsgId,
73 link: &'a mut L,
74 geometry: &'a Geometry,
75 sent_flags: &'a mut [bool],
76 rx: &'a mut [RxMessage],
77 env: &'a Environment,
78 option: SenderOption,
79 timer_strategy: T,
80 ) -> Self::Sender<'a, L, S, T>
81 where
82 L: autd3_core::link::Link + 'a,
83 S: autd3_core::sleep::Sleep,
84 T: TimerStrategy<S>;
85 fn firmware_limits(&self) -> FirmwareLimits;
86}