]> www.average.org Git - pulsecounter.git/commitdiff
make green and red leds similarly controlled
authorEugene Crosser <crosser@average.org>
Wed, 9 Dec 2015 16:37:53 +0000 (19:37 +0300)
committerEugene Crosser <crosser@average.org>
Wed, 9 Dec 2015 16:37:53 +0000 (19:37 +0300)
Hal/Hal.c
Hal/Hal.h
Pulsecounter-Prog.c

index 3417f6a534d440037b49603032313fcf00058ae0..bb05cd4e1113913c4231649cabc5d6548dd4bbaf 100644 (file)
--- a/Hal/Hal.c
+++ b/Hal/Hal.c
 
 /* -------- INTERNAL FEATURES -------- */
 
-#define LED_CONFIG()                (P1DIR |= BIT6)
-#define LED_ON()                    (P1OUT |= BIT6)
-#define LED_OFF()                   (P1OUT &= ~BIT6)
-#define LED_READ()                  (P1OUT & BIT6)
-#define LED_TOGGLE()                (P1OUT ^= BIT6)
-
-#define CONNECTED_LED_CONFIG()      (P1DIR |= BIT0)
-#define CONNECTED_LED_ON()          (P1OUT |= BIT0)
-#define CONNECTED_LED_OFF()         (P1OUT &= ~BIT0)
+#define GREEN_LED_CONFIG()                (P1DIR |= BIT6)
+#define GREEN_LED_ON()                    (P1OUT |= BIT6)
+#define GREEN_LED_OFF()                   (P1OUT &= ~BIT6)
+#define GREEN_LED_READ()                  (P1OUT & BIT6)
+#define GREEN_LED_TOGGLE()                (P1OUT ^= BIT6)
+
+#define RED_LED_CONFIG()                  (P1DIR |= BIT0)
+#define RED_LED_ON()                      (P1OUT |= BIT0)
+#define RED_LED_OFF()                     (P1OUT &= ~BIT0)
+#define RED_LED_READ()                    (P1OUT & BIT0)
+#define RED_LED_TOGGLE()                  (P1OUT ^= BIT0)
 
 #define BUTTON_CONFIG()             (P1DIR &= ~BIT3, P1REN |= BIT3, P1OUT |= BIT3, P1IES |= BIT3);
 #define BUTTON_ENABLE()             (P1IFG &= ~BIT3, P1IE |= BIT3)
