Compare commits
3 commits
f551dd582b
...
a09d7de1df
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a09d7de1df | ||
|
|
8e3978a089 | ||
|
|
0676abc259 |
24 changed files with 311 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -104,3 +104,4 @@ queuelogs
|
||||||
.generated_files/flags/attiny404
|
.generated_files/flags/attiny404
|
||||||
dist/default
|
dist/default
|
||||||
dist/attiny404/production
|
dist/attiny404/production
|
||||||
|
.cache/clangd/index
|
||||||
|
|
|
||||||
0
.template_files/.template_files/.template_files_git_dir
Normal file
0
.template_files/.template_files/.template_files_git_dir
Normal file
7
.template_files/.template_files/modules/CMakeLists.txt
Normal file
7
.template_files/.template_files/modules/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
add_library(module_name STATIC
|
||||||
|
module_name.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(module_name PUBLIC
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
10
.template_files/.template_files/modules/TestCMakeLists.txt
Normal file
10
.template_files/.template_files/modules/TestCMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# TEST_RUNNER
|
||||||
|
add_library(test_module_name
|
||||||
|
test_module_name.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(test_module_name
|
||||||
|
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||||
|
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||||
|
module_name
|
||||||
|
)
|
||||||
16
.template_files/.template_files/modules/module_name.c
Normal file
16
.template_files/.template_files/modules/module_name.c
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Author: username
|
||||||
|
* Date: todays_date
|
||||||
|
* filename: module_name.c
|
||||||
|
* description: module_purpose
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module_name.h"
|
||||||
|
|
||||||
|
// dumb test function
|
||||||
|
int add_two(int a)
|
||||||
|
{
|
||||||
|
int b = a;
|
||||||
|
b += 2;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
14
.template_files/.template_files/modules/module_name.h
Normal file
14
.template_files/.template_files/modules/module_name.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Author: username
|
||||||
|
* Date: todays_date
|
||||||
|
* filename: module_name.h
|
||||||
|
* description: module_purpose
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef module_name
|
||||||
|
#define module_name
|
||||||
|
|
||||||
|
|
||||||
|
int add_two(int a);
|
||||||
|
|
||||||
|
#endif //module_name
|
||||||
0
.template_files/.template_files/modules/modules_git_dir
Normal file
0
.template_files/.template_files/modules/modules_git_dir
Normal file
38
.template_files/.template_files/modules/test_module_name.cpp
Normal file
38
.template_files/.template_files/modules/test_module_name.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Author: username
|
||||||
|
* Date: todays_date
|
||||||
|
* filename: test_module_name.c
|
||||||
|
* description: module_purpose
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CppUTest/CommandLineTestRunner.h"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "module_name.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_GROUP(FirstTestGroup)
|
||||||
|
{
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void teardown()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(FirstTestGroup, FirstTest)
|
||||||
|
{
|
||||||
|
FAIL("Fail me!");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FirstTestGroup, SecondTest)
|
||||||
|
{
|
||||||
|
STRCMP_EQUAL("hello", "world");
|
||||||
|
LONGS_EQUAL(1, 2);
|
||||||
|
CHECK(false);
|
||||||
|
}
|
||||||
|
|
||||||
0
.template_files/.template_files_git_dir
Normal file
0
.template_files/.template_files_git_dir
Normal file
7
.template_files/modules/CMakeLists.txt
Normal file
7
.template_files/modules/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
add_library(module_name STATIC
|
||||||
|
module_name.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(module_name PUBLIC
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
)
|
||||||
10
.template_files/modules/TestCMakeLists.txt
Normal file
10
.template_files/modules/TestCMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# TEST_RUNNER
|
||||||
|
add_library(test_module_name
|
||||||
|
test_module_name.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(test_module_name
|
||||||
|
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||||
|
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||||
|
module_name
|
||||||
|
)
|
||||||
16
.template_files/modules/module_name.c
Normal file
16
.template_files/modules/module_name.c
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Author: username
|
||||||
|
* Date: todays_date
|
||||||
|
* filename: module_name.c
|
||||||
|
* description: module_purpose
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module_name.h"
|
||||||
|
|
||||||
|
// dumb test function
|
||||||
|
int add_two(int a)
|
||||||
|
{
|
||||||
|
int b = a;
|
||||||
|
b += 2;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
20
.template_files/modules/module_name.h
Normal file
20
.template_files/modules/module_name.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* @brief PUT_TEXT_HERE
|
||||||
|
* @details This file is...
|
||||||
|
* @author username
|
||||||
|
* @date todays_date
|
||||||
|
* @copyright None
|
||||||
|
* @file module_name.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef module_name
|
||||||
|
#define module_name
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function that adds two to a number
|
||||||
|
* @param a The first argument
|
||||||
|
*/
|
||||||
|
int add_two(int a);
|
||||||
|
|
||||||
|
#endif //module_name
|
||||||
0
.template_files/modules/modules_git_dir
Normal file
0
.template_files/modules/modules_git_dir
Normal file
38
.template_files/modules/test_module_name.cpp
Normal file
38
.template_files/modules/test_module_name.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Author: username
|
||||||
|
* Date: todays_date
|
||||||
|
* filename: test_module_name.c
|
||||||
|
* description: module_purpose
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CppUTest/CommandLineTestRunner.h"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "module_name.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_GROUP(test_module_name)
|
||||||
|
{
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void teardown()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(test_module_name, FirstTest)
|
||||||
|
{
|
||||||
|
FAIL("Fail me!");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(test_module_name, SecondTest)
|
||||||
|
{
|
||||||
|
STRCMP_EQUAL("hello", "world");
|
||||||
|
LONGS_EQUAL(1, 2);
|
||||||
|
CHECK(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -54,3 +54,4 @@ add_subdirectory(RegEdit)
|
||||||
add_subdirectory(usart)
|
add_subdirectory(usart)
|
||||||
add_subdirectory(TriacOut)
|
add_subdirectory(TriacOut)
|
||||||
add_subdirectory(load)
|
add_subdirectory(load)
|
||||||
|
add_subdirectory(Enable)
|
||||||
|
|
|
||||||
17
src/Enable/CMakeLists.txt
Normal file
17
src/Enable/CMakeLists.txt
Normal file
|
|
@ -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()
|
||||||
21
src/Enable/Enable.c
Normal file
21
src/Enable/Enable.c
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
24
src/Enable/Enable.h
Normal file
24
src/Enable/Enable.h
Normal file
|
|
@ -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
|
||||||
28
src/main.c
28
src/main.c
|
|
@ -11,12 +11,6 @@
|
||||||
|
|
||||||
#define F_CPU 3333333UL
|
#define F_CPU 3333333UL
|
||||||
|
|
||||||
//These defines are mostly useful for when you want you editors LSP server to
|
|
||||||
//function correctly.
|
|
||||||
//#ifndef __AVR_ATtiny404__
|
|
||||||
//#define __AVR_ATtiny404__
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//This can prevent issues with utils/delay.h library with the gcc toolchain
|
//This can prevent issues with utils/delay.h library with the gcc toolchain
|
||||||
#define __DELAY_BACKWARD_COMPATIBLE__
|
#define __DELAY_BACKWARD_COMPATIBLE__
|
||||||
|
|
||||||
|
|
@ -35,6 +29,16 @@
|
||||||
//Set the function pointer for the delay func
|
//Set the function pointer for the delay func
|
||||||
void (*Delay_MicroSeconds)(double us) = _delay_us;
|
void (*Delay_MicroSeconds)(double us) = _delay_us;
|
||||||
|
|
||||||
|
static void setEnablePinsHigh(void)
|
||||||
|
{
|
||||||
|
//Pins 12, 6 and 7 are all set high.
|
||||||
|
PORTA.DIR |= (1<<2); //PA2= pin 12
|
||||||
|
PORTB.DIR |= (1<<2)|(1<<3); //PB2 = pin 7, PB3 = pin 6
|
||||||
|
|
||||||
|
PORTA.OUT |= (1<<2);
|
||||||
|
PORTB.OUT |= (1<<2)|(1<<3);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
while(true){
|
while(true){
|
||||||
|
|
@ -42,20 +46,14 @@ int main(int argc, char **argv)
|
||||||
ZCD_Poll();
|
ZCD_Poll();
|
||||||
_delay_us(Tau);
|
_delay_us(Tau);
|
||||||
TriacOut_SetupPins();
|
TriacOut_SetupPins();
|
||||||
TriacOut_SetAllHigh();
|
TriacOut_SetAllHigh(); //Only G1 exists in High power mode
|
||||||
TriacOut_PulsePins(GatePulses[i]);
|
TriacOut_PulsePins(GatePulses[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The G1-G3 pins are low at this point.
|
//The G1 pin is low at this point.
|
||||||
_delay_ms(2500);
|
_delay_ms(2500);
|
||||||
ZCD_Poll();
|
ZCD_Poll();
|
||||||
TriacOut_SetupPins();
|
//setEnablePinsHigh();
|
||||||
TriacOut_SetAllHigh();
|
|
||||||
|
|
||||||
Load_HandleLoadPortA(ADC_LOAD1, 1);
|
|
||||||
Load_HandleLoadPortB(ADC_LOAD2, 3);
|
|
||||||
Load_HandleLoadPortB(ADC_LOAD3, 2);
|
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
; //Do nothing until new Power cycle/reset occurs
|
; //Do nothing until new Power cycle/reset occurs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
IMPORT_TEST_GROUP(simple_test);
|
IMPORT_TEST_GROUP(simple_test);
|
||||||
IMPORT_TEST_GROUP(test_ADC);
|
IMPORT_TEST_GROUP(test_ADC);
|
||||||
IMPORT_TEST_GROUP(test_RegEdit);
|
IMPORT_TEST_GROUP(test_RegEdit);
|
||||||
|
IMPORT_TEST_GROUP(test_Enable);
|
||||||
|
|
||||||
|
|
||||||
//START: main
|
//START: main
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
project(Tests)
|
project(Tests)
|
||||||
|
|
||||||
# TEST_DIRS
|
# TEST_DIRS
|
||||||
|
add_subdirectory(Enable)
|
||||||
#add_subdirectory(usart)
|
#add_subdirectory(usart)
|
||||||
add_subdirectory(MockADC)
|
add_subdirectory(MockADC)
|
||||||
add_subdirectory(ADC)
|
add_subdirectory(ADC)
|
||||||
|
|
@ -20,6 +21,7 @@ target_link_libraries(AllTests
|
||||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||||
# TEST_LINKS
|
# TEST_LINKS
|
||||||
|
test_Enable
|
||||||
test_ADC
|
test_ADC
|
||||||
test_RegEdit
|
test_RegEdit
|
||||||
simple_test
|
simple_test
|
||||||
|
|
|
||||||
11
tests/Enable/CMakeLists.txt
Normal file
11
tests/Enable/CMakeLists.txt
Normal file
|
|
@ -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
|
||||||
|
)
|
||||||
44
tests/Enable/test_Enable.cpp
Normal file
44
tests/Enable/test_Enable.cpp
Normal file
|
|
@ -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 <iotn404.h>
|
||||||
|
#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();
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue