altos: Add 'ao_led_set_mask' in the PCA9922 driver
authorKeith Packard <keithp@keithp.com>
Fri, 24 Aug 2012 07:34:55 +0000 (00:34 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 24 Aug 2012 07:34:55 +0000 (00:34 -0700)
This lets a subset of the LEDs be controlled independent of other LED settings.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_led.h
src/drivers/ao_pca9922.c

index edc5fd1f9fb41d97bae679067f8fe5fec1759c08..d9a0914a761cb931bdc4d92bf7388ad8cb4839f8 100644 (file)
@@ -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);
index dc006f55eaf47311a3a1025b821b0cb5f2e3c522..6d8d18d8f8eb7df1880eb9d3ca29887786180515 100644 (file)
@@ -56,6 +56,13 @@ ao_led_set(uint8_t colors)
        ao_led_apply();
 }
 
+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)
 {
@@ -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);
 }