summaryrefslogtreecommitdiff
path: root/blink
diff options
context:
space:
mode:
Diffstat (limited to 'blink')
-rw-r--r--blink/Makefile2
-rw-r--r--blink/led.c17
-rw-r--r--blink/util.c8
3 files changed, 19 insertions, 8 deletions
diff --git a/blink/Makefile b/blink/Makefile
index 6d9756d..75e423b 100644
--- a/blink/Makefile
+++ b/blink/Makefile
@@ -22,6 +22,6 @@
NAME := blink
OBJ := blink.o util.o led.o
-BOARD_TYPE := arduinoNG
+BOARD_TYPE := arduino2009
include ../include.mk
diff --git a/blink/led.c b/blink/led.c
index 0e9292e..ba4b681 100644
--- a/blink/led.c
+++ b/blink/led.c
@@ -23,12 +23,17 @@
#include "avr/io.h"
#include "led.h"
+#define HAS_LED 1
+#if defined(__BOARD_arduinoUno__)
+#define HAS_LED 0
+#endif
+
#define LED_DIR 1
#if defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__)
#define LED_DIR 0
#endif
-#if defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__) || defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__)
+#if defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__) || defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__)
#define LED_PORT PORTD
#define LED_DDR DDRD
#define LED_PINNUM 6
@@ -40,7 +45,7 @@
#define LED_PINNUM 6
#endif
-#if defined(__BOARD_arduino2009__) || defined(__BOARD_arduinoNG__)
+#if defined(__BOARD_arduino2009v2__) || defined(__BOARD_arduino2009__) || defined(__BOARD_arduino10000__) || defined(__BOARD_arduinoNG__)
#define LED_PORT PORTB
#define LED_DDR DDRB
#define LED_PINNUM 5
@@ -48,29 +53,37 @@
void led_init(void)
{
+#if HAS_LED == 1
led_off();
LED_DDR = 1<<LED_PINNUM;
+#endif
}
void led_on(void)
{
+#if HAS_LED == 1
#if LED_DIR == 1
LED_PORT |= 1<<LED_PINNUM;
#else
LED_PORT &= ~(1<<LED_PINNUM);
#endif
+#endif
}
void led_off(void)
{
+#if HAS_LED == 1
#if LED_DIR == 1
LED_PORT &= ~(1<<LED_PINNUM);
#else
LED_PORT |= 1<<LED_PINNUM;
#endif
+#endif
}
void led_toggle(void)
{
+#if HAS_LED == 1
LED_PORT ^= 1<<LED_PINNUM;
+#endif
}
diff --git a/blink/util.c b/blink/util.c
index 43e78ba..3b88dfc 100644
--- a/blink/util.c
+++ b/blink/util.c
@@ -23,12 +23,10 @@
#include "avr/io.h"
#include "util.h"
-#if defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__) || defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__) || defined(__BOARD_hhd70dongle__) || defined(__BOARD_arduino2009__)
-#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
-#endif
-
-#if defined(__BOARD_arduinoNG__)
+#if defined(__AVR_ATmega8__)
#define CPU_PRESCALE(n)
+#else
+#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#endif
void cpu_init(void)