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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
#[doc = "Reader of register POFCON"] pub type R = crate::R<u32, super::POFCON>; #[doc = "Writer for register POFCON"] pub type W = crate::W<u32, super::POFCON>; #[doc = "Register POFCON `reset()`'s with value 0"] impl crate::ResetValue for super::POFCON { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Enable or disable power failure comparator\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum POF_A { #[doc = "0: Disable"] DISABLED, #[doc = "1: Enable"] ENABLED, } impl From<POF_A> for bool { #[inline(always)] fn from(variant: POF_A) -> Self { match variant { POF_A::DISABLED => false, POF_A::ENABLED => true, } } } #[doc = "Reader of field `POF`"] pub type POF_R = crate::R<bool, POF_A>; impl POF_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> POF_A { match self.bits { false => POF_A::DISABLED, true => POF_A::ENABLED, } } #[doc = "Checks if the value of the field is `DISABLED`"] #[inline(always)] pub fn is_disabled(&self) -> bool { *self == POF_A::DISABLED } #[doc = "Checks if the value of the field is `ENABLED`"] #[inline(always)] pub fn is_enabled(&self) -> bool { *self == POF_A::ENABLED } } #[doc = "Write proxy for field `POF`"] pub struct POF_W<'a> { w: &'a mut W, } impl<'a> POF_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: POF_A) -> &'a mut W { { self.bit(variant.into()) } } #[doc = "Disable"] #[inline(always)] pub fn disabled(self) -> &'a mut W { self.variant(POF_A::DISABLED) } #[doc = "Enable"] #[inline(always)] pub fn enabled(self) -> &'a mut W { self.variant(POF_A::ENABLED) } #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); self.w } } #[doc = "Power failure comparator threshold setting\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum THRESHOLD_A { #[doc = "4: Set threshold to 1.7 V"] V17, #[doc = "5: Set threshold to 1.8 V"] V18, #[doc = "6: Set threshold to 1.9 V"] V19, #[doc = "7: Set threshold to 2.0 V"] V20, #[doc = "8: Set threshold to 2.1 V"] V21, #[doc = "9: Set threshold to 2.2 V"] V22, #[doc = "10: Set threshold to 2.3 V"] V23, #[doc = "11: Set threshold to 2.4 V"] V24, #[doc = "12: Set threshold to 2.5 V"] V25, #[doc = "13: Set threshold to 2.6 V"] V26, #[doc = "14: Set threshold to 2.7 V"] V27, #[doc = "15: Set threshold to 2.8 V"] V28, } impl From<THRESHOLD_A> for u8 { #[inline(always)] fn from(variant: THRESHOLD_A) -> Self { match variant { THRESHOLD_A::V17 => 4, THRESHOLD_A::V18 => 5, THRESHOLD_A::V19 => 6, THRESHOLD_A::V20 => 7, THRESHOLD_A::V21 => 8, THRESHOLD_A::V22 => 9, THRESHOLD_A::V23 => 10, THRESHOLD_A::V24 => 11, THRESHOLD_A::V25 => 12, THRESHOLD_A::V26 => 13, THRESHOLD_A::V27 => 14, THRESHOLD_A::V28 => 15, } } } #[doc = "Reader of field `THRESHOLD`"] pub type THRESHOLD_R = crate::R<u8, THRESHOLD_A>; impl THRESHOLD_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::Variant<u8, THRESHOLD_A> { use crate::Variant::*; match self.bits { 4 => Val(THRESHOLD_A::V17), 5 => Val(THRESHOLD_A::V18), 6 => Val(THRESHOLD_A::V19), 7 => Val(THRESHOLD_A::V20), 8 => Val(THRESHOLD_A::V21), 9 => Val(THRESHOLD_A::V22), 10 => Val(THRESHOLD_A::V23), 11 => Val(THRESHOLD_A::V24), 12 => Val(THRESHOLD_A::V25), 13 => Val(THRESHOLD_A::V26), 14 => Val(THRESHOLD_A::V27), 15 => Val(THRESHOLD_A::V28), i => Res(i), } } #[doc = "Checks if the value of the field is `V17`"] #[inline(always)] pub fn is_v17(&self) -> bool { *self == THRESHOLD_A::V17 } #[doc = "Checks if the value of the field is `V18`"] #[inline(always)] pub fn is_v18(&self) -> bool { *self == THRESHOLD_A::V18 } #[doc = "Checks if the value of the field is `V19`"] #[inline(always)] pub fn is_v19(&self) -> bool { *self == THRESHOLD_A::V19 } #[doc = "Checks if the value of the field is `V20`"] #[inline(always)] pub fn is_v20(&self) -> bool { *self == THRESHOLD_A::V20 } #[doc = "Checks if the value of the field is `V21`"] #[inline(always)] pub fn is_v21(&self) -> bool { *self == THRESHOLD_A::V21 } #[doc = "Checks if the value of the field is `V22`"] #[inline(always)] pub fn is_v22(&self) -> bool { *self == THRESHOLD_A::V22 } #[doc = "Checks if the value of the field is `V23`"] #[inline(always)] pub fn is_v23(&self) -> bool { *self == THRESHOLD_A::V23 } #[doc = "Checks if the value of the field is `V24`"] #[inline(always)] pub fn is_v24(&self) -> bool { *self == THRESHOLD_A::V24 } #[doc = "Checks if the value of the field is `V25`"] #[inline(always)] pub fn is_v25(&self) -> bool { *self == THRESHOLD_A::V25 } #[doc = "Checks if the value of the field is `V26`"] #[inline(always)] pub fn is_v26(&self) -> bool { *self == THRESHOLD_A::V26 } #[doc = "Checks if the value of the field is `V27`"] #[inline(always)] pub fn is_v27(&self) -> bool { *self == THRESHOLD_A::V27 } #[doc = "Checks if the value of the field is `V28`"] #[inline(always)] pub fn is_v28(&self) -> bool { *self == THRESHOLD_A::V28 } } #[doc = "Write proxy for field `THRESHOLD`"] pub struct THRESHOLD_W<'a> { w: &'a mut W, } impl<'a> THRESHOLD_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: THRESHOLD_A) -> &'a mut W { unsafe { self.bits(variant.into()) } } #[doc = "Set threshold to 1.7 V"] #[inline(always)] pub fn v17(self) -> &'a mut W { self.variant(THRESHOLD_A::V17) } #[doc = "Set threshold to 1.8 V"] #[inline(always)] pub fn v18(self) -> &'a mut W { self.variant(THRESHOLD_A::V18) } #[doc = "Set threshold to 1.9 V"] #[inline(always)] pub fn v19(self) -> &'a mut W { self.variant(THRESHOLD_A::V19) } #[doc = "Set threshold to 2.0 V"] #[inline(always)] pub fn v20(self) -> &'a mut W { self.variant(THRESHOLD_A::V20) } #[doc = "Set threshold to 2.1 V"] #[inline(always)] pub fn v21(self) -> &'a mut W { self.variant(THRESHOLD_A::V21) } #[doc = "Set threshold to 2.2 V"] #[inline(always)] pub fn v22(self) -> &'a mut W { self.variant(THRESHOLD_A::V22) } #[doc = "Set threshold to 2.3 V"] #[inline(always)] pub fn v23(self) -> &'a mut W { self.variant(THRESHOLD_A::V23) } #[doc = "Set threshold to 2.4 V"] #[inline(always)] pub fn v24(self) -> &'a mut W { self.variant(THRESHOLD_A::V24) } #[doc = "Set threshold to 2.5 V"] #[inline(always)] pub fn v25(self) -> &'a mut W { self.variant(THRESHOLD_A::V25) } #[doc = "Set threshold to 2.6 V"] #[inline(always)] pub fn v26(self) -> &'a mut W { self.variant(THRESHOLD_A::V26) } #[doc = "Set threshold to 2.7 V"] #[inline(always)] pub fn v27(self) -> &'a mut W { self.variant(THRESHOLD_A::V27) } #[doc = "Set threshold to 2.8 V"] #[inline(always)] pub fn v28(self) -> &'a mut W { self.variant(THRESHOLD_A::V28) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !(0x0f << 1)) | (((value as u32) & 0x0f) << 1); self.w } } impl R { #[doc = "Bit 0 - Enable or disable power failure comparator"] #[inline(always)] pub fn pof(&self) -> POF_R { POF_R::new((self.bits & 0x01) != 0) } #[doc = "Bits 1:4 - Power failure comparator threshold setting"] #[inline(always)] pub fn threshold(&self) -> THRESHOLD_R { THRESHOLD_R::new(((self.bits >> 1) & 0x0f) as u8) } } impl W { #[doc = "Bit 0 - Enable or disable power failure comparator"] #[inline(always)] pub fn pof(&mut self) -> POF_W { POF_W { w: self } } #[doc = "Bits 1:4 - Power failure comparator threshold setting"] #[inline(always)] pub fn threshold(&mut self) -> THRESHOLD_W { THRESHOLD_W { w: self } } }