@@ -150,18 +150,17 @@ impl Watchdog {
150150 w
151151 } ) ;
152152 }
153- }
154153
155- impl watchdog:: Watchdog for Watchdog {
156- fn feed ( & mut self ) {
154+ /// Set the watchdog counter back to its load value, making sure
155+ /// that the watchdog reboot will not be triggered for the configured
156+ /// period.
157+ pub fn feed ( & self ) {
157158 self . load_counter ( self . load_value )
158159 }
159- }
160-
161- impl watchdog:: WatchdogEnable for Watchdog {
162- type Time = MicrosDurationU32 ;
163160
164- fn start < T : Into < Self :: Time > > ( & mut self , period : T ) {
161+ /// Start the watchdog. This enables a timer which will reboot the
162+ /// rp2040 if [`feed()`] doesnot get called for the configured period.
163+ pub fn start < T : Into < MicrosDurationU32 > > ( & mut self , period : T ) {
165164 const MAX_PERIOD : u32 = 0xFFFFFF ;
166165
167166 let delay_us = period. into ( ) . to_micros ( ) ;
@@ -183,10 +182,29 @@ impl watchdog::WatchdogEnable for Watchdog {
183182 self . load_counter ( self . load_value ) ;
184183 self . enable ( true ) ;
185184 }
185+
186+ /// Disable the watchdog timer.
187+ pub fn disable ( & self ) {
188+ self . enable ( false )
189+ }
190+ }
191+
192+ impl watchdog:: Watchdog for Watchdog {
193+ fn feed ( & mut self ) {
194+ ( * self ) . feed ( )
195+ }
196+ }
197+
198+ impl watchdog:: WatchdogEnable for Watchdog {
199+ type Time = MicrosDurationU32 ;
200+
201+ fn start < T : Into < Self :: Time > > ( & mut self , period : T ) {
202+ self . start ( period)
203+ }
186204}
187205
188206impl watchdog:: WatchdogDisable for Watchdog {
189207 fn disable ( & mut self ) {
190- self . enable ( false )
208+ ( * self ) . disable ( )
191209 }
192210}
0 commit comments