led.c

来自「HAL硬件抽象层源码」· C语言 代码 · 共 53 行

C
53
字号
/***************************************************************************
 * Copyright ? Intel Corporation, March 18th 1998.  All rights reserved.
 * Copyright ? ARM Limited 1998.  All rights reserved.
 ***************************************************************************/
/******************************************************************************

	$Id: led.c,v 1.7 1999/08/13 07:45:41 mwelsh Exp $

******************************************************************************/

#include "uhal.h"

#ifdef SEMIHOSTED
extern void print_header( void);
extern void print_end (void);
#endif

char * test_name = "Heap Storage Tests\n";
char * test_ver = "Program Version 1.0\n";

int main (int argc, int *argv[])
{
  unsigned int     count, max, on ;
  unsigned int     wait, i, j ;

  count = uHALr_InitLEDs() ;
  max = (1 << count) ;

  // init the library
  uHALr_LibraryInit() ;

#ifdef SEMIHOSTED
  print_header();
  uHALr_printf("\nCheck target for flashing LEDs\n");
#endif

  while(1) {
    for (i = 0 ; i < max ; i++ ) {
      /* which LEDs are on? */
      on = (max - 1) & i ;

      for (j = 0; j < count ; j++) 
	uHALr_WriteLED(j+1,
		     (on & (1 << j) ? 1 : 0)) ;

      /* wait a while */
      for (wait = 0 ; wait < 100000 ; wait++)
	;
    }
  }
  return (OK);
}

⌨️ 快捷键说明

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