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

📄 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
//* Creation            : JPP   16/Jun/2004
//*----------------------------------------------------------------------------

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

/* Global variables */
#define SPEED 		(MCKKHz/10)
unsigned int LedSpeed = SPEED *50 ;
const int led_mask[8]= {LED1, LED2, LED3, LED4};
const int sw_mask[4]= {SW1_MASK, SW2_MASK, SW3_MASK, SW4_MASK};

//*--------------------------------------------------------------------------------------
//* Function Name       : delay
//* Object              : Software delay loop
//* Input Parameters    : none. Waiting time
//* Output Parameters   : none
//*--------------------------------------------------------------------------------------
void delay(unsigned int x)
{//* Begin
	unsigned int i;
	while(--x)
	{
		for(i=0;i<5000;i++);
	}
}//* End

//*--------------------------------------------------------------------------------------
//* Function Name       : Main
//* Object              : Software entry point
//* Input Parameters    : none.
//* Output Parameters   : none.
//*--------------------------------------------------------------------------------------
int main()
{//* Begin

    int i;
    // First, enable the clock of the PIO
       AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;

    // then, we configure the PIO Lines corresponding to LED1 to LED4
    // 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 ) ;
       
    // Loop forever
    for (;;)
    {                  
        // Once a Shot on each led
		for ( i=0 ; i < NB_LEB ; i++ )
        {
        
 		    if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & sw_mask[i]) == 0 )
 		    {
	       	    AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, led_mask[i]) ;
	       	    //wait();
	    		delay(200);
	    		AT91F_PIO_SetOutput( AT91C_BASE_PIOA, led_mask[i] ) ;
	    		//wait(); 
	    		delay(200);
		    }        
	    	
        }// End for
        
    }// End for
}//* End

⌨️ 快捷键说明

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