diff options
Diffstat (limited to 'software/avr.lib/led.c')
-rw-r--r-- | software/avr.lib/led.c | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/software/avr.lib/led.c b/software/avr.lib/led.c index ea5bcc3..d567cef 100644 --- a/software/avr.lib/led.c +++ b/software/avr.lib/led.c @@ -24,13 +24,17 @@ #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__) +#if defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__) || defined(__BOARD_minimus__) || defined(__BOARD_minimus32__) #define LED_DIR 0 #else #define LED_DIR 1 @@ -42,6 +46,16 @@ #define LED_PINNUM 6 #endif +#if defined(__BOARD_minimus__) || defined(__BOARD_minimus32__) +#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__) #define LED_PORT PORTE #define LED_DDR DDRE @@ -56,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 @@ -75,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 @@ -86,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 +} |