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

📄 frmwrk.c

📁 ADS1.2编译环境下的EP7312芯片的一个基本测试范例
💻 C
字号:
#include "ep7312.h"
#include "def.h"
#include "frmwrk.h"
#include "consol.h"

#include <stdarg.h>
#include <stdio.h>


/* ********************************************************************* */
/* Global definitions */


/* ********************************************************************* */
/* File local definitions */


/* ********************************************************************* */
/* Local functions */

/*
*********************************************************************************************
*                                       __Haltx
*
* Description: These exception handlers are used to report a particular exception on the
*              CONSOL & halt.
*
* Arguments  : none.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/

static void __irq __HaltUndef(void)
{
        CONSOL_Printf("Undefined instruction exception!!!\n");
        while(1);
}

static void __irq __HaltSwi(void)
{
        CONSOL_Printf("SWI exception!!!\n");

        while(1);
}

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

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

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

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

/*
*********************************************************************************************
*                                       __vInitHaltHandlers
*
* Description: This routine hooks all the Halt exception handlers. Exceptions 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.
*
* Note(s)    : 
*********************************************************************************************
*/

static void __vInitHaltHandlers(void)
{
        pISR_UNDEF = (unsigned)__HaltUndef;
        pISR_SWI   = (unsigned)__HaltSwi;
        pISR_PABORT= (unsigned)__HaltPabort;
        pISR_DABORT= (unsigned)__HaltDabort;
        pISR_FIQ   = (unsigned)__HaltFiq;
        pISR_IRQ = (unsigned)__HaltIrq;
}

/*
*********************************************************************************************
*                                       __vLogo
*
* Description: This routine display the Logo on the CONSOL port.
*
* Arguments  : none.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/

void __vLogo(void)
{
        CONSOL_Printf("\n\nTEST_FRAMEWORK Ver %s for %s :%s\n",
                      __mVer,__mProcessor,__mDate);
        CONSOL_Printf("Built using %s on %s <%s>\n",
                      "ADS",__DATE__,__TIME__);
        CONSOL_Printf("CONSOL: COM%d, %dbps, 8Bit, NP\n",__nConsolPort,__nConsolBaud);
	CONSOL_Printf("CPU Clk: %dMHz   MMU: %s   Cache: %s   Write Buf: %s\n",MCLK/1000000,
#ifdef MMU_enabled
                       "ON","ON","ON");
#else
                       "OFF","OFF","OFF");
#endif
        CONSOL_Printf("FLASH_SADDR:%08xh SRAM_SADDR:%08xh SRAM_EADDR:%08xh\nSDRAM_SADDR:\
%08xh SFR_BADDR :%08xh ISR_BADDR :%08xh\n",FLASH_SADDR,SRAM_SADDR,SRAM_EADDR,SDRAM_SADDR,
SFR_BADDR,ISR_BADDR);
		CONSOL_Printf("rework by HAN\n");
}


/* ********************************************************************* */
/* Global functions */

/*
*********************************************************************************************
*                                       C_IRQHandler
*
* Description: This routine is the IRQ handler. Handles UART1 interrupts.
*
* Arguments  : none.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/

void C_IRQHandler(void)
{
        U32 wTemp;

        wTemp = rINTSR1&rINTMR1;

        if(TEST_BIT_SET(wTemp,BIT_EINT3)) /* High priority since its used for CS8900A */
        {
                ((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 the other IRQ Group 2 interrupts here */
}

/*
*********************************************************************************************
*                                       FRMWRK_vRamTest
*
* 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 FRMWRK_vRamTest(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");
}

/*
*********************************************************************************************
*                                       C_vMain
*
* Description: This is the main C entry function.
*
* Arguments  : none.
*
* Return     : none.
*
* Note(s)    : 
*********************************************************************************************
*/

void C_vMain(void)
{
        __vInitHaltHandlers();

        CONSOL_Select(__nConsolPort);
        CONSOL_Init(__nConsolBaud,__nConsolFifoEn);

        __vLogo();

        app_main();

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

/*
*********************************************************************************************
*                                       printf
*
* Description: This is a stdio.h function.
*
* Arguments  : .
*
* Return     : Returns o.
*
* Note(s)    : 
*********************************************************************************************
*/

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 + -