|
代码如下:
- import machine as mc
- class WDOG():
- def __init__(self):
- self.timer = mc.Timer(-1)
- self.fed = False
- def feed(self):
- self.fed = True
- def wdcb(self):
- pass
- def wdtcb(self,tmr):
- if not self.fed:
- mc.reset()
- self.fed = False
- self.wdcb()
- def init(self,msec=5000):
- self.timer.init(period=msec, mode=mc.Timer.PERIODIC, callback=self.wdtcb)
- self.feed()
-
-
- wd = WDOG()
- wd.init(20000)
- for i in range(100):
- wd.feed()
- time.sleep(1)
- print(i)
复制代码
此内容由EEWORLD论坛网友youxinweizhi原创,如需转载或用于商业用途需征得作者同意并注明出处
|
|