Permalink
Browse files

LED changes, similar to iLLNESS.

  • Loading branch information...
1 parent a388b1e commit 49e60b9fe051bb3fd108a7f8e1599038023e1f7b @Noltari committed Dec 16, 2010
Showing with 45 additions and 20 deletions.
  1. +35 −0 led.h
  2. +10 −20 main.c
View
@@ -0,0 +1,35 @@
+unsigned char ledStatus = 0;
+
+void initLED() {
+ output_bit(LEDR1, 1);
+ output_bit(LEDR2, 1);
+ output_bit(LEDR3, 1);
+ output_bit(LEDG1, 1);
+ output_bit(LEDG2, 1);
+}
+
+void blink0LED() {
+ ledStatus =! ledStatus;
+
+ output_bit(LEDR1, ledStatus);
+ output_bit(LEDR2, ledStatus);
+ output_bit(LEDR3, ledStatus);
+ output_bit(LEDG1, ledStatus);
+ output_bit(LEDG2, ledStatus);
+}
+
+void blink1LED() {
+ output_bit(LEDR1, 0);
+ output_bit(LEDR2, 0);
+ output_bit(LEDR3, 0);
+ output_bit(LEDG1, 1);
+ output_bit(LEDG2, 1);
+}
+
+void blink2LED() {
+ output_bit(LEDR1, 0);
+ output_bit(LEDR2, 0);
+ output_bit(LEDR3, 0);
+ output_bit(LEDG1, 0);
+ output_bit(LEDG2, 0);
+}
View
@@ -26,6 +26,7 @@
#define USB_EP2_RX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP2_RX_SIZE 8
+#include "led.h"
#include "usb.h"
#include "usb_desc.h"
@@ -67,9 +68,7 @@ unsigned int16 port_change[6] = { C_PORT_NONE, C_PORT_NONE, C_PORT_NONE, C_PORT_
void Chirp() {
cnt = 2;
- output_high(LEDR1);
- output_high(LEDR2);
- output_high(LEDR3);
+ initLED();
}
void Delay10ms(unsigned char delay) {
@@ -183,20 +182,9 @@ int16 GetHubLength() {
void OnDongleOK() {
BlinkMode = 1;
- output_high(LEDR1);
- output_high(LEDR2);
- output_high(LEDR3);
- output_high(LEDG1);
- output_high(LEDG2);
}
void main() {
- output_high(LEDR1);
- output_high(LEDR2);
- output_high(LEDR3);
- output_low(LEDG1);
- output_low(LEDG2);
-
usb_init();
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
@@ -205,6 +193,8 @@ void main() {
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER0);
+ initLED();
+
while(1) {
usb_task();
usb_isr();
@@ -319,22 +309,22 @@ void timer() {
//Blink
if(BlinkMode == 0) {
if(cnt == 20) {
- output_toggle(LEDR1);
- output_toggle(LEDR2);
- output_toggle(LEDR3);
+ blink0LED();
cnt = 0;
}
else {
cnt++;
}
}
+ if (BlinkMode == 1) {
+ blink1LED();
+ }
+
//Chirp
if(BlinkMode == 2) {
if(!cnt) {
- output_low(LEDR1);
- output_low(LEDR2);
- output_low(LEDR3);
+ blink2LED();
}
else {
cnt--;

0 comments on commit 49e60b9

Please sign in to comment.