📄 led_swing.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 : led_swing.c
//* Object : Led Swing for the AT91EB40A
//*
//* 1.0 06/08/01 PF : Creation
//*----------------------------------------------------------------------------
#ifndef AT91_DEBUG_NONE
#include <stdio.h>
#endif
#include "parts/r40008/lib_r40008.h"
#include "drivers/capture/capture.h"
#include "drivers/wait/wait.h"
#include "targets/eb40a/eb40a.h"
extern void wake_up_handler (void) ;
/* Global Variable */
WaitDesc wait_desc = { &TC0_DESC, 0, 0, WAIT_DELAY, wake_up_handler } ;
u_int LedSpeed = 50000 ;
u_int loop_count = 0 ;
const int led_mask[8]= {LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8};
//*----------------------------------------------------------------------------
//* Function Name : change_speed
//* Object : Adjust led speed depending on SW1 and SW3
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void change_speed ( void )
//* Begin
{
u_int status = at91_pio_read (&PIO_DESC) ;
if (( status & SW1 ) == 0 )
{
if ( LedSpeed > 10000 ) LedSpeed -=1000 ;
}
if (( status & SW3 ) == 0 )
{
if ( LedSpeed < 2000000 ) LedSpeed +=1000 ;
}
}
//* End
//*----------------------------------------------------------------------------
//* Function Name : main
//* Object : Main function of the led blink
//* Input Parameters : none
//* Output Parameters : True
//* Functions called :
//*----------------------------------------------------------------------------
int main( void )
//* Begin
{
int i = 0 ;
//* -- Set up PIO
at91_pio_open ( &PIO_DESC, LED_MASK, PIO_OUTPUT ) ;
at91_pio_write (&PIO_DESC, LED_MASK, LED_OFF ) ;
//* Detect Master Clock
wait_desc.mcki_khz = 66000 ;
//* Loop forever
for (;;)
{
//* Once a Shot on each led
for ( i=0 ; i < 8 ; i++ )
{
change_speed () ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_ON ) ;
wait_desc.period = LedSpeed ;
at91_wait_open ( &wait_desc ) ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_OFF ) ;
}
//* Once a Shot on each led
for ( i=7 ; i >= 0 ; i-- )
{
change_speed () ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_ON ) ;
at91_wait_open ( &wait_desc ) ;
at91_pio_write (&PIO_DESC, led_mask[i], LED_OFF ) ;
}
#ifdef SEMIHOSTING
printf ( "Loop %d\n", loop_count ) ;
#endif
loop_count ++ ;
}
return(TRUE);
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -