pub enum MotorDriverError {
GpioError,
PwmError,
InvalidSpeed,
InvalidConfiguration,
NotInitialized,
HardwareFault,
OverCurrent,
OverTemperature,
UnderVoltage,
OverVoltage,
CommunicationError,
}Expand description
Error types that can occur during motor driver operations.
This enum represents all possible error conditions that can arise when using motor driver implementations. Errors are categorized by their source and can help diagnose hardware or configuration issues.
§Example
use motor_driver_hal::MotorDriverError;
match motor.set_speed(1500) {
Ok(()) => println!("Speed set successfully"),
Err(MotorDriverError::InvalidSpeed) => println!("Speed value too high"),
Err(MotorDriverError::NotInitialized) => println!("Driver not initialized"),
Err(e) => println!("Other error: {}", e),
}Variants§
GpioError
GPIO pin control operation failed.
This error occurs when setting GPIO pin states (high/low) fails, typically due to hardware issues or incorrect pin configuration.
PwmError
PWM channel operation failed.
This error occurs when PWM duty cycle setting fails, which can happen due to invalid duty cycle values or PWM hardware issues.
InvalidSpeed
Invalid speed value provided.
This error occurs when the speed value exceeds the configured maximum duty cycle or is otherwise invalid for the motor configuration.
InvalidConfiguration
Invalid configuration detected.
This error occurs when the motor driver configuration is incomplete or contains conflicting settings that prevent proper operation.
NotInitialized
Motor driver has not been initialized.
This error occurs when attempting to perform operations before
calling the initialize() method.
HardwareFault
Hardware fault detected.
This error indicates a general hardware fault that prevents normal operation, such as encoder reading failures or unsupported operations.
OverCurrent
Motor current consumption exceeds safe limits.
This error occurs when the motor draws more current than the configured safe operating limits.
OverTemperature
Motor driver temperature exceeds safe operating limits.
This error occurs when the motor driver’s temperature sensor detects overheating conditions.
UnderVoltage
Supply voltage is below minimum operating requirements.
This error occurs when the motor driver’s supply voltage drops below the minimum required for safe operation.
OverVoltage
Supply voltage exceeds maximum operating limits.
This error occurs when the motor driver’s supply voltage exceeds the maximum safe operating voltage.
CommunicationError
Communication with motor driver hardware failed.
This error occurs when communication protocols (I2C, SPI, UART) fail to communicate with smart motor drivers.
Trait Implementations§
Source§impl Clone for MotorDriverError
impl Clone for MotorDriverError
Source§fn clone(&self) -> MotorDriverError
fn clone(&self) -> MotorDriverError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MotorDriverError
Source§impl Debug for MotorDriverError
impl Debug for MotorDriverError
Source§impl Display for MotorDriverError
impl Display for MotorDriverError
Source§impl Error for MotorDriverError
Available on crate feature std only.
impl Error for MotorDriverError
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()