1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone)]
pub enum ODriveError {
    Axis(AxisError),
    Motor(MotorError),
    Encoder(EncoderError),
    Controller(ControllerError),
}

#[repr(u16)]
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone)]
pub enum AxisError {
    ErrorNone = 0x00,
    /// An invalid state was requested
    ErrorInvalidState = 0x01,
    ErrorDcBusUnderVoltage = 0x02,
    ErrorDcBusOverVoltage = 0x04,
    ErrorCurrentMeasurementTimeout = 0x08,
    /// The brake resistor was unexpectedly disarmed
    ErrorBrakeResistorDisarmed = 0x10,
    /// The motor was unexpectedly disarmed
    ErrorMotorDisarmed = 0x20,
    ErrorMotorFailed = 0x40,
    ErrorSensorlessEstimatorFailed = 0x80,
    ErrorEncoderFailed = 0x100,
    ErrorControllerFailed = 0x200,
    ErrorPosCtrlDuringSensorless = 0x400,
    ErrorWatchdogTimerExpired = 0x800,
}

#[repr(u16)]
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone)]
pub enum MotorError {
    ErrorNone = 0,
    ErrorPhaseResistanceOutOfRange = 0x0001,
    ErrorPhaseInductanceOutOfRange = 0x0002,
    ErrorAdcFailed = 0x0004,
    ErrorDrvFault = 0x0008,
    ErrorControlDeadlineMissed = 0x0010,
    ErrorNotImplementedMotorType = 0x0020,
    ErrorBrakeCurrentOutOfRange = 0x0040,
    ErrorModulationMagnitude = 0x0080,
    ErrorBrakeDeadTimeViolation = 0x0100,
    ErrorUnexpectedTimerCallback = 0x0200,
    ErrorCurrentSenseSaturation = 0x0400,
    ErrorCurrentUnstable = 0x1000,
}

#[repr(u8)]
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone)]
pub enum EncoderError {
    ErrorNone = 0,
    ErrorUnstableGain = 0x01,
    ErrorCprOutOfRange = 0x02,
    ErrorNoResponse = 0x04,
    ErrorUnsupportedEncoderMode = 0x08,
    ErrorIllegalHallState = 0x10,
    ErrorIndexNotFoundYet = 0x20,
}

#[repr(u8)]
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone)]
pub enum ControllerError {
    ErrorNone = 0,
    ErrorOverspeed = 0x01,
}