1crate::wire_enum! {
2 pub enum Cmd {
3 Reset = 0x00,
4 Synchronize = 0x01,
5 SetMode = 0x02,
6 Clear = 0x03,
7 Nop = 0x04,
8 WritePatternBuffer = 0x10,
9 ConfigPattern = 0x11,
10 ChangePatternBank = 0x12,
11 WritePatternCompressed = 0x13,
12 WritePatternFused = 0x14,
13 WriteModulationBuffer = 0x20,
14 ConfigModulation = 0x21,
15 ChangeModulationBank = 0x22,
16 WriteModulationFused = 0x23,
17 SetSilencer = 0x30,
18 SetPhaseCorrection = 0x40,
19 SetOutputMask = 0x41,
20 SetPulseWidthTable = 0x42,
21 EmulateGpioIn = 0x50,
22 SetGpioOut = 0x52,
23 ForceFan = 0x60,
24 ReadErrorDetail = 0xE0,
25 ReadCpuFwVersionMajor = 0xE1,
26 ReadCpuFwVersionMinor = 0xE2,
27 ReadCpuFwVersionPatch = 0xE3,
28 ReadFpgaFwVersionMajor = 0xE4,
29 ReadFpgaFwVersionMinor = 0xE5,
30 ReadFpgaFwVersionPatch = 0xE6,
31 ReadFpgaState = 0xE7,
32 ReadTelemetry = 0xE8,
33 ReadFpgaFunctions = 0xE9,
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn cmd_round_trips() {
43 for raw in 0u8..=0xFF {
44 if let Some(c) = Cmd::from_u8(raw) {
45 assert_eq!(c.as_u8(), raw);
46 assert_eq!(Cmd::try_from(raw), Ok(c));
47 } else {
48 assert_eq!(Cmd::try_from(raw), Err(raw));
49 }
50 }
51 }
52}