summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2012-09-25 15:15:41 +0000
committerChristian Pointner <equinox@spreadspace.org>2012-09-25 15:15:41 +0000
commited415997e5ea2069f4fb46825c30b75d4af5624e (patch)
tree30dab0e79f1bb2b07a11e0d1a300440a6fe9d286
parentbuild added support for minimus (diff)
led lib now supports 2 leds
git-svn-id: https://svn.spreadspace.org/avr/trunk@57 aa12f405-d877-488e-9caf-2d797e2a1cc7
-rw-r--r--blink/Makefile2
-rw-r--r--blink/blink.c3
-rw-r--r--lib/led.c55
-rw-r--r--lib/led.h4
4 files changed, 56 insertions, 8 deletions
diff --git a/blink/Makefile b/blink/Makefile
index c9e9fd8..7451346 100644
--- a/blink/Makefile
+++ b/blink/Makefile
@@ -23,6 +23,6 @@
NAME := blink
OBJ := $(NAME).o
LIBS := util led
-BOARD_TYPE := minimus
+BOARD_TYPE := teensy2
include ../include.mk
diff --git a/blink/blink.c b/blink/blink.c
index 851fd35..a520ff7 100644
--- a/blink/blink.c
+++ b/blink/blink.c
@@ -31,9 +31,12 @@ int main(void)
cpu_init();
led_init();
+ led_off();
+ led2_on();
for(;;) {
_delay_ms(250);
led_toggle();
+ led2_toggle();
}
}
diff --git a/lib/led.c b/lib/led.c
index 8f8f12c..d567cef 100644
--- a/lib/led.c
+++ b/lib/led.c
@@ -24,10 +24,14 @@
#include "led.h"
-#if defined(__BOARD_arduinoUno__) || defined(__BOARD_AvrNetIo__)
-#define HAS_LED 0
+#if defined(__BOARD_minimus__) || defined(__BOARD_minimus32__)
+#define NUM_LEDS 2
+#elif defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__) || defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__) \
+ || defined(__BOARD_arduinoNG__) || defined(__BOARD_arduino2009v2__) || defined(__BOARD_arduino2009__) || defined(__BOARD_arduino10000__) \
+ || defined(__BOARD_hhd70dongle__)
+#define NUM_LEDS 1
#else
-#define HAS_LED 1
+#define NUM_LEDS 0
#endif
#if defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__) || defined(__BOARD_minimus__) || defined(__BOARD_minimus32__)
@@ -46,6 +50,10 @@
#define LED_PORT PORTD
#define LED_DDR DDRD
#define LED_PINNUM 5
+
+#define LED2_PORT PORTD
+#define LED2_DDR DDRD
+#define LED2_PINNUM 6
#endif
#if defined(__BOARD_hhd70dongle__)
@@ -62,15 +70,18 @@
void led_init(void)
{
-#if HAS_LED == 1
+#if NUM_LEDS >= 1
led_off();
LED_DDR = 1<<LED_PINNUM;
+#if NUM_LEDS >= 2
+ LED2_DDR |= 1<<LED2_PINNUM;
+#endif
#endif
}
void led_on(void)
{
-#if HAS_LED == 1
+#if NUM_LEDS >= 1
#if LED_DIR == 1
LED_PORT |= 1<<LED_PINNUM;
#else
@@ -81,7 +92,7 @@ void led_on(void)
void led_off(void)
{
-#if HAS_LED == 1
+#if NUM_LEDS >= 1
#if LED_DIR == 1
LED_PORT &= ~(1<<LED_PINNUM);
#else
@@ -92,7 +103,37 @@ void led_off(void)
void led_toggle(void)
{
-#if HAS_LED == 1
+#if NUM_LEDS >= 1
LED_PORT ^= 1<<LED_PINNUM;
#endif
}
+
+
+void led2_on(void)
+{
+#if NUM_LEDS >= 2
+#if LED_DIR == 1
+ LED2_PORT |= 1<<LED2_PINNUM;
+#else
+ LED2_PORT &= ~(1<<LED2_PINNUM);
+#endif
+#endif
+}
+
+void led2_off(void)
+{
+#if NUM_LEDS >= 2
+#if LED_DIR == 1
+ LED2_PORT &= ~(1<<LED2_PINNUM);
+#else
+ LED2_PORT |= 1<<LED2_PINNUM;
+#endif
+#endif
+}
+
+void led2_toggle(void)
+{
+#if NUM_LEDS >= 2
+ LED2_PORT ^= 1<<LED2_PINNUM;
+#endif
+}
diff --git a/lib/led.h b/lib/led.h
index 12f00a8..d7a8e3b 100644
--- a/lib/led.h
+++ b/lib/led.h
@@ -28,4 +28,8 @@ void led_on(void);
void led_off(void);
void led_toggle(void);
+void led2_on(void);
+void led2_off(void);
+void led2_toggle(void);
+
#endif