⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdt.cc

📁 Small Device C Compiler 面向Inter8051
💻 CC
字号:
/* * Simulator of microcontrollers (wdt.cc) * * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. *  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu * *//* This file is part of microcontroller simulator: ucsim.UCSIM is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.UCSIM is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with UCSIM; see the file COPYING.  If not, write to the FreeSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA02111-1307, USA. *//*@1@*/#include <ctype.h>// local#include "wdtcl.h"#include "regs51.h"cl_wdt::cl_wdt(class cl_uc *auc, long resetvalue):  cl_hw(auc, HW_WDT, 0, "wdt"){  reset_value= resetvalue;  wdt= -1;  written_since_reset= DD_FALSE;}intcl_wdt::init(void){  class cl_mem *sfr= uc->mem(MEM_SFR);  if (!sfr)    {      fprintf(stderr, "No SFR to register WDT into\n");    }  //wdtrst= sfr->register_hw(WDTRST, this, (int*)0);  register_cell(sfr, WDTRST, &wdtrst, wtd_restore);  return(0);}voidcl_wdt::write(class cl_cell *cell, t_mem *val){  if (cell == wdtrst &&      (((*val)&0xff) == 0xe1) &&      (wdtrst->get() == 0x1e) &&      written_since_reset)    {      wdt= 0;      /*uc->sim->app->get_commander()->	debug("%g sec (%d tick): Watchdog timer enabled/reset PC= 0x%06x"	"\n", uc->get_rtime(), uc->ticks->ticks, uc51r->PC);*/    }  written_since_reset= DD_TRUE;}intcl_wdt::tick(int cycles){  if (wdt >= 0)    {      wdt+= cycles;      if (wdt > reset_value)	{	  /*sim->app->get_commander()->	    debug("%g sec (%d ticks): Watchdog timer resets the CPU, "	    "PC= 0x%06x\n", get_rtime(), ticks->ticks, PC);*/	  uc->reset();	  //return(resWDTRESET);	}    }  return(0);}voidcl_wdt::reset(void){  written_since_reset= DD_FALSE;  wdt= -1;}voidcl_wdt::print_info(class cl_console *con){  con->dd_printf("%s[%d] %s counter=%d (remains=%d)\n", id_string, id,		 (wdt>=0)?"ON":"OFF", wdt, (wdt>=0)?(reset_value-wdt):0);}/* End of s51.src/wdt.cc */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -