Compare commits
No commits in common. "a09d7de1df4657d9db0897859fab863c9712b0b9" and "f551dd582b9cea00f28f69c162274ca6cf1217f3" have entirely different histories.
a09d7de1df
...
f551dd582b
24 changed files with 15 additions and 311 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -104,4 +104,3 @@ queuelogs
|
||||||
.generated_files/flags/attiny404
|
.generated_files/flags/attiny404
|
||||||
dist/default
|
dist/default
|
||||||
dist/attiny404/production
|
dist/attiny404/production
|
||||||
.cache/clangd/index
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
add_library(module_name STATIC
|
|
||||||
module_name.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(module_name PUBLIC
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
# 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
|
|
||||||
)
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
add_library(module_name STATIC
|
|
||||||
module_name.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(module_name PUBLIC
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
# 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
|
|
||||||
)
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* 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,4 +54,3 @@ add_subdirectory(RegEdit)
|
||||||
add_subdirectory(usart)
|
add_subdirectory(usart)
|
||||||
add_subdirectory(TriacOut)
|
add_subdirectory(TriacOut)
|
||||||
add_subdirectory(load)
|
add_subdirectory(load)
|
||||||
add_subdirectory(Enable)
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
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()
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
/**
|
|
||||||
* @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,6 +11,12 @@
|
||||||
|
|
||||||
#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__
|
||||||
|
|
||||||
|
|
@ -29,16 +35,6 @@
|
||||||
//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){
|
||||||
|
|
@ -46,14 +42,20 @@ int main(int argc, char **argv)
|
||||||
ZCD_Poll();
|
ZCD_Poll();
|
||||||
_delay_us(Tau);
|
_delay_us(Tau);
|
||||||
TriacOut_SetupPins();
|
TriacOut_SetupPins();
|
||||||
TriacOut_SetAllHigh(); //Only G1 exists in High power mode
|
TriacOut_SetAllHigh();
|
||||||
TriacOut_PulsePins(GatePulses[i]);
|
TriacOut_PulsePins(GatePulses[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The G1 pin is low at this point.
|
//The G1-G3 pins are low at this point.
|
||||||
_delay_ms(2500);
|
_delay_ms(2500);
|
||||||
ZCD_Poll();
|
ZCD_Poll();
|
||||||
//setEnablePinsHigh();
|
TriacOut_SetupPins();
|
||||||
|
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,7 +5,6 @@
|
||||||
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,7 +1,6 @@
|
||||||
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)
|
||||||
|
|
@ -21,7 +20,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# TEST_RUNNER
|
|
||||||
add_library(test_Enable
|
|
||||||
test_Enable.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(test_Enable
|
|
||||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
|
||||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
|
||||||
MockRegEdit
|
|
||||||
Enable
|
|
||||||
)
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* 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