diff options
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | blink/led.c | 35 | ||||
-rw-r--r-- | include.mk | 2 |
3 files changed, 32 insertions, 6 deletions
@@ -7,6 +7,7 @@ binutils-avr gcc-avr avrdude dfu-programmer +teensy_loader udev example rules diff --git a/blink/led.c b/blink/led.c index 0e035d4..997edf0 100644 --- a/blink/led.c +++ b/blink/led.c @@ -23,23 +23,48 @@ #include "avr/io.h" #include "led.h" +#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__) +#define LED_PORT PORTD +#define LED_DDR DDRD +#define LED_PINNUM 6 +#endif + +#if defined(__BOARD_hhd70dongle__) +#define LED_PORT PORTE +#define LED_DDR DDRE +#define LED_PINNUM 6 +#endif + void led_init(void) { - PORTE = 0x00; - DDRE = 1<<PORTE6; + led_off(); + LED_DDR = 1<<LED_PINNUM; } void led_on(void) { - PORTE |= 1<<PORTE6; +#if LED_DIR == 1 + LED_PORT |= 1<<LED_PINNUM; +#else + LED_PORT &= ~(1<<LED_PINNUM); +#endif } void led_off(void) { - PORTE &= ~(1<<PORTE6); +#if LED_DIR == 1 + LED_PORT &= ~(1<<LED_PINNUM); +#else + LED_PORT |= 1<<LED_PINNUM; +#endif } void led_toggle(void) { - PORTE ^= 1<<PORTE6; + LED_PORT ^= 1<<LED_PINNUM; } @@ -66,7 +66,7 @@ CFLAGS += -fshort-enums CFLAGS += -Wall CFLAGS += -Wstrict-prototypes CFLAGS += -DF_CPU=$(F_CPU)UL -CFLAGS += -DBOARD_TYPE=$(BOARD_TYPE) +CFLAGS += -D__BOARD_$(BOARD_TYPE)__ ## Linker flags LDFLAGS = $(COMMON) |