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

📄 reset.c

📁 三星2413芯片的测试代码,对进行驱动开发很有帮助.
💻 C
字号:
/***************************************************************

  NAME: Reset.c
  DESC: Reset mode test
  HISTORY:

 ****************************************************************/
 
#include "def.h"
#include "option.h"
#include "System.h"
#include "Console.h" 
#include "2413addr.h"

#include "reset.h"

void Test_Reset_Repeat(void);
void Test_Software_Reset(void);
void Test_Watchdog_Reset(void);

void * func_syscon_reset[][2]=
{	
	//                          			"0123456789012345678"
	(void *)Test_Software_Reset,			"Software Reset Test    ",
	(void *)Test_Watchdog_Reset,			"Watchdog Reset Test    ",
	0,0
};

void Test_Reset(void)
{
	int i;
	
	printf("\nReset Mode Test.\n");

	// Battery fault setting.
	rMISCCR = (rMISCCR & ~(0x7<<20)) | (1<<22) | (1<<21) | (0<<20);
		
	while(1)
	{
		i=0;
		printf("\n\n");
		while(1)
		{   //display menu
			printf("%2d:%s",i,func_syscon_reset[i][1]);
			i++;
			if((int)(func_syscon_reset[i][0])==0)
			{
				printf("\n");
				break;
			}
			if((i%3)==0)
			printf("\n");
		}

		printf("\nSelect (\"-1\" to exit) : ");
		i = GetIntNum();
		if(i==-1) break;		// return.
		if(i>=0 && (i<((sizeof(func_syscon_reset)-1)/8)) )	// select and execute...
			( (void (*)(void)) (func_syscon_reset[i][0]) )();
	}
	
	printf("\nThe end of Test on Clock Mode.\n");
}

void Test_Software_Reset(void)
{

	unsigned int i,j;

	
	rGPFDAT &= ~(1<<4);
	rGPFCON = (rGPFCON & ~(0x3<<8))|(0x1<<8); // to trig the reset assertion.
	
	
#ifdef DBGMSG	
	printf("Test pattern for SDRAM Self-Refresh is filled!\n");
#endif	
	for(i=0; i<14; i++)
		for(j=0; j<1000; j++)
			*(unsigned int *)(_NONCACHE_STARTADDRESS + i*0x100000 + j*4) = (_NONCACHE_STARTADDRESS + i*0x100000 + j*4)^0xa5a55a5a;

#ifdef DBGMSG	
	printf("Any unintentional interrupt is cleared!\n");
#endif
	rEINTMASK = 0xffffff;
	rINTMSK = 0xffffffff;
	rEINTPEND = 0xffffff;
	rSRCPND = 0xffffffff;
	rINTPND = rINTPND;

#ifdef DBGMSG
	printf("Reset Count Value is set!\n");
#endif		
	rRSTCON = (rRSTCON & ~(0xff<<8))|(0xff<<8);

#ifdef DBGMSG	
	printf("Inform register is set!\n");
#endif	
	rINFORM0 = rINFORM2=0x0;
	rINFORM1 = 0xFFAEFFAE;
#ifdef DBGMSG	
	printf("Software Reset is asserted!\n");
#endif

	Uart_TxEmpty(1);
	
	rGPFDAT |= 1<<4;

	rSWRSTCON = 0x533c2412;	
}

void Test_Watchdog_Reset(void)
{

	unsigned int i,j;

	rGPFDAT &= ~(1<<4);
	rGPFCON = (rGPFCON & ~(0x3<<8))|(0x1<<8); // to trig the reset assertion.
	
	
#ifdef DBGMSG	
	printf("Test pattern for SDRAM Self-Refresh is filled!\n");
#endif	
	for(i=0; i<14; i++)
		for(j=0; j<1000; j++)
			*(unsigned int *)(_NONCACHE_STARTADDRESS + i*0x100000 + j*4) = (_NONCACHE_STARTADDRESS + i*0x100000 + j*4)^0xa5a55a5a;

#ifdef DBGMSG	
	printf("Any unintentional interrupt is cleared!\n");
#endif
	rEINTMASK = 0xffffff;
	rINTMSK = 0xffffffff;
	rEINTPEND = 0xffffff;
	rSRCPND = 0xffffffff;
	rINTPND = rINTPND;

#ifdef DBGMSG
	printf("Reset Count Value is set!\n");
#endif		
	rRSTCON = (rRSTCON & ~(0xff<<8))|(0xff<<8);

#ifdef DBGMSG	
	printf("Inform register is set!\n");
#endif	
	rINFORM0 = rINFORM1=0x0;
	rINFORM2 = 0xFACDFACD;
#ifdef DBGMSG	
	printf("Watchdog Reset is asserted!\n");
#endif

	Uart_TxEmpty(1);
	
	rWTDAT = 0x1;
	rWTCNT = 0x1;
	
	
	rGPFDAT |= 1<<4;
	
	rWTCON = (1<<5)|(1);
	while(1);
}

⌨️ 快捷键说明

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