summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-08-24 00:34:55 -0700
committerKeith Packard <keithp@keithp.com>2012-08-24 00:34:55 -0700
commita8e9906513227600599da12b268ff5f807ae98c7 (patch)
treeeb44774161179d60f475931eaae8f065c42eda13 /src
parent50b58d703b8b48005a3ca9ad4e3603d6f7ac1430 (diff)
altos: Add 'ao_led_set_mask' in the PCA9922 driver
This lets a subset of the LEDs be controlled independent of other LED settings. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/ao_led.h4
-rw-r--r--src/drivers/ao_pca9922.c8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/core/ao_led.h b/src/core/ao_led.h
index edc5fd1f..d9a0914a 100644
--- a/src/core/ao_led.h
+++ b/src/core/ao_led.h
@@ -40,6 +40,10 @@ ao_led_off(AO_LED_TYPE colors);
void
ao_led_set(AO_LED_TYPE colors);
+/* Set all LEDs in 'mask' to the specified state */
+void
+ao_led_set_mask(uint8_t colors, uint8_t mask);
+
/* Toggle the specified LEDs */
void
ao_led_toggle(AO_LED_TYPE colors);
diff --git a/src/drivers/ao_pca9922.c b/src/drivers/ao_pca9922.c
index dc006f55..6d8d18d8 100644
--- a/src/drivers/ao_pca9922.c
+++ b/src/drivers/ao_pca9922.c
@@ -57,6 +57,13 @@ ao_led_set(uint8_t colors)
}
void
+ao_led_set_mask(uint8_t colors, uint8_t mask)
+{
+ ao_led_state = (ao_led_state & ~mask) | (colors & mask);
+ ao_led_apply();
+}
+
+void
ao_led_toggle(uint8_t colors)
{
ao_led_state ^= colors;
@@ -74,5 +81,6 @@ ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
void
ao_led_init(uint8_t enable)
{
+ (void) enable;
ao_enable_output(AO_PCA9922_CS_PORT, AO_PCA9922_CS_PIN, AO_PCA9922_CS, 1);
}