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
use crate::generic::*; #[doc = "RTC register 0 Read this before RTC 1!"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Rtc0(pub u32); impl Rtc0 { #[doc = "Day of the week"] pub const fn dotw(&self) -> u8 { let val = (self.0 >> 24u32) & 0x07; val as u8 } #[doc = "Day of the week"] pub fn set_dotw(&mut self, val: u8) { self.0 = (self.0 & !(0x07 << 24u32)) | (((val as u32) & 0x07) << 24u32); } #[doc = "Hours"] pub const fn hour(&self) -> u8 { let val = (self.0 >> 16u32) & 0x1f; val as u8 } #[doc = "Hours"] pub fn set_hour(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 16u32)) | (((val as u32) & 0x1f) << 16u32); } #[doc = "Minutes"] pub const fn min(&self) -> u8 { let val = (self.0 >> 8u32) & 0x3f; val as u8 } #[doc = "Minutes"] pub fn set_min(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 8u32)) | (((val as u32) & 0x3f) << 8u32); } #[doc = "Seconds"] pub const fn sec(&self) -> u8 { let val = (self.0 >> 0u32) & 0x3f; val as u8 } #[doc = "Seconds"] pub fn set_sec(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 0u32)) | (((val as u32) & 0x3f) << 0u32); } } impl Default for Rtc0 { fn default() -> Rtc0 { Rtc0(0) } } #[doc = "Interrupt setup register 1"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct IrqSetup1(pub u32); impl IrqSetup1 { #[doc = "Enable day of the week matching"] pub const fn dotw_ena(&self) -> bool { let val = (self.0 >> 31u32) & 0x01; val != 0 } #[doc = "Enable day of the week matching"] pub fn set_dotw_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 31u32)) | (((val as u32) & 0x01) << 31u32); } #[doc = "Enable hour matching"] pub const fn hour_ena(&self) -> bool { let val = (self.0 >> 30u32) & 0x01; val != 0 } #[doc = "Enable hour matching"] pub fn set_hour_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 30u32)) | (((val as u32) & 0x01) << 30u32); } #[doc = "Enable minute matching"] pub const fn min_ena(&self) -> bool { let val = (self.0 >> 29u32) & 0x01; val != 0 } #[doc = "Enable minute matching"] pub fn set_min_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 29u32)) | (((val as u32) & 0x01) << 29u32); } #[doc = "Enable second matching"] pub const fn sec_ena(&self) -> bool { let val = (self.0 >> 28u32) & 0x01; val != 0 } #[doc = "Enable second matching"] pub fn set_sec_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 28u32)) | (((val as u32) & 0x01) << 28u32); } #[doc = "Day of the week"] pub const fn dotw(&self) -> u8 { let val = (self.0 >> 24u32) & 0x07; val as u8 } #[doc = "Day of the week"] pub fn set_dotw(&mut self, val: u8) { self.0 = (self.0 & !(0x07 << 24u32)) | (((val as u32) & 0x07) << 24u32); } #[doc = "Hours"] pub const fn hour(&self) -> u8 { let val = (self.0 >> 16u32) & 0x1f; val as u8 } #[doc = "Hours"] pub fn set_hour(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 16u32)) | (((val as u32) & 0x1f) << 16u32); } #[doc = "Minutes"] pub const fn min(&self) -> u8 { let val = (self.0 >> 8u32) & 0x3f; val as u8 } #[doc = "Minutes"] pub fn set_min(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 8u32)) | (((val as u32) & 0x3f) << 8u32); } #[doc = "Seconds"] pub const fn sec(&self) -> u8 { let val = (self.0 >> 0u32) & 0x3f; val as u8 } #[doc = "Seconds"] pub fn set_sec(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 0u32)) | (((val as u32) & 0x3f) << 0u32); } } impl Default for IrqSetup1 { fn default() -> IrqSetup1 { IrqSetup1(0) } } #[doc = "Interrupt Enable"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Int(pub u32); impl Int { pub const fn rtc(&self) -> bool { let val = (self.0 >> 0u32) & 0x01; val != 0 } pub fn set_rtc(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 0u32)) | (((val as u32) & 0x01) << 0u32); } } impl Default for Int { fn default() -> Int { Int(0) } } #[doc = "RTC Control and status"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Ctrl(pub u32); impl Ctrl { #[doc = "If set, leapyear is forced off. Useful for years divisible by 100 but not by 400"] pub const fn force_notleapyear(&self) -> bool { let val = (self.0 >> 8u32) & 0x01; val != 0 } #[doc = "If set, leapyear is forced off. Useful for years divisible by 100 but not by 400"] pub fn set_force_notleapyear(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 8u32)) | (((val as u32) & 0x01) << 8u32); } #[doc = "Load RTC"] pub const fn load(&self) -> bool { let val = (self.0 >> 4u32) & 0x01; val != 0 } #[doc = "Load RTC"] pub fn set_load(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 4u32)) | (((val as u32) & 0x01) << 4u32); } #[doc = "RTC enabled (running)"] pub const fn rtc_active(&self) -> bool { let val = (self.0 >> 1u32) & 0x01; val != 0 } #[doc = "RTC enabled (running)"] pub fn set_rtc_active(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 1u32)) | (((val as u32) & 0x01) << 1u32); } #[doc = "Enable RTC"] pub const fn rtc_enable(&self) -> bool { let val = (self.0 >> 0u32) & 0x01; val != 0 } #[doc = "Enable RTC"] pub fn set_rtc_enable(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 0u32)) | (((val as u32) & 0x01) << 0u32); } } impl Default for Ctrl { fn default() -> Ctrl { Ctrl(0) } } #[doc = "RTC setup register 1"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Setup1(pub u32); impl Setup1 { #[doc = "Day of the week: 1-Monday...0-Sunday ISO 8601 mod 7"] pub const fn dotw(&self) -> u8 { let val = (self.0 >> 24u32) & 0x07; val as u8 } #[doc = "Day of the week: 1-Monday...0-Sunday ISO 8601 mod 7"] pub fn set_dotw(&mut self, val: u8) { self.0 = (self.0 & !(0x07 << 24u32)) | (((val as u32) & 0x07) << 24u32); } #[doc = "Hours"] pub const fn hour(&self) -> u8 { let val = (self.0 >> 16u32) & 0x1f; val as u8 } #[doc = "Hours"] pub fn set_hour(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 16u32)) | (((val as u32) & 0x1f) << 16u32); } #[doc = "Minutes"] pub const fn min(&self) -> u8 { let val = (self.0 >> 8u32) & 0x3f; val as u8 } #[doc = "Minutes"] pub fn set_min(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 8u32)) | (((val as u32) & 0x3f) << 8u32); } #[doc = "Seconds"] pub const fn sec(&self) -> u8 { let val = (self.0 >> 0u32) & 0x3f; val as u8 } #[doc = "Seconds"] pub fn set_sec(&mut self, val: u8) { self.0 = (self.0 & !(0x3f << 0u32)) | (((val as u32) & 0x3f) << 0u32); } } impl Default for Setup1 { fn default() -> Setup1 { Setup1(0) } } #[doc = "Divider minus 1 for the 1 second counter. Safe to change the value when RTC is not enabled."] #[repr(transparent)] #[derive(Copy, Clone)] pub struct ClkdivM1(pub u32); impl ClkdivM1 { pub const fn clkdiv_m1(&self) -> u16 { let val = (self.0 >> 0u32) & 0xffff; val as u16 } pub fn set_clkdiv_m1(&mut self, val: u16) { self.0 = (self.0 & !(0xffff << 0u32)) | (((val as u32) & 0xffff) << 0u32); } } impl Default for ClkdivM1 { fn default() -> ClkdivM1 { ClkdivM1(0) } } #[doc = "RTC register 1."] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Rtc1(pub u32); impl Rtc1 { #[doc = "Year"] pub const fn year(&self) -> u16 { let val = (self.0 >> 12u32) & 0x0fff; val as u16 } #[doc = "Year"] pub fn set_year(&mut self, val: u16) { self.0 = (self.0 & !(0x0fff << 12u32)) | (((val as u32) & 0x0fff) << 12u32); } #[doc = "Month (1..12)"] pub const fn month(&self) -> u8 { let val = (self.0 >> 8u32) & 0x0f; val as u8 } #[doc = "Month (1..12)"] pub fn set_month(&mut self, val: u8) { self.0 = (self.0 & !(0x0f << 8u32)) | (((val as u32) & 0x0f) << 8u32); } #[doc = "Day of the month (1..31)"] pub const fn day(&self) -> u8 { let val = (self.0 >> 0u32) & 0x1f; val as u8 } #[doc = "Day of the month (1..31)"] pub fn set_day(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 0u32)) | (((val as u32) & 0x1f) << 0u32); } } impl Default for Rtc1 { fn default() -> Rtc1 { Rtc1(0) } } #[doc = "Interrupt setup register 0"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct IrqSetup0(pub u32); impl IrqSetup0 { pub const fn match_active(&self) -> bool { let val = (self.0 >> 29u32) & 0x01; val != 0 } pub fn set_match_active(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 29u32)) | (((val as u32) & 0x01) << 29u32); } #[doc = "Global match enable. Don't change any other value while this one is enabled"] pub const fn match_ena(&self) -> bool { let val = (self.0 >> 28u32) & 0x01; val != 0 } #[doc = "Global match enable. Don't change any other value while this one is enabled"] pub fn set_match_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 28u32)) | (((val as u32) & 0x01) << 28u32); } #[doc = "Enable year matching"] pub const fn year_ena(&self) -> bool { let val = (self.0 >> 26u32) & 0x01; val != 0 } #[doc = "Enable year matching"] pub fn set_year_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 26u32)) | (((val as u32) & 0x01) << 26u32); } #[doc = "Enable month matching"] pub const fn month_ena(&self) -> bool { let val = (self.0 >> 25u32) & 0x01; val != 0 } #[doc = "Enable month matching"] pub fn set_month_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 25u32)) | (((val as u32) & 0x01) << 25u32); } #[doc = "Enable day matching"] pub const fn day_ena(&self) -> bool { let val = (self.0 >> 24u32) & 0x01; val != 0 } #[doc = "Enable day matching"] pub fn set_day_ena(&mut self, val: bool) { self.0 = (self.0 & !(0x01 << 24u32)) | (((val as u32) & 0x01) << 24u32); } #[doc = "Year"] pub const fn year(&self) -> u16 { let val = (self.0 >> 12u32) & 0x0fff; val as u16 } #[doc = "Year"] pub fn set_year(&mut self, val: u16) { self.0 = (self.0 & !(0x0fff << 12u32)) | (((val as u32) & 0x0fff) << 12u32); } #[doc = "Month (1..12)"] pub const fn month(&self) -> u8 { let val = (self.0 >> 8u32) & 0x0f; val as u8 } #[doc = "Month (1..12)"] pub fn set_month(&mut self, val: u8) { self.0 = (self.0 & !(0x0f << 8u32)) | (((val as u32) & 0x0f) << 8u32); } #[doc = "Day of the month (1..31)"] pub const fn day(&self) -> u8 { let val = (self.0 >> 0u32) & 0x1f; val as u8 } #[doc = "Day of the month (1..31)"] pub fn set_day(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 0u32)) | (((val as u32) & 0x1f) << 0u32); } } impl Default for IrqSetup0 { fn default() -> IrqSetup0 { IrqSetup0(0) } } #[doc = "RTC setup register 0"] #[repr(transparent)] #[derive(Copy, Clone)] pub struct Setup0(pub u32); impl Setup0 { #[doc = "Year"] pub const fn year(&self) -> u16 { let val = (self.0 >> 12u32) & 0x0fff; val as u16 } #[doc = "Year"] pub fn set_year(&mut self, val: u16) { self.0 = (self.0 & !(0x0fff << 12u32)) | (((val as u32) & 0x0fff) << 12u32); } #[doc = "Month (1..12)"] pub const fn month(&self) -> u8 { let val = (self.0 >> 8u32) & 0x0f; val as u8 } #[doc = "Month (1..12)"] pub fn set_month(&mut self, val: u8) { self.0 = (self.0 & !(0x0f << 8u32)) | (((val as u32) & 0x0f) << 8u32); } #[doc = "Day of the month (1..31)"] pub const fn day(&self) -> u8 { let val = (self.0 >> 0u32) & 0x1f; val as u8 } #[doc = "Day of the month (1..31)"] pub fn set_day(&mut self, val: u8) { self.0 = (self.0 & !(0x1f << 0u32)) | (((val as u32) & 0x1f) << 0u32); } } impl Default for Setup0 { fn default() -> Setup0 { Setup0(0) } }