📄 led.c
字号:
/******************************************************************************************
Led.c (v1.0)
-------------------------------------------------------------------------------------
This code is from the book:
"Embedded Internet: TCP/IP Basics, Implementation and Applications" by Sergio Scaglia
[Pearson Education, 2006 - ISBN: 0-32-130638-4]
This code is copyright (c) 2006 by Sergio Scaglia, and it may only be used for educational
purposes. For commercial use, please contact me at sscaglia@intramarket.com.ar
For more information and updates, please visit www.embeddedinternet.org
******************************************************************************************/
#include "Led.h"
#include "hardware.h"
#include "timer.h"
#include <iolpc2129.h>
char led;
char led_enable=1;
void ledOn(void) {
IO0CLR = LED;
}
void ledOff(void) {
IO0SET = LED;
}
void led_init() {
led=0;
IO0DIR |= LED;
ledOff();
timer_start(ledtimer, 1000);
}
void led_process(void) {
if (timer_expired(ledtimer) && led_enable) {
if (led) {
led=0;
ledOff();
}else {
led=1;
ledOn();
}
timer_start(ledtimer, 500);
}
if (!led_enable && led) {
ledOff();
led=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -