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

📄 blinky.c

📁 ARM的keil_project
💻 C
字号:
/******************************************************************************/
/*  This file is part of the uVision/ARM development tools                    */
/*  Copyright KEIL ELEKTRONIK GmbH 2002-2004                                  */
/******************************************************************************/
/*                                                                            */
/*  BLINKY.C:  LED Flasher                                                    */
/*                                                                            */
/******************************************************************************/
                  
#include <LPC21xx.H>                        /* LPC21xx definitions */  
#include "Timer.h"

extern long volatile timeval;
/*******************************************************************************
**Name: wait()
**Descriptions: Delay
********************************************************************************/
void wait (void)  {                         /*  wait function */
  unsigned long i;

  i = timeval;
  while ((i + 10) != timeval);              /* wait 100ms */
}

/*******************************************************************************
**Name: main()
**Descriptions: Blink 
********************************************************************************/
int main (void) {
  unsigned int j;                           /* LED var */

  IO0DIR = 0x0000FF;                        /*P0.0..P0.7defined as Outputs */

  init_timer();
  IO0SET=0x0000FF; 
  while (1)  {                                  /* Loop forever */
    for (j = 0x000001; j < 0x000080; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
      IO0CLR = j;                               /* Turn on LED */
      wait ();                                  /* call wait function */
      IO0SET = j;                               /* Turn off LED */
    }
    for (j = 0x000080; j > 0x000001; j >>=1 ) { /* Blink LED 7,6,5,4,3,2,1 */
      IO0CLR = j;                               /* Turn on LED */
      wait ();                                  /* call wait function */
      IO0SET = j;                               /* Turn off LED */
    }
  }
}

⌨️ 快捷键说明

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