nrf24l01_commands/
fields.rs1#[const_trait]
5pub trait EnumField {
6 fn into_bits(self) -> u8;
8 fn from_bits(bits: u8) -> Self;
10}
11
12#[derive(Copy, Clone, Debug, PartialEq, Eq)]
14#[repr(u8)]
15pub enum Crco {
16 OneByte = 0,
18 TwoByte = 1,
20}
21impl const EnumField for Crco {
22 fn into_bits(self) -> u8 {
23 self as _
24 }
25 fn from_bits(bits: u8) -> Self {
26 unsafe { core::mem::transmute(bits & 1) }
28 }
29}
30
31#[derive(Copy, Clone, Debug, PartialEq, Eq)]
34#[repr(u8)]
35pub enum AddressWidth {
36 Illegal = 0,
37 ThreeByte = 0b01,
38 FourByte = 0b10,
39 FiveByte = 0b11,
40}
41impl const EnumField for AddressWidth {
42 fn into_bits(self) -> u8 {
43 self as _
44 }
45 fn from_bits(bits: u8) -> Self {
46 unsafe { core::mem::transmute(bits & 0b11) }
48 }
49}
50
51#[derive(Copy, Clone, Debug, PartialEq, Eq)]
63#[repr(u8)]
64pub enum AutoRetransmitDelay {
65 US250 = 0b0000,
66 US500 = 0b0001,
67 US750 = 0b0010,
68 US1000 = 0b0011,
69 US1250 = 0b0100,
70 US1500 = 0b0101,
71 US1750 = 0b0110,
72 US2000 = 0b0111,
73 US2250 = 0b1000,
74 US2500 = 0b1001,
75 US2750 = 0b1010,
76 US3000 = 0b1011,
77 US3250 = 0b1100,
78 US3500 = 0b1101,
79 US3750 = 0b1110,
80 US4000 = 0b1111,
81}
82impl const EnumField for AutoRetransmitDelay {
83 fn into_bits(self) -> u8 {
84 self as _
85 }
86 fn from_bits(bits: u8) -> Self {
87 unsafe { core::mem::transmute(bits & 0b1111) }
89 }
90}
91
92#[derive(Copy, Clone, Debug, PartialEq, Eq)]
94#[repr(u8)]
95pub enum RfDrHigh {
96 Mbps1 = 0,
97 Mbps2 = 1,
98}
99impl const EnumField for RfDrHigh {
100 fn into_bits(self) -> u8 {
101 self as _
102 }
103 fn from_bits(bits: u8) -> Self {
104 unsafe { core::mem::transmute(bits & 1) }
106 }
107}
108
109#[derive(Copy, Clone, Debug, PartialEq, Eq)]
111#[repr(u8)]
112pub enum RfPower {
113 Neg18Dbm = 0b00,
115 Neg12Dbm = 0b01,
117 Neg6Dbm = 0b10,
119 Dbm0 = 0b11,
121}
122impl const EnumField for RfPower {
123 fn into_bits(self) -> u8 {
124 self as _
125 }
126 fn from_bits(bits: u8) -> Self {
127 unsafe { core::mem::transmute(bits & 0b11) }
129 }
130}
131
132#[derive(Copy, Clone, Debug, PartialEq, Eq)]
134#[repr(u8)]
135pub enum RxPipeNo {
136 Pipe0 = 0,
137 Pipe1 = 1,
138 Pipe2 = 2,
139 Pipe3 = 3,
140 Pipe4 = 4,
141 Pipe5 = 5,
142 NotUsed = 0b110,
143 RxFifoEmpty = 0b111,
144}
145impl const EnumField for RxPipeNo {
146 fn into_bits(self) -> u8 {
147 self as _
148 }
149 fn from_bits(bits: u8) -> Self {
150 unsafe { core::mem::transmute(bits & 0b111) }
152 }
153}