@@ -110,7 +112,6 @@ void Hal_buttonEnable(Hal_Handler handler) {
 }
 
 void Hal_connected(void) {
-    CONNECTED_LED_ON();
 }
 
 void Hal_debugOn(uint8_t line) {
@@ -152,7 +153,6 @@ void Hal_delay(uint16_t msecs) {
 }
 
 void Hal_disconnected(void) {
-    CONNECTED_LED_OFF();
 }
 
 void Hal_init(void) {
@@ -171,10 +171,10 @@ void Hal_init(void) {
 
     /* setup LEDs */
 
-    LED_CONFIG();
-    LED_OFF();
-    CONNECTED_LED_CONFIG();
-    CONNECTED_LED_OFF();
+    GREEN_LED_CONFIG();
+    GREEN_LED_OFF();
+    RED_LED_CONFIG();
+    RED_LED_OFF();
 
     /* setup debug pins */
 
@@ -236,20 +236,36 @@ void Hal_idleLoop(void) {
     }
 }
 
-void Hal_ledOn(void) {
-    LED_ON();
+void Hal_greenLedOn(void) {
+    GREEN_LED_ON();
+}
+
+void Hal_greenLedOff(void) {
+    GREEN_LED_OFF();
+}
+
+bool Hal_greenLedRead(void) {
+    return GREEN_LED_READ();
+}
+
+void Hal_greenLedToggle(void) {
+    GREEN_LED_TOGGLE();
+}
+
+void Hal_redLedOn(void) {
+    RED_LED_ON();
 }
 
-void Hal_ledOff(void) {
-    LED_OFF();
+void Hal_redLedOff(void) {
+    RED_LED_OFF();
 }
 
-bool Hal_ledRead(void) {
-    return LED_READ();
+bool Hal_redLedRead(void) {
+    return RED_LED_READ();
 }
 
-void Hal_ledToggle(void) {
-    LED_TOGGLE();
+void Hal_redLedToggle(void) {
+    RED_LED_TOGGLE();
 }
 
 void Hal_tickStart(uint16_t msecs, Hal_Handler handler) {
index 245608cc98c2c19df3b9ea851e31c17de6f4c633..cee0483a3128f243d89bcac4a9a65f5337cc26ad 100644 (file)
--- a/Hal/Hal.h
+++ b/Hal/Hal.h
@@ -4,7 +4,6 @@
  * This example HAL is intentionally simple.  The implementation is limited to:
  *
  * BUTTON -- a single button that when pressed will cause an interrupt.
- * CONNECTED_LED -- an LED that is controlled inside the HAL to indicate connection to a central.
  * DEBUG -- two debug GPIOs that are available as outputs from the EAP and under user control.
  * DELAY -- a delay routine that can delay by n milliseconds.
  * INIT -- set the hardware up to its initial state
@@ -56,7 +55,6 @@ extern void Hal_buttonEnable(Hal_Handler handler);
  *
  * Called whenever the MCM peripheral connects to a central.
  *
- * Turns on the CONNECTED_LED to show connectivity to the central
  * Could do other things associated with connection to the central.
  *
  * Inputs:
@@ -65,9 +63,6 @@ extern void Hal_buttonEnable(Hal_Handler handler);
  * Returns:
  *   None
  *
- * Side Effects:
- *   CONNECTED_LED on.
- *
  **/
 extern void Hal_connected(void);
 /**
@@ -151,7 +146,6 @@ extern void Hal_delay(uint16_t msecs);
  *
  * Called whenever the MCM peripheral disconnects from a central.
  *
- * Turns off the CONNECTED_LED to show lack of connectivity to the central
  * Could do other things associated with connection to the central.
  *
  * Inputs:
@@ -160,9 +154,6 @@ extern void Hal_delay(uint16_t msecs);
  * Returns:
  *   None
  *
- * Side Effects:
- *   CONNECTED_LED off.
- *
  **/
 extern void Hal_disconnected(void);
 /**
@@ -228,7 +219,8 @@ extern void Hal_init(void);
  *   User LED off.
  *
  **/
-extern void Hal_ledOff(void);
+extern void Hal_greenLedOff(void);
+extern void Hal_redLedOff(void);
 /**
  * --------- Hal_ledOn ---------
  *
@@ -244,7 +236,8 @@ extern void Hal_ledOff(void);
  *   User LED on.
  *
  **/
-extern void Hal_ledOn(void);
+extern void Hal_greenLedOn(void);
+extern void Hal_redLedOn(void);
 /**
  * --------- Hal_ledRead ---------
  *
@@ -260,7 +253,8 @@ extern void Hal_ledOn(void);
  *   None
  *
  **/
-extern bool Hal_ledRead(void);
+extern bool Hal_greenLedRead(void);
+extern bool Hal_redLedRead(void);
 /**
  * --------- Hal_ledToggle ---------
  *
@@ -276,7 +270,8 @@ extern bool Hal_ledRead(void);
  *   User LED toggles state.
  *
  **/
-extern void Hal_ledToggle(void);
+extern void Hal_greenLedToggle(void);
+extern void Hal_redLedToggle(void);
 /**
  * --------- Hal_tickStart ---------
  *
index 266edb73fd12e66c81504035a7d1e9b5ebc0a5a0..62efd73b3e0daa1bb0fa9b26f04bca0238fc0f02 100644 (file)
@@ -11,9 +11,11 @@ void main() {
 }\r
 \r
 static void buttonHandler(void) {\r
-    Hal_ledOn();\r
+    Hal_greenLedOn();\r
+    Hal_redLedOn();\r
     Hal_delay(500);\r
-    Hal_ledOff();\r
+    Hal_greenLedOff();\r
+    Hal_redLedOff();\r
     Pulsecounter_event3_indicate();\r
 }\r
 \r