sm1000_leds_switches: Add support for toggling LEDs
authorsjlongland <sjlongland@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 24 Sep 2015 08:12:13 +0000 (08:12 +0000)
committersjlongland <sjlongland@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 24 Sep 2015 08:12:13 +0000 (08:12 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2366 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/stm32/inc/sm1000_leds_switches.h
codec2-dev/stm32/src/sm1000_leds_switches.c

index 33de73fe708977c629604416317cf12049fd31dd..0949efb8fd46dfb83c6ac5e574f5f3a113d52acf 100644 (file)
 
 void sm1000_leds_switches_init(void);
 
+#define        LED_ON  1       /*!< Turn LED on */
+#define LED_OFF        0       /*!< Turn LED off */
+#define LED_INV        -1      /*!< Invert LED state */
+
 void led_pwr(int state);
 void led_ptt(int state);
 void led_rt(int state);
index 129d54ef711342d45c2548e2c64bb6e2bbaf831b..e8f6ffc955f7d0b0be656031aad4b1820c254328 100644 (file)
@@ -71,29 +71,37 @@ void sm1000_leds_switches_init(void) {
 }
 
 void led_pwr(int state) {
-    if (state)
+    if (state > 0)
         GPIOD->ODR |= (1 << 12);
+    else if (state < 0)
+        GPIOD->ODR ^= (1 << 12);
     else
         GPIOD->ODR &= ~(1 << 12);
 }
 
 void led_ptt(int state) {
-    if (state)
+    if (state > 0)
+        GPIOD->ODR |= (1 << 13);
+    else if (state < 0)
         GPIOD->ODR |= (1 << 13);
     else
         GPIOD->ODR &= ~(1 << 13);
 }
 
 void led_rt(int state) {
-    if (state)
+    if (state > 0)
         GPIOD->ODR |= (1 << 14);
+    else if (state < 0)
+        GPIOD->ODR ^= (1 << 14);
     else
         GPIOD->ODR &= ~(1 << 14);
 }
 
 void led_err(int state) {
-    if (state)
+    if (state > 0)
         GPIOD->ODR |= (1 << 15);
+    else if (state < 0)
+        GPIOD->ODR ^= (1 << 15);
     else
         GPIOD->ODR &= ~(1 << 15);
 }