#![no_std] pub type Instance = ral_registers::Instance; #[allow(non_snake_case)] #[repr(C)] pub struct RegisterBlock { pub CS: u32, pub CNT: u32, pub TOVAL: u32, pub WIN: u32, } /// Written to `CNT` during the unlock sequence. pub const RTWDOG_MAGIC: u32 = 0xD928_C520; ral_registers::register! { #[doc = "Watchdog Control and Status Register"] pub CS RW [ #[doc = "Stop Enable"] STOP start(0) width(1) RW {} #[doc = "Wait Enable"] WAIT start(1) width(1) RW {} #[doc = "Debug Enable"] DBG start(2) width(1) RW {} #[doc = "Watchdog Test"] TST start(3) width(2) RW { #[doc = "Watchdog test mode disabled."] DISABLED = 0, #[doc = "Watchdog user mode enabled. (Watchdog test mode disabled.) After testing the watchdog, software should use this setting to indicate that the watchdog is functioning normally in user mode."] USER_MODE = 0x1, #[doc = "Watchdog test mode enabled, only the low byte is used. CNT[CNTLOW] is compared with TOVAL[TOVALLOW]."] TEST_LOW_BYTE_ONLY = 0x2, #[doc = "Watchdog test mode enabled, only the high byte is used. CNT[CNTHIGH] is compared with TOVAL[TOVALHIGH]."] TEST_HIGH_BYTE_ONLY = 0x3, } #[doc = "Allow updates"] UPDATE start(5) width(1) RW {} #[doc = "Watchdog Interrupt"] INT start(6) width(1) RW {} #[doc = "Watchdog Enable"] EN start(7) width(1) RW {} #[doc = "Watchdog Clock"] CLK start(8) width(2) RW {} #[doc = "Reconfiguration Success"] RCS start(10) width(1) RO {} #[doc = "Unlock status"] ULK start(11) width(1) RO {} #[doc = "Watchdog prescaler"] PRES start(12) width(1) RW {} #[doc = "Enables or disables WDOG support for 32-bit (otherwise 16-bit or 8-bit) refresh/unlock command write words"] CMD32EN start(13) width(1) RW {} #[doc = "Watchdog Interrupt Flag"] FLG start(14) width(1) RW {} #[doc = "Watchdog Window"] WIN start(15) width(1) RW {} ] } ral_registers::register! { #[doc = "Watchdog Counter Register"] pub CNT RW [ #[doc = "Low byte of the Watchdog Counter"] CNTLOW start(0) width(8) RW {} #[doc = "High byte of the Watchdog Counter"] CNTHIGH start(8) width(8) RW {} ] } ral_registers::register! { #[doc = "Watchdog Timeout Value Register"] pub TOVAL RW [ #[doc = "Low byte of the timeout value"] TOVALLOW start(0) width(8) RW {} #[doc = "High byte of the timeout value"] TOVALHIGH start(8) width(8) RW {} ] } ral_registers::register! { #[doc = "Watchdog Window Register"] pub WIN RW [ #[doc = "Low byte of Watchdog Window"] WINLOW start(0) width(8) RW {} #[doc = "High byte of Watchdog Window"] WINHIGH start(8) width(8) RW {} ] } /// Unlike and disable the RTWDOG. #[inline] pub fn disable(rtwdog: Instance) { ral_registers::write_reg!(self, rtwdog, CNT, RTWDOG_MAGIC); ral_registers::modify_reg!(self, rtwdog, CS, EN: 0); }