1#![no_std]
6
7#[cfg(feature = "driver")]
8pub mod program;
9#[cfg(feature = "driver")]
10pub use program::StandardDShotTimings as StandardDShotTimings;
11#[cfg(feature = "driver")]
12pub use program::BdDShotTimings as BdDShotTimings;
13#[cfg(feature = "driver")]
14pub mod driver;
15
16pub mod encoder;
17
18#[derive(Debug, Clone)]
19#[cfg_attr(feature = "thiserror", derive(thiserror_no_std::Error))]
20#[cfg_attr(feature = "defmt", derive(defmt::Format))]
21pub enum Error {
22 #[cfg(feature = "driver")]
24 #[cfg_attr(feature = "thiserror", error("Throttle command must be in the range 0-1999, was {throttle}"))]
25 ThrottleBoundsError { throttle: u16 },
26 #[cfg(feature = "driver")]
28 #[cfg_attr(feature = "thiserror", error("Conversion from float to fixed failed in clock divider calculation. Float value: {}", clock_divider_float))]
29 ClockDividerConversionError { clock_divider_float: f32 },
30 #[cfg(feature = "driver")]
32 #[cfg_attr(feature = "thiserror", error("Failed to spawn task"))]
33 SpawnError(embassy_executor::SpawnError),
34 #[cfg(feature = "driver")]
36 #[cfg_attr(feature = "thiserror", error("Failed to recieve value from channel"))]
37 TryReceiveError(embassy_sync::channel::TryReceiveError),
38 #[cfg(feature = "driver")]
40 #[cfg_attr(feature = "thiserror", error("Driver future timed out"))]
41 TimeoutError(embassy_time::TimeoutError),
42 #[cfg(feature = "driver")]
44 #[cfg_attr(feature = "thiserror", error("Invalid ERPM telemetry checksum"))]
45 InvalidTelemetryChecksum,
46 #[cfg(feature = "driver")]
48 #[cfg_attr(feature = "thiserror", error("TX Push Faliure"))]
49 TxTryPushFaliure,
50 #[cfg(feature = "driver")]
51 #[cfg_attr(feature = "thiserror", error("SM Split Faliure, empty pointer!"))]
53 SmSplitFaliure,
54}
55
56#[cfg(feature = "driver")]
57impl From<embassy_executor::SpawnError> for Error {
58 fn from(e: embassy_executor::SpawnError) -> Self {
59 Error::SpawnError(e)
60 }
61}
62
63#[cfg(feature = "driver")]
64impl From<embassy_sync::channel::TryReceiveError> for Error {
65 fn from(e: embassy_sync::channel::TryReceiveError) -> Self {
66 Error::TryReceiveError(e)
67 }
68}
69
70#[cfg(feature = "driver")]
71impl From<embassy_time::TimeoutError> for Error {
72 fn from(e: embassy_time::TimeoutError) -> Self {
73 Error::TimeoutError(e)
74 }
75}