diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index beddb5a..2b831fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,3 +54,4 @@ add_subdirectory(RegEdit) add_subdirectory(usart) add_subdirectory(TriacOut) add_subdirectory(load) +add_subdirectory(Enable) diff --git a/src/Enable/CMakeLists.txt b/src/Enable/CMakeLists.txt new file mode 100644 index 0000000..6da8e33 --- /dev/null +++ b/src/Enable/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(Enable STATIC + Enable.c +) + +target_include_directories(Enable PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +if(UNIT_TESTING) + target_link_libraries(Enable + MockRegEdit + ) +else() + target_link_libraries(Enable + RegEdit + ) +endif() diff --git a/src/Enable/Enable.c b/src/Enable/Enable.c new file mode 100644 index 0000000..8ffc085 --- /dev/null +++ b/src/Enable/Enable.c @@ -0,0 +1,21 @@ +/* + * Author: username + * Date: 2024 + * filename: Enable.c + * description: module_purpose + */ + +#ifndef __AVR_ATtiny404__ +#define __AVR_ATtiny404__ +#endif + +#include "Enable.h" +#include "avr/io.h" +#include "RegEdit.h" + + +void Enable_SetPinsHigh() +{ + RegEdit_SetBit((void *) &PORTA.DIR, EN1); + return; +} diff --git a/src/Enable/Enable.h b/src/Enable/Enable.h new file mode 100644 index 0000000..0bf1d88 --- /dev/null +++ b/src/Enable/Enable.h @@ -0,0 +1,24 @@ +/** + * @brief PUT_TEXT_HERE + * @details This file is... + * @author username + * @date todays_date + * @copyright None + * @file ENABLE.h + */ + +#ifndef ENABLE +#define ENABLE + +#define EN1 (1<<2) +#define EN2 (1<<3) +#define EN3 (1<<2) + +/** + * Sets all the Enable pins high. + */ +void Enable_SetPinsHigh(); + + + +#endif //ENABLE diff --git a/tests/AllTests.cpp b/tests/AllTests.cpp index f36c181..8c7a1c9 100644 --- a/tests/AllTests.cpp +++ b/tests/AllTests.cpp @@ -5,6 +5,7 @@ IMPORT_TEST_GROUP(simple_test); IMPORT_TEST_GROUP(test_ADC); IMPORT_TEST_GROUP(test_RegEdit); +IMPORT_TEST_GROUP(test_Enable); //START: main diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0d80b58..f74ed76 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,7 @@ project(Tests) # TEST_DIRS +add_subdirectory(Enable) #add_subdirectory(usart) add_subdirectory(MockADC) add_subdirectory(ADC) @@ -20,6 +21,7 @@ target_link_libraries(AllTests ${CPPUTEST_LIBRARIES}/libCppUTest.a ${CPPUTEST_LIBRARIES}/libCppUTestExt.a # TEST_LINKS + test_Enable test_ADC test_RegEdit simple_test diff --git a/tests/Enable/CMakeLists.txt b/tests/Enable/CMakeLists.txt new file mode 100644 index 0000000..4a57728 --- /dev/null +++ b/tests/Enable/CMakeLists.txt @@ -0,0 +1,11 @@ +# TEST_RUNNER +add_library(test_Enable + test_Enable.cpp +) + +target_link_libraries(test_Enable + ${CPPUTEST_LIBRARIES}/libCppUTest.a + ${CPPUTEST_LIBRARIES}/libCppUTestExt.a + MockRegEdit + Enable +) diff --git a/tests/Enable/test_Enable.cpp b/tests/Enable/test_Enable.cpp new file mode 100644 index 0000000..fc8c71e --- /dev/null +++ b/tests/Enable/test_Enable.cpp @@ -0,0 +1,44 @@ +/* + * Author: username + * Date: todays_date + * filename: test_Enable.c + * description: module_purpose + */ + + + +#include "CppUTest/CommandLineTestRunner.h" +#include "CppUTestExt/MockSupport.h" + +//This define allows us to dircetly include the device header without error. +#define _AVR_IO_H_ + +extern "C" +{ +#include +#include "Enable.h" +#include "MockRegEdit.h" +} + +TEST_GROUP(test_Enable) +{ + void setup() + { + + } + void teardown() + { + mock().checkExpectations(); + mock().clear(); + } +}; + + +TEST(test_Enable, SetEnablePinsHighCallsCorrectFuncs) +{ + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &PORTA.DIR) + .withUnsignedIntParameter("bit_num", EN1); + + Enable_SetPinsHigh(); +}