summaryrefslogtreecommitdiff
path: root/src/attiny
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-09-11 11:57:50 -0700
committerKeith Packard <keithp@keithp.com>2018-10-13 08:23:25 -0700
commit2cdb1f30c49ba460b0850d23ba9c85e0336af290 (patch)
tree880abd83761ec7ce5511b30ee621057eeb8412d8 /src/attiny
parentcdaa0d7b272505c49017f409b7c0b8e3240608f0 (diff)
altos: Add generic LED driver.
This driver uses the generic GPIO functions and allows per-LED port and pin configuration. It supports up to 32 LEDs. Rename SoC-specific LED drivers. Remove enabled parameter to ao_led_init Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/attiny')
-rw-r--r--src/attiny/ao_arch.h2
-rw-r--r--src/attiny/ao_led_tiny.c (renamed from src/attiny/ao_led.c)19
2 files changed, 10 insertions, 11 deletions
diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h
index 84a94be7..a9c450fc 100644
--- a/src/attiny/ao_arch.h
+++ b/src/attiny/ao_arch.h
@@ -34,6 +34,8 @@
#define AO_PORT_TYPE uint8_t
+#define AO_LED_TYPE uint8_t
+
/* Various definitions to make GCC look more like SDCC */
#define ao_arch_naked_declare __attribute__((naked))
diff --git a/src/attiny/ao_led.c b/src/attiny/ao_led_tiny.c
index 88505490..cd620f46 100644
--- a/src/attiny/ao_led.c
+++ b/src/attiny/ao_led_tiny.c
@@ -18,37 +18,35 @@
#include "ao.h"
-uint8_t ao_led_enable;
-
#define LED_PORT PORTB
#define LED_DDR DDRB
void
ao_led_on(uint8_t colors)
{
- LED_PORT |= (colors & ao_led_enable);
+ LED_PORT |= colors;
}
void
ao_led_off(uint8_t colors)
{
- LED_PORT &= ~(colors & ao_led_enable);
+ LED_PORT &= ~colors;
}
void
ao_led_set(uint8_t colors)
{
- LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
+ LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
}
void
ao_led_toggle(uint8_t colors)
{
- LED_PORT ^= (colors & ao_led_enable);
+ LED_PORT ^= (colors & LEDS_AVAILABLE);
}
void
-ao_led_for(uint8_t colors, uint16_t ticks)
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -56,9 +54,8 @@ ao_led_for(uint8_t colors, uint16_t ticks)
}
void
-ao_led_init(uint8_t enable)
+ao_led_init(void)
{
- ao_led_enable = enable;
- LED_PORT &= ~enable;
- LED_DDR |= enable;
+ LED_PORT &= ~LEDS_AVAILABLE;
+ LED_DDR |= LEDS_AVAILABLE;
}