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

📄 frmwrk.c

📁 EP7312的入门例子
💻 C
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 *
 * frmwrk.c - 
 *
 *
 * Copyright (c) 1999 SUN Sirius, Inc.
 *
--------------------------------------------------------------------------------------------------------------------------------*/
#include "type.h"
#include "ep7312.h"
#include "consol.h"
#include "frmwrk.h"
#include <stdarg.h>
#include <stdio.h>


/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: halt_xxx
 * Description	: These exception handlers are used to report a particular exception on the consol & halt.
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
static void __irq halt_undef(void)
{
	consol_printf("Undefined instruction exception !!\n");
	while(1);
}

static void __irq halt_swi(void)
{
	consol_printf("SWI exception !!\n");
	while(1);
}

static void __irq halt_pabort(void)
{
	consol_printf("Pabort exception !!\n");
	while(1);
}

static void __irq halt_dabort(void)
{
	consol_printf("Dabort exception !!\n");
	while(1);
}

static void __irq halt_fiq(void)
{
	consol_printf("FIQ exception !!\n");
	while(1);
}

static void __irq halt_irq(void)
{
	consol_printf("IRQ exception !!\n");
	while(1);
}

/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: init_halt_handlers
 * Description	: This routine hooks all the Halt exception handlers. Exception which are to be handled by the application can be
 *					  overwritten(冲掉改写) with the new handler at the appropriate(适当的) software hook location.
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
static void init_halt_handlers(void)
{
	pISR_UNDEF	= (unsigned)halt_undef;
	pISR_SWI	= (unsigned)halt_swi;
	pISR_PABORT	= (unsigned)halt_pabort;
	pISR_DABORT	= (unsigned)halt_dabort;
	pISR_FIQ	= (unsigned)halt_fiq;
	pISR_IRQ	= (unsigned)halt_irq;
}


/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: logo_display
 * Description	: This routine display the Logo on the consol port.
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
void logo_display(void)
{
	consol_printf("\n\n Test_Framwork Ver %s for %s : %s\n", BULID_VER, PROCESSOR_ID, BULID_DATE);
	consol_printf("Bulit using %s on %s <%s>\n", "ADS", __DATE__, __TIME__);
	consol_printf("Consol : COM %d, %dbps, 8Bit, NP\n", CONSOL_PORT, CONSOL_BAUD);
	consol_printf("CPU CLK : %dMHz, MMU: %s, Cache: %s, Writer Buf: %s\n", MCLK/1000000,
#ifdef MMU_enabled
		"ON", "ON", "ON");
#else
		"OFF", "OFF", "OFF");
#endif

	consol_printf("FLASH_SADDR : %08xh\nSRAM_SADDR : %08xh\nSRAM_EADDR : %08xh\nSDRAM_SADDR : %08xh\n\
						SFR_BADDR : %08xh\nISR_BADDR : %08xh\n", FLASH_SADDR, SRAM_SADDR, SRAM_EADDR, SDRAM_SADDR, SFR_BADDR,
						ISR_BADDR);
	consol_printf("rework by Sirius\n");
}

/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: irq_handler
 * Description	: This routine is the IRQ handler. Handles UART1 interrupts.
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
void irq_handler(void)
{
	u32 wTemp;
	wTemp = rINTSR1 & rINTMR1;

	// High priority since its used for CS8900A
	if(TEST_BIT_SET(wTemp, BIT_EINT3))
		((void(*)(void))pISR_EINT3)();
	
	//
	if(TEST_BIT_SET(wTemp, BIT_TC1OI))
	{
		rTC1EOI = 0;
		((void(*)(void))pISR_TC1OI)();
	}


	//
	if(TEST_BIT_SET(wTemp, BIT_TC2OI))
	{
		rTC2EOI = 0;
		((void(*)(void))pISR_TC2OI)();
	}

	//
	if(TEST_BIT_SET(wTemp, BIT_URXINT1))
		((void(*)(void))pISR_URXINT1)();

	//
	if(TEST_BIT_SET(wTemp, BIT_UTXINT1))
		((void(*)(void))pISR_UTXINT1)();

	// Add code for the other IRQ Group 1 interrupts here
	wTemp = rINTSR2 & rINTMR2;

	//
	if(TEST_BIT_SET(wTemp, BIT_URXINT2))
		((void(*)(void))pISR_URXINT2)();

	//
	if(TEST_BIT_SET(wTemp, BIT_UTXINT2))
		((void(*)(void))pISR_UTXINT2)();

	// Add code for other IRQ Group 2 interrupts here
}

/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: ram_test
 * Description	: This routine is used do RAM test.
 * Arguments	: pbID		- Test identification string.
 *					  wSAddr	- RAM starting address.
 *					  wEAddr		- RAM end address.
 * Return		: None
 * Note(s)		: Do not test the following areas using this routine: 1. Stack   2. Software vector table   3. C Variables (RW & ZI)
-------------------------------------------------------------------------------------------------------------------------*/
void ram_test(u8 *pbID, u32 wSAddr, u32 wEAddr)
{
	u32 wI, wJ;
	u8 bError = 0;

	consol_printf("\n%s(%08xh-%08xh):WR", pbID, wSAddr, wEAddr);
	for(wI=wSAddr; wI<wEAddr; wI+=4)
	{
		*((volatile unsigned *)wI) = wI;
	}
	consol_printf("\b\bRD");
	for(wI=wSAddr; wI<wEAddr; wI+=4)
	{
		wJ = *((volatile unsigned *)wI);
		if(wJ != wI)
			bError = 1;
	}

	if(bError == 0)
		consol_printf("\b\bO.K.\n");
	else
		consol_printf("\b\bFAIL\n");
}

/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: C_vMain
 * Description	: This is the main C entry function
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
void C_vMain(void)
{
	init_halt_handlers();

	consol_select(CONSOL_PORT);
	consol_init(CONSOL_BAUD, CONSOL_FIFO_ENABLE);

	logo_display();
	app_main();

	consol_printf("APP has ended...\n");
}

/*-------------------------------------------------------------------------------------------------------------------------
 * Routine		: printf
 * Description	: This is a stdio.h function.
 * Arguments	: None
 * Return		: None
-------------------------------------------------------------------------------------------------------------------------*/
int printf(const char *pbFmt,...)
{
	va_list pArg;
	char abString[1024];

	va_start(pArg, pbFmt);
	vsprintf(abString, pbFmt, pArg);
	consol_sendstring(abString);
	va_end(pArg);

	return 0;
}

⌨️ 快捷键说明

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