From 0fe08d7612d36efa555a282bfe1e3300f3045b1b Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Sat, 27 Jul 2024 12:53:45 -0700 Subject: [PATCH] Added function for setting the enable pins low --- src/Enable/Enable.c | 15 ++++++++++++++ src/Enable/Enable.h | 4 ++++ tests/Enable/test_Enable.cpp | 38 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/Enable/Enable.c b/src/Enable/Enable.c index 8ffc085..7f1771a 100644 --- a/src/Enable/Enable.c +++ b/src/Enable/Enable.c @@ -17,5 +17,20 @@ void Enable_SetPinsHigh() { RegEdit_SetBit((void *) &PORTA.DIR, EN1); + RegEdit_SetBit((void *) &PORTB.DIR, EN2); + RegEdit_SetBit((void *) &PORTB.DIR, EN3); + + RegEdit_SetBit((void *) &PORTA.OUT, EN1); + RegEdit_SetBit((void *) &PORTB.OUT, EN2); + RegEdit_SetBit((void *) &PORTB.OUT, EN3); + return; +} + + +void Enable_SetPinsLow() +{ + RegEdit_ClearBit((void *) &PORTA.OUT, EN1); + RegEdit_ClearBit((void *) &PORTB.OUT, EN2); + RegEdit_ClearBit((void *) &PORTB.OUT, EN3); return; } diff --git a/src/Enable/Enable.h b/src/Enable/Enable.h index 0bf1d88..748783a 100644 --- a/src/Enable/Enable.h +++ b/src/Enable/Enable.h @@ -19,6 +19,10 @@ */ void Enable_SetPinsHigh(); +/** + * Sets all the Enable pins low. + */ +void Enable_SetPinsLow(); #endif //ENABLE diff --git a/tests/Enable/test_Enable.cpp b/tests/Enable/test_Enable.cpp index fc8c71e..f91eedc 100644 --- a/tests/Enable/test_Enable.cpp +++ b/tests/Enable/test_Enable.cpp @@ -40,5 +40,43 @@ TEST(test_Enable, SetEnablePinsHighCallsCorrectFuncs) .withPointerParameter("reg", (void *) &PORTA.DIR) .withUnsignedIntParameter("bit_num", EN1); + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTB.DIR) + .withUnsignedIntParameter("bit_num", EN2); + + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTB.DIR) + .withUnsignedIntParameter("bit_num", EN3); + + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTA.OUT) + .withUnsignedIntParameter("bit_num", EN1); + + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", EN2); + + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", EN3); + Enable_SetPinsHigh(); } + +TEST(test_Enable, SetEnablePinsLow) +{ + + mock().expectOneCall("RegEdit_ClearBit") + .withPointerParameter("reg", (void *) &PORTA.OUT) + .withUnsignedIntParameter("bit_num", EN1); + + mock().expectOneCall("RegEdit_ClearBit") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", EN2); + + mock().expectOneCall("RegEdit_ClearBit") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", EN3); + + Enable_SetPinsLow(); +}