leddemo.c

来自「一个在uClinux下做的最简单的控制led的程序」· C语言 代码 · 共 51 行

C
51
字号
#include <stdio.h>/* * LED blink function.  *     this function blink the led */void led_blink(void){	static int led_status = 0;		led_status += 1;	if(led_status % 2 == 0)		*(char *)0x02000000 = 0xff;	else		*(char *)0x02000000 = 0x00;			}/* * LED blink function.  *     this function blink the led */void seg_blink(void){	static unsigned char seg_value[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e };		   	static int seg_status = 0;		*((unsigned char *)0x02000004) = seg_value[seg_status];	seg_status += 1;	if(seg_status > 15)		seg_status = 0;}int main(){	int loopcnt;	printf("hello world!!!\n");	*((unsigned char *)0x02000006) = 0x3e;	while(1)	{		led_blink();		seg_blink();		sleep(1);	}	return 0;}

⌨️ 快捷键说明

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