Skip to main content

nrf52/radio/state/
mod.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5impl super::STATE {
6    #[doc = r" Reads the contents of the register"]
7    #[inline]
8    pub fn read(&self) -> R {
9        R {
10            bits: self.register.get(),
11        }
12    }
13}
14#[doc = "Possible values of the field `STATE`"]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub enum STATER {
17    #[doc = "RADIO is in the Disabled state"]
18    DISABLED,
19    #[doc = "RADIO is in the RXRU state"]
20    RXRU,
21    #[doc = "RADIO is in the RXIDLE state"]
22    RXIDLE,
23    #[doc = "RADIO is in the RX state"]
24    RX,
25    #[doc = "RADIO is in the RXDISABLED state"]
26    RXDISABLE,
27    #[doc = "RADIO is in the TXRU state"]
28    TXRU,
29    #[doc = "RADIO is in the TXIDLE state"]
30    TXIDLE,
31    #[doc = "RADIO is in the TX state"]
32    TX,
33    #[doc = "RADIO is in the TXDISABLED state"]
34    TXDISABLE,
35    #[doc = r" Reserved"]
36    _Reserved(u8),
37}
38impl STATER {
39    #[doc = r" Value of the field as raw bits"]
40    #[inline]
41    pub fn bits(&self) -> u8 {
42        match *self {
43            STATER::DISABLED => 0,
44            STATER::RXRU => 1,
45            STATER::RXIDLE => 2,
46            STATER::RX => 3,
47            STATER::RXDISABLE => 4,
48            STATER::TXRU => 9,
49            STATER::TXIDLE => 10,
50            STATER::TX => 11,
51            STATER::TXDISABLE => 12,
52            STATER::_Reserved(bits) => bits,
53        }
54    }
55    #[allow(missing_docs)]
56    #[doc(hidden)]
57    #[inline]
58    pub fn _from(value: u8) -> STATER {
59        match value {
60            0 => STATER::DISABLED,
61            1 => STATER::RXRU,
62            2 => STATER::RXIDLE,
63            3 => STATER::RX,
64            4 => STATER::RXDISABLE,
65            9 => STATER::TXRU,
66            10 => STATER::TXIDLE,
67            11 => STATER::TX,
68            12 => STATER::TXDISABLE,
69            i => STATER::_Reserved(i),
70        }
71    }
72    #[doc = "Checks if the value of the field is `DISABLED`"]
73    #[inline]
74    pub fn is_disabled(&self) -> bool {
75        *self == STATER::DISABLED
76    }
77    #[doc = "Checks if the value of the field is `RXRU`"]
78    #[inline]
79    pub fn is_rx_ru(&self) -> bool {
80        *self == STATER::RXRU
81    }
82    #[doc = "Checks if the value of the field is `RXIDLE`"]
83    #[inline]
84    pub fn is_rx_idle(&self) -> bool {
85        *self == STATER::RXIDLE
86    }
87    #[doc = "Checks if the value of the field is `RX`"]
88    #[inline]
89    pub fn is_rx(&self) -> bool {
90        *self == STATER::RX
91    }
92    #[doc = "Checks if the value of the field is `RXDISABLE`"]
93    #[inline]
94    pub fn is_rx_disable(&self) -> bool {
95        *self == STATER::RXDISABLE
96    }
97    #[doc = "Checks if the value of the field is `TXRU`"]
98    #[inline]
99    pub fn is_tx_ru(&self) -> bool {
100        *self == STATER::TXRU
101    }
102    #[doc = "Checks if the value of the field is `TXIDLE`"]
103    #[inline]
104    pub fn is_tx_idle(&self) -> bool {
105        *self == STATER::TXIDLE
106    }
107    #[doc = "Checks if the value of the field is `TX`"]
108    #[inline]
109    pub fn is_tx(&self) -> bool {
110        *self == STATER::TX
111    }
112    #[doc = "Checks if the value of the field is `TXDISABLE`"]
113    #[inline]
114    pub fn is_tx_disable(&self) -> bool {
115        *self == STATER::TXDISABLE
116    }
117}
118impl R {
119    #[doc = r" Value of the register as raw bits"]
120    #[inline]
121    pub fn bits(&self) -> u32 {
122        self.bits
123    }
124    #[doc = "Bits 0:3 - Current radio state"]
125    #[inline]
126    pub fn state(&self) -> STATER {
127        STATER::_from({
128            const MASK: u8 = 15;
129            const OFFSET: u8 = 0;
130            ((self.bits >> OFFSET) & MASK as u32) as u8
131        })
132    }
133}