1#[derive(Debug, PartialEq)]
3#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4#[repr(u8)]
5pub enum Register {
6 ChipAddress = 0x00,
7 HashRate = 0x04,
8 PLL0Parameter = 0x08,
9 ChipNonceOffset = 0x0C,
10 HashCountingNumber = 0x10,
11 TicketMask = 0x14,
12 MiscControl = 0x18,
13 I2CControl = 0x1C,
14 OrderedClockEnable = 0x20,
15 FastUARTConfiguration = 0x28,
16 UARTRelay = 0x2C,
17 TicketMask2 = 0x38,
18 CoreRegisterControl = 0x3C,
19 CoreRegisterValue = 0x40,
20 ExternalTemperatureSensorRead = 0x44,
21 ErrorFlag = 0x48,
22 NonceErrorCounter = 0x4C,
23 NonceOverflowCounter = 0x50,
24 AnalogMuxControl = 0x54,
25 IoDriverStrenghtConfiguration = 0x58,
26 TimeOut = 0x5C,
27 PLL1Parameter = 0x60,
28 PLL2Parameter = 0x64,
29 PLL3Parameter = 0x68,
30 OrderedClockMonitor = 0x6C,
31 Pll0Divider = 0x70,
32 Pll1Divider = 0x74,
33 Pll2Divider = 0x78,
34 Pll3Divider = 0x7C,
35 ClockOrderControl0 = 0x80,
36 ClockOrderControl1 = 0x84,
37 ClockOrderStatus = 0x8C,
38 FrequencySweepControl1 = 0x90,
39 GoldenNonceForSweepReturn = 0x94,
40 ReturnedGroupPatternStatus = 0x98,
41 NonceReturnedTimeout = 0x9C,
42 ReturnedSinglePatternStatus = 0xA0,
43}
44
45impl From<Register> for u8 {
46 fn from(r: Register) -> u8 {
47 r as u8
48 }
49}
50
51impl TryFrom<u8> for Register {
52 type Error = u8;
53 fn try_from(val: u8) -> Result<Register, u8> {
54 match val {
55 x if x == Register::ChipAddress as u8 => Ok(Register::ChipAddress),
56 x if x == Register::HashRate as u8 => Ok(Register::HashRate),
57 x if x == Register::PLL0Parameter as u8 => Ok(Register::PLL0Parameter),
58 x if x == Register::ChipNonceOffset as u8 => Ok(Register::ChipNonceOffset),
59 x if x == Register::HashCountingNumber as u8 => Ok(Register::HashCountingNumber),
60 x if x == Register::TicketMask as u8 => Ok(Register::TicketMask),
61 x if x == Register::MiscControl as u8 => Ok(Register::MiscControl),
62 x if x == Register::I2CControl as u8 => Ok(Register::I2CControl),
63 x if x == Register::OrderedClockEnable as u8 => Ok(Register::OrderedClockEnable),
64 x if x == Register::FastUARTConfiguration as u8 => Ok(Register::FastUARTConfiguration),
65 x if x == Register::UARTRelay as u8 => Ok(Register::UARTRelay),
66 x if x == Register::TicketMask2 as u8 => Ok(Register::TicketMask2),
67 x if x == Register::CoreRegisterControl as u8 => Ok(Register::CoreRegisterControl),
68 x if x == Register::CoreRegisterValue as u8 => Ok(Register::CoreRegisterValue),
69 x if x == Register::ExternalTemperatureSensorRead as u8 => {
70 Ok(Register::ExternalTemperatureSensorRead)
71 }
72 x if x == Register::ErrorFlag as u8 => Ok(Register::ErrorFlag),
73 x if x == Register::NonceErrorCounter as u8 => Ok(Register::NonceErrorCounter),
74 x if x == Register::NonceOverflowCounter as u8 => Ok(Register::NonceOverflowCounter),
75 x if x == Register::AnalogMuxControl as u8 => Ok(Register::AnalogMuxControl),
76 x if x == Register::IoDriverStrenghtConfiguration as u8 => {
77 Ok(Register::IoDriverStrenghtConfiguration)
78 }
79 x if x == Register::TimeOut as u8 => Ok(Register::TimeOut),
80 x if x == Register::PLL1Parameter as u8 => Ok(Register::PLL1Parameter),
81 x if x == Register::PLL2Parameter as u8 => Ok(Register::PLL2Parameter),
82 x if x == Register::PLL3Parameter as u8 => Ok(Register::PLL3Parameter),
83 x if x == Register::OrderedClockMonitor as u8 => Ok(Register::OrderedClockMonitor),
84 x if x == Register::Pll0Divider as u8 => Ok(Register::Pll0Divider),
85 x if x == Register::Pll1Divider as u8 => Ok(Register::Pll1Divider),
86 x if x == Register::Pll2Divider as u8 => Ok(Register::Pll2Divider),
87 x if x == Register::Pll3Divider as u8 => Ok(Register::Pll3Divider),
88 x if x == Register::ClockOrderControl0 as u8 => Ok(Register::ClockOrderControl0),
89 x if x == Register::ClockOrderControl1 as u8 => Ok(Register::ClockOrderControl1),
90 x if x == Register::ClockOrderStatus as u8 => Ok(Register::ClockOrderStatus),
91 x if x == Register::FrequencySweepControl1 as u8 => {
92 Ok(Register::FrequencySweepControl1)
93 }
94 x if x == Register::GoldenNonceForSweepReturn as u8 => {
95 Ok(Register::GoldenNonceForSweepReturn)
96 }
97 x if x == Register::ReturnedGroupPatternStatus as u8 => {
98 Ok(Register::ReturnedGroupPatternStatus)
99 }
100 x if x == Register::NonceReturnedTimeout as u8 => Ok(Register::NonceReturnedTimeout),
101 x if x == Register::ReturnedSinglePatternStatus as u8 => {
102 Ok(Register::ReturnedSinglePatternStatus)
103 }
104 _ => Err(val),
105 }
106 }
107}
108
109#[derive(Debug, PartialEq)]
111#[cfg_attr(feature = "defmt", derive(defmt::Format))]
112#[repr(u8)]
113pub enum CoreRegister {
114 ClockDelayCtrl = 0,
115 ProcessMonitorCtrl = 1,
116 ProcessMonitorData = 2,
117 CoreError = 3,
118 CoreEnable = 4,
119 HashClockCtrl = 5,
120 HashClockCounter = 6,
121 SweepClockCtrl = 7,
122}
123
124impl From<CoreRegister> for u8 {
125 fn from(r: CoreRegister) -> u8 {
126 r as u8
127 }
128}
129
130impl TryFrom<u8> for CoreRegister {
131 type Error = u8;
132 fn try_from(val: u8) -> Result<CoreRegister, u8> {
133 match val {
134 x if x == CoreRegister::ClockDelayCtrl as u8 => Ok(CoreRegister::ClockDelayCtrl),
135 x if x == CoreRegister::ProcessMonitorCtrl as u8 => {
136 Ok(CoreRegister::ProcessMonitorCtrl)
137 }
138 x if x == CoreRegister::ProcessMonitorData as u8 => {
139 Ok(CoreRegister::ProcessMonitorData)
140 }
141 x if x == CoreRegister::CoreError as u8 => Ok(CoreRegister::CoreError),
142 x if x == CoreRegister::CoreEnable as u8 => Ok(CoreRegister::CoreEnable),
143 x if x == CoreRegister::HashClockCtrl as u8 => Ok(CoreRegister::HashClockCtrl),
144 x if x == CoreRegister::HashClockCounter as u8 => Ok(CoreRegister::HashClockCounter),
145 x if x == CoreRegister::SweepClockCtrl as u8 => Ok(CoreRegister::SweepClockCtrl),
146 _ => Err(val),
147 }
148 }
149}