本站改版新增arduino频道

Micropython
Arduino

micropython esp8266看门狗用法


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)



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号

执行时间: 0.0094249248504639 seconds