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

📄 main.c

📁 EMB91SAM7S64开发板(全套资料)
💻 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
//* 1.0 24/Jun/04 JPP   : Creation
//*
//*----------------------------------------------------------------------------

// Include Standard LIB  files
#include "Board.h"
#include "dbgu.h"

//*   Waiting time between LED1 and LED2
#define     WAIT_TIME       MCK

//* Global variable
int count_timer0_interrupt;
int count_timer1_interrupt;

static const char szembed_header[]=
{
"\n\r================================================"
"\n\r==         欢迎使用英贝德公司的产品           =="
"\n\r==         EBD7S64 各种中断的演示测试         =="
"\n\r==   更多的的帮助请到 http://www.szembed.com  =="
"\n\r================================================\n\r"
};

// External Function Prototype
extern void timer_init (void );
extern void Usart_init (void);



//*----------------------------------------------------------------------------
//* Function Name       : delay
//* Object              : Wait
//* Input Parameters    : none
//* Output Parameters   : none
//* Functions called    : none
//*----------------------------------------------------------------------------
void delay ( void )
{
//* Set in Volatile for Optimisation
    volatile unsigned int    i ;
//* loop delay
    for ( i = 0 ;(i < WAIT_TIME/100 );i++ ) ;
}

//*----------------------------------------------------------------------------
//* Function Name       : main
//* Object              : Main interrupt function
//*		level timer 0 => 1
//*	SW2	level Irq0    => 2
//*		level timer 1 => 4
//*	SW4	level PIOA    => 6
//*		level USART   => 7
//*		LEVEL FIQ     => MAX
//* Input Parameters    : none
//* Output Parameters   : TRUE
//*----------------------------------------------------------------------------
int main( void )
//* Begin
{
    unsigned int   loop_count ;
    AT91PS_AIC     pAic;
   //* Load System pAic Base address
        pAic = AT91C_BASE_AIC;        
        
        AT91F_DBGU_Init();
        
		AT91F_DBGU_Printk("\n\r================================================");
		AT91F_DBGU_Printk("\n\r==         欢迎使用英贝德公司的产品           ==");
		AT91F_DBGU_Printk("\n\r==         EBD7S64 各种中断的演示测试         ==");
		AT91F_DBGU_Printk("\n\r==   更多的的帮助请到 http://www.szembed.com  ==");		
		AT91F_DBGU_Printk("\n\r================================================\n\r");        
        
    //* Init Usart
        Usart_init(); 
                                   
// 		AT91F_US_SendFrame(COM0,(char *)szembed_header,sizeof(szembed_header),0,0);
                        
	//* Init
     	loop_count = 0 ;
    	// First, enable the clock of the PIOB
    	AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;

   	//* then, we configure the PIO Lines corresponding to LED1 to LED8
   	//* to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
    	AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LED_MASK ) ;
   	//* Clear the LED's. On the EB55 we must apply a "1" to turn off LEDs
   	   AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_MASK ) ;
   	   
    //* Init timer interrupt
        timer_init();

for (;;)
    {

        AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1 );
        delay () ;
        AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );  //背景应用
        delay () ;

        loop_count ++ ;
    //* Set LED by software interrupt
        if (loop_count == 10)
        {
             loop_count=0;
    		if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED2 ) == LED2 )
    		{
				AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED2);
    		}
    		else
    		{
				AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED2);
    		}
        }
    }

//* End
}

⌨️ 快捷键说明

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