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

📄 dm642_wdog.c

📁 针对TI的DM642的看门狗程序
💻 C
字号:
/*
 *  Copyright 2005 by SEED.
 *  All rights reserved. Property of SEED.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* August 2005 */
/********************************************************************/
/* TSK_wdog.c file                                                      */
/********************************************************************/
#include <csl.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <std.h>

#include <tsk.h>

#include <csl_stdinc.h>

#include "..\include\seeddm642.h"
#include "..\include\seed_wdog.h"
#include "..\SEEDVPM642cfg.h"

Uint32 ledturn = 0;
Uint32 i = 0;
Uint32 k = 0;
Uint32 wdogturn = 0;
static Int TimerEventId1;

void rtc_delay(Uint32 delay)
{
	Uint32 i = 0;
	for(i = 0; i<delay;i++)
	{
		SEEDDM642_waitusec(10000);
	}	
}

void tsk_WDOG()
{
	/*测试SEEDVPM642的LED*/
    GPIO_RSET(GPGC,0x0);/*将GPIO0不做为GPINT使用*/
    GPIO_RSET(GPEN,0x108);
	GPIO_RSET(GPDIR,0x108);/*将GPIO0做为输出*/
	
	for(;;)
	{
		if(ledturn ==0)
		{
			/*GPIO3输出为高*/
			GPIO_RSET(GPVAL,0x8);
			/*GPIO8输出为低*/
			GPIO_RSET(GPVAL,0x0);	
		}
		else
		{
			/*GPIO3输出为低*/
			GPIO_RSET(GPVAL,0x0);
			/*GPIO8输出为高*/
		    GPIO_RSET(GPVAL,0x100);
		}
		if(wdogturn == 1)
		{
			/*reset system,if you not feed watchdog*/
			SEED_WatchDog_Enable();
		}
	}
}
void time_init()
{
	IRQ_globalDisable();
	TimerEventId1 = TIMER_getEventId(hTimer2);
	IRQ_reset(TimerEventId1);	
    IRQ_enable(TimerEventId1);
    TIMER_start(hTimer2);
}

Void HWI_time2()
{
	if(i++ ==6000)
	{
		ledturn = 1;
	}
	if(i ==12000)
	{
		ledturn = 0;
		i = 0;
	}
	/*test the watchdog*/
	if(k++ ==100000)
	{
		wdogturn =1;	
	}
	/*feed the watchdog*/
	if(wdogturn == 1)
	{
		SEED_watchDog_Feed();
	}
}

⌨️ 快捷键说明

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