Skip to main content

autd3_cpu_wire/
lib.rs

1#![no_std]
2
3#[macro_export]
4macro_rules! wire_enum {
5    ($vis:vis enum $name:ident { $($variant:ident = $value:expr,)+ }) => {
6        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
7        #[repr(u8)]
8        $vis enum $name {
9            $($variant = $value,)+
10        }
11
12        impl $name {
13            #[must_use]
14            $vis const fn from_u8(value: u8) -> Option<Self> {
15                $(if value == $value {
16                    return Some(Self::$variant);
17                })+
18                None
19            }
20
21            #[must_use]
22            $vis const fn as_u8(self) -> u8 {
23                self as u8
24            }
25        }
26
27        impl ::core::convert::TryFrom<u8> for $name {
28            type Error = u8;
29
30            fn try_from(value: u8) -> ::core::result::Result<Self, u8> {
31                Self::from_u8(value).ok_or(value)
32            }
33        }
34    };
35}
36
37mod cmd;
38mod error;
39mod frame;
40pub mod layout;
41mod mode;
42pub mod params;
43pub mod payload;
44mod telemetry;
45
46pub use cmd::Cmd;
47pub use error::{Error, describe_device_error};
48pub use frame::{DEVICE_TO_HOST_BYTES, HOST_TO_DEVICE_BYTES, PAYLOAD_BYTES};
49pub use mode::Mode;
50pub use telemetry::Telemetry;