From ca5bd37eed3f758a3ecbf24f482c403b69a0141f Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Wed, 9 Dec 2015 19:37:53 +0300 Subject: [PATCH] make green and red leds similarly controlled --- Hal/Hal.c | 62 ++++++++++++++++++++++++++++----------------- Hal/Hal.h | 21 ++++++--------- Pulsecounter-Prog.c | 6 +++-- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/Hal/Hal.c b/Hal/Hal.c index 3417f6a..bb05cd4 100644 --- a/Hal/Hal.c +++ b/Hal/Hal.c @@ -10,15 +10,17 @@ /* -------- 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) { diff --git a/Hal/Hal.h b/Hal/Hal.h index 245608c..cee0483 100644 --- 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 --------- * diff --git a/Pulsecounter-Prog.c b/Pulsecounter-Prog.c index 266edb7..62efd73 100644 --- a/Pulsecounter-Prog.c +++ b/Pulsecounter-Prog.c @@ -11,9 +11,11 @@ void main() { } static void buttonHandler(void) { - Hal_ledOn(); + Hal_greenLedOn(); + Hal_redLedOn(); Hal_delay(500); - Hal_ledOff(); + Hal_greenLedOff(); + Hal_redLedOff(); Pulsecounter_event3_indicate(); } -- 2.39.2