Compare commits

..

No commits in common. "c04b35168a6a8bc47e53267299ca8c2f2051d3a0" and "597441b978291d04c15c15616feaab902fda8746" have entirely different histories.

12 changed files with 58 additions and 57 deletions

View file

@ -2,7 +2,7 @@
## Description ## Description
This embedded firmware is the High Power mode for the software. This embedded firmware is the High Power mode for the triac software.
### Micro Controller Pins ### Micro Controller Pins
@ -111,4 +111,6 @@ Some stuff that still needs done.
- [X] Write tests for ADC Mock - [X] Write tests for ADC Mock
- [X] Write ZCD using ADC Mock. - [X] Write ZCD using ADC Mock.
- [X] Write ADC version for ATtiny404 - [X] Write ADC version for ATtiny404
- [X] Add Triac module.
- [X] Add Triac tests.

View file

@ -257,10 +257,10 @@ run_c_tests () {
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../ cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make AllTests make AllTests
make Mock_Tests make Mock_Tests
make EnTests make TriacTests
./tests/AllTests -v -c ./tests/AllTests -v -c
./tests/Mock_Tests -v -c ./tests/Mock_Tests -v -c
./tests/EnTests -v -c ./tests/TriacTests -v -c
} }
print_menu () { print_menu () {

View file

@ -5,7 +5,7 @@ add_executable(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
RegEdit RegEdit
ADC ADC
EnOut TriacOut
zero_cross_detection zero_cross_detection
load load
Enable Enable
@ -54,5 +54,5 @@ add_subdirectory(zero_cross_detection)
add_subdirectory(ADC) add_subdirectory(ADC)
add_subdirectory(RegEdit) add_subdirectory(RegEdit)
add_subdirectory(usart) add_subdirectory(usart)
add_subdirectory(EnOut) add_subdirectory(TriacOut)
add_subdirectory(Enable) add_subdirectory(Enable)

View file

@ -1,17 +0,0 @@
add_library(EnOut STATIC
EnOut.c
)
target_include_directories(EnOut PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
if(UNIT_TESTING)
target_link_libraries(EnOut
MockRegEdit
)
else()
target_link_libraries(EnOut
RegEdit
)
endif()

View file

@ -0,0 +1,17 @@
add_library(TriacOut STATIC
TriacOut.c
)
target_include_directories(TriacOut PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
if(UNIT_TESTING)
target_link_libraries(TriacOut
MockRegEdit
)
else()
target_link_libraries(TriacOut
RegEdit
)
endif()

View file

@ -1,7 +1,7 @@
/* /*
* Author: username * Author: username
* Date: todays_date * Date: todays_date
* filename: EnOut.c * filename: TriacOut.c
* description: module_purpose * description: module_purpose
*/ */
#ifndef __AVR_ATtiny404__ #ifndef __AVR_ATtiny404__
@ -10,29 +10,29 @@
#include <avr/io.h> #include <avr/io.h>
#include "EnOut.h" #include "TriacOut.h"
#include "RegEdit.h" #include "RegEdit.h"
void EnOut_InitTimerA(void) void TriacOut_InitTimerA(void)
{ {
} }
void EnOut_SetupPins(void) void TriacOut_SetupPins(void)
{ {
RegEdit_SetBit((void *) &PORTA.DIR, G1); RegEdit_SetBit((void *) &PORTA.DIR, G1);
} }
void EnOut_SetAllHigh(void) void TriacOut_SetAllHigh(void)
{ {
RegEdit_SetBit((void *) &PORTA.OUT, G1); RegEdit_SetBit((void *) &PORTA.OUT, G1);
} }
void EnOut_PulsePins(uint16_t pulse_time) void TriacOut_PulsePins(uint16_t pulse_time)
{ {
Delay_MicroSeconds(pulse_time); Delay_MicroSeconds(pulse_time);

View file

@ -4,11 +4,11 @@
* @author username * @author username
* @date todays_date * @date todays_date
* @copyright None * @copyright None
* @file EnOut.h * @file TriacOut.h
*/ */
#ifndef ENOUT_H #ifndef TRIACOUT_H
#define ENOUT_H #define TRIACOUT_H
#include <stdint.h> #include <stdint.h>
@ -31,18 +31,18 @@ extern void (*Delay_MicroSeconds)(double us);
* This function turns off G1, G2 and G3, once the passed time in micro seconds * This function turns off G1, G2 and G3, once the passed time in micro seconds
* has elapsed the pins are all set to low. * has elapsed the pins are all set to low.
*/ */
void EnOut_PulsePins(uint16_t pulse_time); void TriacOut_PulsePins(uint16_t pulse_time);
/** /**
* This sets up the G1, G2 and the G3 pins for output. * This sets up the G1, G2 and the G3 pins for output.
*/ */
void EnOut_SetupPins(void); void TriacOut_SetupPins(void);
/** /**
* This sets G1, G2 and G3 to high on the output. * This sets G1, G2 and G3 to high on the output.
*/ */
void EnOut_SetAllHigh(void); void TriacOut_SetAllHigh(void);
#endif //ENOUT_H #endif //TRIACOUT_H

View file

@ -18,7 +18,7 @@
#include "RegEdit.h" #include "RegEdit.h"
#include "zero_cross_detection.h" #include "zero_cross_detection.h"
#include "ADC.h" #include "ADC.h"
#include "EnOut.h" #include "TriacOut.h"
#include "load.h" #include "load.h"
#include "Enable.h" #include "Enable.h"
#include <avr/cpufunc.h> /* Required header file */ #include <avr/cpufunc.h> /* Required header file */
@ -52,7 +52,6 @@ int main(int argc, char **argv)
while(true){ while(true){
//Enable pins are enabled(set high) if the ADCLOAD value is valid. //Enable pins are enabled(set high) if the ADCLOAD value is valid.
_delay_us(Tau);
Load_HandleLoadPortA(ADC_LOAD1, EN1); Load_HandleLoadPortA(ADC_LOAD1, EN1);
Load_HandleLoadPortB(ADC_LOAD2, EN2); Load_HandleLoadPortB(ADC_LOAD2, EN2);
Load_HandleLoadPortB(ADC_LOAD3, EN3); Load_HandleLoadPortB(ADC_LOAD3, EN3);

View file

@ -9,7 +9,7 @@ add_subdirectory(MockRegEdit)
add_subdirectory(RegEdit) add_subdirectory(RegEdit)
add_subdirectory(simple_test) add_subdirectory(simple_test)
add_subdirectory(zero_cross_detection) add_subdirectory(zero_cross_detection)
add_subdirectory(EnOut) add_subdirectory(TriacOut)
add_subdirectory(load) add_subdirectory(load)
@ -43,12 +43,12 @@ target_link_libraries(Mock_Tests
) )
add_executable(EnTests add_executable(TriacTests
EnTests.cpp TriacTests.cpp
) )
target_link_libraries(EnTests target_link_libraries(TriacTests
${CPPUTEST_LIBRARIES}/libCppUTest.a ${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a ${CPPUTEST_LIBRARIES}/libCppUTestExt.a
test_EnOut test_TriacOut
) )

View file

@ -1,12 +1,12 @@
# TEST_RUNNER # TEST_RUNNER
add_library(test_EnOut add_library(test_TriacOut
test_EnOut.cpp test_TriacOut.cpp
) )
target_link_libraries(test_EnOut target_link_libraries(test_TriacOut
${CPPUTEST_LIBRARIES}/libCppUTest.a ${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a ${CPPUTEST_LIBRARIES}/libCppUTestExt.a
MockRegEdit MockRegEdit
EnOut TriacOut
) )

View file

@ -1,7 +1,7 @@
/* /*
* Author: username * Author: username
* Date: todays_date * Date: todays_date
* filename: test_EnOut.c * filename: test_TriacOut.c
* description: module_purpose * description: module_purpose
*/ */
@ -14,7 +14,7 @@
extern "C" extern "C"
{ {
#include <iotn404.h> #include <iotn404.h>
#include "EnOut.h" #include "TriacOut.h"
#include "MockRegEdit.h" #include "MockRegEdit.h"
} }
@ -27,7 +27,7 @@ void FakeDelay(double us)
void (*Delay_MicroSeconds)(double us) = FakeDelay; void (*Delay_MicroSeconds)(double us) = FakeDelay;
TEST_GROUP(test_EnOut) TEST_GROUP(test_TriacOut)
{ {
void setup() void setup()
{ {
@ -40,13 +40,13 @@ TEST_GROUP(test_EnOut)
} }
}; };
TEST(test_EnOut, FirstTest) TEST(test_TriacOut, FirstTest)
{ {
//FAIL("Fail me!"); //FAIL("Fail me!");
CHECK(true); CHECK(true);
} }
TEST(test_EnOut, EnOut_SetupPins) TEST(test_TriacOut, TriacOut_SetupPins)
{ {
//Expect that pin PA1 is set to output //Expect that pin PA1 is set to output
mock().expectOneCall("RegEdit_SetBit") mock().expectOneCall("RegEdit_SetBit")
@ -54,21 +54,21 @@ TEST(test_EnOut, EnOut_SetupPins)
.withUnsignedIntParameter("bit_num", G1); .withUnsignedIntParameter("bit_num", G1);
EnOut_SetupPins(); TriacOut_SetupPins();
} }
TEST(test_EnOut, EnOut_SetAllHigh) TEST(test_TriacOut, TriacOut_SetAllHigh)
{ {
//Expect that pin PA1 is set to output //Expect that pin PA1 is set to output
mock().expectOneCall("RegEdit_SetBit") mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.OUT) .withPointerParameter("reg", (void *) &PORTA.OUT)
.withUnsignedIntParameter("bit_num", G1); .withUnsignedIntParameter("bit_num", G1);
EnOut_SetAllHigh(); TriacOut_SetAllHigh();
} }
TEST(test_EnOut, EnOut_PulsePins) TEST(test_TriacOut, TriacOut_PulsePins)
{ {
//Expect that pin PA1 is set to output //Expect that pin PA1 is set to output
@ -76,5 +76,5 @@ TEST(test_EnOut, EnOut_PulsePins)
.withPointerParameter("reg", (void *) &PORTA.OUT) .withPointerParameter("reg", (void *) &PORTA.OUT)
.withUnsignedIntParameter("bit_num", G1); .withUnsignedIntParameter("bit_num", G1);
EnOut_PulsePins(1000); TriacOut_PulsePins(1000);
} }

View file

@ -1,6 +1,6 @@
#include "CppUTest/CommandLineTestRunner.h" #include "CppUTest/CommandLineTestRunner.h"
IMPORT_TEST_GROUP(test_EnOut); IMPORT_TEST_GROUP(test_TriacOut);
//START: main //START: main