main.c

来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 112 行

C
112
字号
/*
**************************************************************************
** Copyright(C) Micronas GmbH
** This program is the property of Micronas GmbH. Its contents is proprietary
** information and is not to be reproduced in whole or part by any means or is
** to be disclosed to anyone except employees of Micronas GmbH, or as agreed in
** writing signed by an autorized person of Micronas GmbH.
** The software is delivered "AS IS" without warranty or condition of any
** kind, either express, implied or statutory. This includes without
** limitation any warranty or condition with respect to merchantability or
** fitness for any particular purpose, or against the infringements of
** intellectual property rights of others.
**	-----------------------------------------------------------------------
**
** file:              main.c
**
** description:       "APB LEDs Blink"
**
** Copyright (c) 2004 Micronas GmbH,
**
** Author: P. Bonello
**
** History:
**
**************************************************************************
*/

#define SRAM_C  // for shadow RAM
#include "cdc32xxg-c2-api.h"
#include "cdc32xxg-c2-pm.h"
#include "globals.h"
#include "power_mode.h"
#include "utility.h"
#undef	SRAM_C

#include "stdio.h"

static void interrupt_enable( void * vec_tab );

u16 f_sys;		        // actual fsys frequency
u16 f_0;			// actual f0 frequency
i8 portToggleEnable=0xff;

void main(void)
{
    int i;

    HPortInitNormalOutput(0,0xF);

    HPortInitNormalOutput(1,0xF);

    f_sys = f_0 = XTAL;		// Fast Mode

    // Initialiasing CDC32xxG and host communication
    pll_set( CPU_PLL, PLL_MODE_PMF_VALUE, PLL_MODE_WSR_VALUE, PLL_MODE_IOP_VALUE );


    // enable ICU using default vector table in 'irq.arm'
    interrupt_enable(&VECTAB_1 );	

    //initialise Timer0
    init_timer0();

    while(1)
    {
	if(portToggleEnable)
	{
	    HPortSet( 0, 0x0F );
	    HPortReset( 1, 0x0F );

	    for(i=0; i<500000; i++);

	    HPortSet( 1, 0x0F );
	    HPortReset( 0, 0x0F );

	    for(i=0; i<500000; i++);
	}
	else
	{
	    HPortReset( 0, 0x0F );
	    HPortReset( 1, 0x0F );
	}
    }

}


/******************************************************************************
  IRQ HANDLER SECTION
  ****************************************************************************/
/***********************************************************************/
void interrupt_enable( void * vec_tab )
/***********************************************************************/
{
	ISN0  = 0xE0;		// set P, E and PRIO=0

	SR1_IRQ = 1;
	VTB = (u32) vec_tab;
	CRI_GE = 1;
	CRI_TE = 1;
}


void isr_def()
{}

void isr_not_used()
{}

__irq __arm __nested void FIQHandler()
{}

⌨️ 快捷键说明

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