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

📄 main.c

📁 ATMEL AT91RM9200开发板配套光盘上的全部示例程序
💻 C
字号:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* 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 Name           : main.c
//* Object              : main application written in C
//* Creation            : JPP   13/Jan/2003
//*
//*----------------------------------------------------------------------------

//* Include Standard  LIB  files 
#include "eb55.h"

//* --------------------------- Constant definition ---------------------------
#define SOFT_INTERRUPT_LEVEL	5

extern void sw_asm_irq_handler(void);

//*----------------------------------------------------------------------------
//* Function Name       : aic_software_interrupt
//* Object              : Software interrupt function
//* Input Parameters    : none
//* Output Parameters   : none
//* Functions called    : at91_pio_write
//*----------------------------------------------------------------------------
void aic_software_interrupt(void)
{
int i;
     for (i=0;i<100000;i++)
     {
     
	//* Read the output state
	if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & LED3 ) == LED3 )
	{
	AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED3 );
	}
	else
	{
	AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED3 );
	}
     }
}

//*----------------------------------------------------------------------------
//* Function Name       : main
//* Object              : Main interrupt function 
//* Input Parameters    : none
//* Output Parameters   : TRUE
//*----------------------------------------------------------------------------
void main( void )
//* Begin
{
    // Load System pAic Base address 
    AT91PS_AIC     pAic= AT91C_BASE_AIC;
    // Set the PIO 
    	// First, enable the clock of the PIOB and set the LEDs in output
    	AT91F_APMC_EnablePeriphClock ( AT91C_BASE_APMC, 1<<AT91C_ID_PIOB ) ;
    	AT91F_PIO_CfgOutput( AT91C_BASE_PIOB, LED1 | LED2 | LED3  ) ;
    	AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED1 | LED2 | LED3 ) ;

    	//* define switch SW1 at PIO input
 	AT91F_PIO_CfgInput(AT91C_BASE_PIOB,SW1_MASK);

   //* Software interrupt
    	//* Open the software interrupt on the AIC
	AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_SYS, SOFT_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE,  sw_asm_irq_handler); 
	AT91F_AIC_EnableIt (pAic, AT91C_ID_SYS);

  //* Timer initialization
       Init_Mips_Timer();
       
       AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED1) ;

       printf("Star by press SW1 external clock %d \n",MCK);
       while( 1==1) {
         //* while SW1 is push loop
     	 if  ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & SW1_MASK ) != SW1_MASK ) {
		// Set LED2
		AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED2) ;

		//* Enable the clock and Start timer
		Start_Mips_Timer();

		//* Start the target application 
		//AT91F_AIC_Trig (pAic,AT91C_ID_SYS);
		//* Background measurement
		asm_mips();
		//* print result
		printf("external ARM   %d, %d mMPIS \n", Mips_Result_loop(), Mips_Result_all() );

		//* Enable the clock and Start timer
		Start_Mips_Timer();		
		asm_mips_th();
		printf("external THUMB %d, %d mMPIS \n", Mips_Result_loop(), Mips_Result_all() );

		//* Enable the clock and Start timer
		Start_Mips_Timer();		
		asm_mips_int();
		printf("internal ARM   %d, %d mMPIS \n", Mips_Result_loop(), Mips_Result_all() );

		//* Enable the clock and Start timer
		Start_Mips_Timer();		
		asm_mips_int_th();
		printf("internal THUMB %d, %d mMPIS \n", Mips_Result_loop(), Mips_Result_all() );

		//* Enable the clock and Start timer
		Start_Mips_Timer();

		//* Start the target application 
		AT91F_AIC_Trig (pAic,AT91C_ID_SYS);

		//* Background measurement
		asm_mips_int();
		
		//* print result
		printf(" ARM   %d, %d mMPIS \n", Mips_Result_loop(), Mips_Result_all() );

		// Clear LED2
		AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED2 ) ;
	}
    }

//* End
}

⌨️ 快捷键说明

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