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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
#[doc = "Reader of register CTRL"] pub type R = crate::R<u32, super::CTRL>; #[doc = "Writer for register CTRL"] pub type W = crate::W<u32, super::CTRL>; #[doc = "Register CTRL `reset()`'s with value 0"] impl crate::ResetValue for super::CTRL { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `EN`"] pub type EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `EN`"] pub struct EN_W<'a> { w: &'a mut W, } impl<'a> EN_W<'a> { #[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 = "Reader of field `SLAVE`"] pub type SLAVE_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SLAVE`"] pub struct SLAVE_W<'a> { w: &'a mut W, } impl<'a> SLAVE_W<'a> { #[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 << 1)) | (((value as u32) & 0x01) << 1); self.w } } #[doc = "Reader of field `AUTOACK`"] pub type AUTOACK_R = crate::R<bool, bool>; #[doc = "Write proxy for field `AUTOACK`"] pub struct AUTOACK_W<'a> { w: &'a mut W, } impl<'a> AUTOACK_W<'a> { #[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 << 2)) | (((value as u32) & 0x01) << 2); self.w } } #[doc = "Reader of field `AUTOSE`"] pub type AUTOSE_R = crate::R<bool, bool>; #[doc = "Write proxy for field `AUTOSE`"] pub struct AUTOSE_W<'a> { w: &'a mut W, } impl<'a> AUTOSE_W<'a> { #[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 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Reader of field `AUTOSN`"] pub type AUTOSN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `AUTOSN`"] pub struct AUTOSN_W<'a> { w: &'a mut W, } impl<'a> AUTOSN_W<'a> { #[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 << 4)) | (((value as u32) & 0x01) << 4); self.w } } #[doc = "Reader of field `ARBDIS`"] pub type ARBDIS_R = crate::R<bool, bool>; #[doc = "Write proxy for field `ARBDIS`"] pub struct ARBDIS_W<'a> { w: &'a mut W, } impl<'a> ARBDIS_W<'a> { #[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 << 5)) | (((value as u32) & 0x01) << 5); self.w } } #[doc = "Reader of field `GCAMEN`"] pub type GCAMEN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `GCAMEN`"] pub struct GCAMEN_W<'a> { w: &'a mut W, } impl<'a> GCAMEN_W<'a> { #[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 << 6)) | (((value as u32) & 0x01) << 6); self.w } } #[doc = "Reader of field `TXBIL`"] pub type TXBIL_R = crate::R<bool, bool>; #[doc = "Write proxy for field `TXBIL`"] pub struct TXBIL_W<'a> { w: &'a mut W, } impl<'a> TXBIL_W<'a> { #[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 << 7)) | (((value as u32) & 0x01) << 7); self.w } } #[doc = "Clock Low High Ratio\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u8)] pub enum CLHR_A { #[doc = "0: The ratio between low period and high period counters (Nlow:Nhigh) is 4:4"] STANDARD = 0, #[doc = "1: The ratio between low period and high period counters (Nlow:Nhigh) is 6:3"] ASYMMETRIC = 1, #[doc = "2: The ratio between low period and high period counters (Nlow:Nhigh) is 11:6"] FAST = 2, } impl From<CLHR_A> for u8 { #[inline(always)] fn from(variant: CLHR_A) -> Self { variant as _ } } #[doc = "Reader of field `CLHR`"] pub type CLHR_R = crate::R<u8, CLHR_A>; impl CLHR_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::Variant<u8, CLHR_A> { use crate::Variant::*; match self.bits { 0 => Val(CLHR_A::STANDARD), 1 => Val(CLHR_A::ASYMMETRIC), 2 => Val(CLHR_A::FAST), i => Res(i), } } #[doc = "Checks if the value of the field is `STANDARD`"] #[inline(always)] pub fn is_standard(&self) -> bool { *self == CLHR_A::STANDARD } #[doc = "Checks if the value of the field is `ASYMMETRIC`"] #[inline(always)] pub fn is_asymmetric(&self) -> bool { *self == CLHR_A::ASYMMETRIC } #[doc = "Checks if the value of the field is `FAST`"] #[inline(always)] pub fn is_fast(&self) -> bool { *self == CLHR_A::FAST } } #[doc = "Write proxy for field `CLHR`"] pub struct CLHR_W<'a> { w: &'a mut W, } impl<'a> CLHR_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: CLHR_A) -> &'a mut W { unsafe { self.bits(variant.into()) } } #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 4:4"] #[inline(always)] pub fn standard(self) -> &'a mut W { self.variant(CLHR_A::STANDARD) } #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 6:3"] #[inline(always)] pub fn asymmetric(self) -> &'a mut W { self.variant(CLHR_A::ASYMMETRIC) } #[doc = "The ratio between low period and high period counters (Nlow:Nhigh) is 11:6"] #[inline(always)] pub fn fast(self) -> &'a mut W { self.variant(CLHR_A::FAST) } #[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 & !(0x03 << 8)) | (((value as u32) & 0x03) << 8); self.w } } #[doc = "Bus Idle Timeout\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u8)] pub enum BITO_A { #[doc = "0: Timeout disabled"] OFF = 0, #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."] _40PCC = 1, #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."] _80PCC = 2, #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."] _160PCC = 3, } impl From<BITO_A> for u8 { #[inline(always)] fn from(variant: BITO_A) -> Self { variant as _ } } #[doc = "Reader of field `BITO`"] pub type BITO_R = crate::R<u8, BITO_A>; impl BITO_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> BITO_A { match self.bits { 0 => BITO_A::OFF, 1 => BITO_A::_40PCC, 2 => BITO_A::_80PCC, 3 => BITO_A::_160PCC, _ => unreachable!(), } } #[doc = "Checks if the value of the field is `OFF`"] #[inline(always)] pub fn is_off(&self) -> bool { *self == BITO_A::OFF } #[doc = "Checks if the value of the field is `_40PCC`"] #[inline(always)] pub fn is_40pcc(&self) -> bool { *self == BITO_A::_40PCC } #[doc = "Checks if the value of the field is `_80PCC`"] #[inline(always)] pub fn is_80pcc(&self) -> bool { *self == BITO_A::_80PCC } #[doc = "Checks if the value of the field is `_160PCC`"] #[inline(always)] pub fn is_160pcc(&self) -> bool { *self == BITO_A::_160PCC } } #[doc = "Write proxy for field `BITO`"] pub struct BITO_W<'a> { w: &'a mut W, } impl<'a> BITO_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: BITO_A) -> &'a mut W { { self.bits(variant.into()) } } #[doc = "Timeout disabled"] #[inline(always)] pub fn off(self) -> &'a mut W { self.variant(BITO_A::OFF) } #[doc = "Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."] #[inline(always)] pub fn _40pcc(self) -> &'a mut W { self.variant(BITO_A::_40PCC) } #[doc = "Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."] #[inline(always)] pub fn _80pcc(self) -> &'a mut W { self.variant(BITO_A::_80PCC) } #[doc = "Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."] #[inline(always)] pub fn _160pcc(self) -> &'a mut W { self.variant(BITO_A::_160PCC) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !(0x03 << 12)) | (((value as u32) & 0x03) << 12); self.w } } #[doc = "Reader of field `GIBITO`"] pub type GIBITO_R = crate::R<bool, bool>; #[doc = "Write proxy for field `GIBITO`"] pub struct GIBITO_W<'a> { w: &'a mut W, } impl<'a> GIBITO_W<'a> { #[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 << 15)) | (((value as u32) & 0x01) << 15); self.w } } #[doc = "Clock Low Timeout\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u8)] pub enum CLTO_A { #[doc = "0: Timeout disabled"] OFF = 0, #[doc = "1: Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."] _40PCC = 1, #[doc = "2: Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."] _80PCC = 2, #[doc = "3: Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."] _160PCC = 3, #[doc = "4: Timeout after 320 prescaled clock cycles. In standard mode at 100 kHz, this results in a 400us timeout."] _320PCC = 4, #[doc = "5: Timeout after 1024 prescaled clock cycles. In standard mode at 100 kHz, this results in a 1280us timeout."] _1024PCC = 5, } impl From<CLTO_A> for u8 { #[inline(always)] fn from(variant: CLTO_A) -> Self { variant as _ } } #[doc = "Reader of field `CLTO`"] pub type CLTO_R = crate::R<u8, CLTO_A>; impl CLTO_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::Variant<u8, CLTO_A> { use crate::Variant::*; match self.bits { 0 => Val(CLTO_A::OFF), 1 => Val(CLTO_A::_40PCC), 2 => Val(CLTO_A::_80PCC), 3 => Val(CLTO_A::_160PCC), 4 => Val(CLTO_A::_320PCC), 5 => Val(CLTO_A::_1024PCC), i => Res(i), } } #[doc = "Checks if the value of the field is `OFF`"] #[inline(always)] pub fn is_off(&self) -> bool { *self == CLTO_A::OFF } #[doc = "Checks if the value of the field is `_40PCC`"] #[inline(always)] pub fn is_40pcc(&self) -> bool { *self == CLTO_A::_40PCC } #[doc = "Checks if the value of the field is `_80PCC`"] #[inline(always)] pub fn is_80pcc(&self) -> bool { *self == CLTO_A::_80PCC } #[doc = "Checks if the value of the field is `_160PCC`"] #[inline(always)] pub fn is_160pcc(&self) -> bool { *self == CLTO_A::_160PCC } #[doc = "Checks if the value of the field is `_320PCC`"] #[inline(always)] pub fn is_320pcc(&self) -> bool { *self == CLTO_A::_320PCC } #[doc = "Checks if the value of the field is `_1024PCC`"] #[inline(always)] pub fn is_1024pcc(&self) -> bool { *self == CLTO_A::_1024PCC } } #[doc = "Write proxy for field `CLTO`"] pub struct CLTO_W<'a> { w: &'a mut W, } impl<'a> CLTO_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: CLTO_A) -> &'a mut W { unsafe { self.bits(variant.into()) } } #[doc = "Timeout disabled"] #[inline(always)] pub fn off(self) -> &'a mut W { self.variant(CLTO_A::OFF) } #[doc = "Timeout after 40 prescaled clock cycles. In standard mode at 100 kHz, this results in a 50us timeout."] #[inline(always)] pub fn _40pcc(self) -> &'a mut W { self.variant(CLTO_A::_40PCC) } #[doc = "Timeout after 80 prescaled clock cycles. In standard mode at 100 kHz, this results in a 100us timeout."] #[inline(always)] pub fn _80pcc(self) -> &'a mut W { self.variant(CLTO_A::_80PCC) } #[doc = "Timeout after 160 prescaled clock cycles. In standard mode at 100 kHz, this results in a 200us timeout."] #[inline(always)] pub fn _160pcc(self) -> &'a mut W { self.variant(CLTO_A::_160PCC) } #[doc = "Timeout after 320 prescaled clock cycles. In standard mode at 100 kHz, this results in a 400us timeout."] #[inline(always)] pub fn _320pcc(self) -> &'a mut W { self.variant(CLTO_A::_320PCC) } #[doc = "Timeout after 1024 prescaled clock cycles. In standard mode at 100 kHz, this results in a 1280us timeout."] #[inline(always)] pub fn _1024pcc(self) -> &'a mut W { self.variant(CLTO_A::_1024PCC) } #[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 & !(0x07 << 16)) | (((value as u32) & 0x07) << 16); self.w } } impl R { #[doc = "Bit 0 - I2C Enable"] #[inline(always)] pub fn en(&self) -> EN_R { EN_R::new((self.bits & 0x01) != 0) } #[doc = "Bit 1 - Addressable as Slave"] #[inline(always)] pub fn slave(&self) -> SLAVE_R { SLAVE_R::new(((self.bits >> 1) & 0x01) != 0) } #[doc = "Bit 2 - Automatic Acknowledge"] #[inline(always)] pub fn autoack(&self) -> AUTOACK_R { AUTOACK_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - Automatic STOP When Empty"] #[inline(always)] pub fn autose(&self) -> AUTOSE_R { AUTOSE_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bit 4 - Automatic STOP on NACK"] #[inline(always)] pub fn autosn(&self) -> AUTOSN_R { AUTOSN_R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 5 - Arbitration Disable"] #[inline(always)] pub fn arbdis(&self) -> ARBDIS_R { ARBDIS_R::new(((self.bits >> 5) & 0x01) != 0) } #[doc = "Bit 6 - General Call Address Match Enable"] #[inline(always)] pub fn gcamen(&self) -> GCAMEN_R { GCAMEN_R::new(((self.bits >> 6) & 0x01) != 0) } #[doc = "Bit 7 - TX Buffer Interrupt Level"] #[inline(always)] pub fn txbil(&self) -> TXBIL_R { TXBIL_R::new(((self.bits >> 7) & 0x01) != 0) } #[doc = "Bits 8:9 - Clock Low High Ratio"] #[inline(always)] pub fn clhr(&self) -> CLHR_R { CLHR_R::new(((self.bits >> 8) & 0x03) as u8) } #[doc = "Bits 12:13 - Bus Idle Timeout"] #[inline(always)] pub fn bito(&self) -> BITO_R { BITO_R::new(((self.bits >> 12) & 0x03) as u8) } #[doc = "Bit 15 - Go Idle on Bus Idle Timeout"] #[inline(always)] pub fn gibito(&self) -> GIBITO_R { GIBITO_R::new(((self.bits >> 15) & 0x01) != 0) } #[doc = "Bits 16:18 - Clock Low Timeout"] #[inline(always)] pub fn clto(&self) -> CLTO_R { CLTO_R::new(((self.bits >> 16) & 0x07) as u8) } } impl W { #[doc = "Bit 0 - I2C Enable"] #[inline(always)] pub fn en(&mut self) -> EN_W { EN_W { w: self } } #[doc = "Bit 1 - Addressable as Slave"] #[inline(always)] pub fn slave(&mut self) -> SLAVE_W { SLAVE_W { w: self } } #[doc = "Bit 2 - Automatic Acknowledge"] #[inline(always)] pub fn autoack(&mut self) -> AUTOACK_W { AUTOACK_W { w: self } } #[doc = "Bit 3 - Automatic STOP When Empty"] #[inline(always)] pub fn autose(&mut self) -> AUTOSE_W { AUTOSE_W { w: self } } #[doc = "Bit 4 - Automatic STOP on NACK"] #[inline(always)] pub fn autosn(&mut self) -> AUTOSN_W { AUTOSN_W { w: self } } #[doc = "Bit 5 - Arbitration Disable"] #[inline(always)] pub fn arbdis(&mut self) -> ARBDIS_W { ARBDIS_W { w: self } } #[doc = "Bit 6 - General Call Address Match Enable"] #[inline(always)] pub fn gcamen(&mut self) -> GCAMEN_W { GCAMEN_W { w: self } } #[doc = "Bit 7 - TX Buffer Interrupt Level"] #[inline(always)] pub fn txbil(&mut self) -> TXBIL_W { TXBIL_W { w: self } } #[doc = "Bits 8:9 - Clock Low High Ratio"] #[inline(always)] pub fn clhr(&mut self) -> CLHR_W { CLHR_W { w: self } } #[doc = "Bits 12:13 - Bus Idle Timeout"] #[inline(always)] pub fn bito(&mut self) -> BITO_W { BITO_W { w: self } } #[doc = "Bit 15 - Go Idle on Bus Idle Timeout"] #[inline(always)] pub fn gibito(&mut self) -> GIBITO_W { GIBITO_W { w: self } } #[doc = "Bits 16:18 - Clock Low Timeout"] #[inline(always)] pub fn clto(&mut self) -> CLTO_W { CLTO_W { w: self } } }