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

📄 watchdog_main.c

📁 pxa270平台看门狗模块的驱动代码
💻 C
字号:
/***************************************优龙科技责任有限公司*********************************************
**--------------文件信息--------------------------------------------------------------------------------
**文   件   名: WatchDog_Main
**创   建   人: cgf
**最后修改日期: 2005-11-28
**描        述: 看门狗实验代码
**                
********************************************************************************************************/

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

#include "systypes.h"
#include "utils.h"
#include "globals.h"
#include "xsuart.h"
#include "regsdef.h"

//定义相关寄存器参数
#define	GPLR0	*(volatile UINT *)0x40E00000
#define	GPLR2	*(volatile UINT *)0x40E00008
#define	GPSR0	*(volatile UINT *)0x40E00018
#define	GPCR0	*(volatile UINT *)0x40E00024
#define	GAFR3_U	*(volatile UINT *)0x40E00070
#define	MDCNFG	*(volatile UINT *)0x48000000
#define	MDREFR	*(volatile UINT *)0x48000004
#define	MSC0	*(volatile UINT *)0x48000008
#define	MSC1	*(volatile UINT *)0x4800000C
#define	MSC2	*(volatile UINT *)0x48000010

UINT downloadAddress, downloadFileSize;

#define	ESC_KEY		0x1b
#define	ENTER_KEY	0x0d
#define	BACK_KEY	0x08

/*****************************************************************************
** 函数名称: TestWdt
** 功能描述: 看门狗实验代码
** 输 入:   无
** 输 出 :  无
** 全局变量: 无
** 调用模块: 无
*****************************************************************************/
void TestWdt(void)
{
	char c;
	
	printf("Test watchdog, press '0' to Test Watchdog.\r\n");
	
	OSCR0 = 0;
	OSMR3 = OSCR0 + 3250000 * 2;	//2000ms
	OSSR |=	1<<3;
	OWER  = 1;						//enable watchdog
	
	while(1) {
		DM_WaitS(1);
		printf("update watchdog\r\n");
		OSMR3 = OSCR0 + 3250000 * 2;	//2000ms
		c = GetUserKey();
		if(c=='0') {					//如果从串口获得字符'0',将停止喂狗
			printf("stop updating watchdog, system will reset after 2 seconds.\r\n");
			while(1);
		}
	}
	
}
/*****************************************************************************
** 函数名称: PlatformMain
** 功能描述: PXA270平台主函数
** 输 入:   无
** 输 出 :  无
** 全局变量: 无
** 调用模块: 无
*****************************************************************************/

void PlatformMain(void * memTop)
{

	show_led(1, 1);	//D4 light
	show_led(2, 1);	//D5 light 
	
	SerialConsoleInit(115200);	//
	SerialConsleSel(0);			//0->FFUART, 1->BTUART
	
	TestWdt();			//看门狗函数
	
	
		
}
	
/*****************************************************************************
****空函数
******************************************************************************/
VOID DumpProcessorRegisters(UINT exception, void *regsP)
{
}

/*****************************End of File*************************************/

⌨️ 快捷键说明

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