📄 appli.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 : appli.c
//* Object : LED application written in C
//* Creation : JPP 16/Jun/2004
//*----------------------------------------------------------------------------
// Include Standard files
#include "Board.h"
const int led_mask[8]= {LED1, LED2, LED3, LED4};
volatile unsigned int LedSpeed;
//*--------------------------------------------------------------------------------------
//* Function Name : wait
//* Object : Software waiting loop
//* Input Parameters : none. Waiting time is defined by the global variable LedSpeed.
//* Output Parameters : none
//*--------------------------------------------------------------------------------------
void wait ( void )
{//* Begin
unsigned int waiting_time ;
for(waiting_time = 0; waiting_time < LedSpeed; waiting_time++) ;
}//* End
void Init_LED_FOR_APPLI (void)
{
// 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_PIOB, LED_MASK ) ;
// Clear the LED's. On the EB55 we must apply a "1" to turn off L EDs
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED_MASK ) ;
LedSpeed = 200000;
}
void APPLI (void)
{
int i;
// Once a Shot on each led
for ( i=0 ; i < NB_LEB ; i++ )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, led_mask[i]) ;
wait();
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, led_mask[i] ) ;
wait();
}// End for
// Once a Shot on each led
for ( i=(NB_LEB-1) ; i >= 0 ; i-- )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, led_mask[i]) ;
wait();
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, led_mask[i] ) ;
wait();
}
}
void LED_Toggle(unsigned int led)
{
if (AT91F_PIO_GetOutputDataStatus(AT91C_BASE_PIOB) & led)
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, led);
else
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, led) ;
}
void LED_TurnOn(unsigned int led)
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, led);
}
void LED_TurnOff(unsigned int led)
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOB, led) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -