Compare commits

..

33 Commits

Author SHA1 Message Date
jakeg00dwin d60e4d0586 Re-added the fake microseconds function for testing to pass. 2024-07-27 11:23:07 -07:00
jakeg00dwin 8eb5600499 removed the Delay_MicroSeconds_impl function and pointer set. 2024-07-27 11:04:30 -07:00
jakeg00dwin a35b806299 removed unused comments and substituted bit shifts with constants 2024-07-27 09:56:03 -07:00
jakeg00dwin 077b265be2 Uncommented the SetAllHigh test and added the constatnts 2024-07-27 09:52:29 -07:00
jakeg00dwin 2e26507d76 whitespace change 2024-07-27 09:51:11 -07:00
jakeg00dwin 098d34c853 changed tests to not use magic numbers 2024-07-27 09:51:06 -07:00
jakeg00dwin 1a5324aef6 cleaned up tests a bit more by extracting duplication in helper function 2024-07-27 09:44:42 -07:00
jakeg00dwin a061258669 Moved static helper function to top of tests. Extracted now uneeded expectations from tests. 2024-07-27 09:42:40 -07:00
jakeg00dwin f10ed49eb4 extracted the expectations into helper func for ZCD poll function. 2024-07-27 09:39:20 -07:00
jakeg00dwin d8403a4e82 Added call to helper function for ADC_INIT test 2024-07-27 09:28:29 -07:00
jakeg00dwin a926cc3836 setup usage of the new ReadReg function. 2024-07-27 09:28:17 -07:00
jakeg00dwin 4ab57eb948 Created a helper function for the ADC storage testing 2024-07-27 09:23:36 -07:00
jakeg00dwin 7deea50e91 white space change 2024-07-27 09:23:15 -07:00
jakeg00dwin 4b44d364e0 fixed issue with mock causing a segmentation fault from pointer deref with lower type (void *) --> (uint8_t *) 2024-07-27 09:22:32 -07:00
jakeg00dwin a92cdead2e fixed up ADC code + tests to make them pass 2024-07-27 09:06:23 -07:00
jakeg00dwin 5f547dd844 mplab change 2024-07-26 18:19:44 -07:00
jakeg00dwin 8117d3f890 fix of port storage 2024-07-26 18:19:36 -07:00
jakeg00dwin 6ecbe2f48a linking with the cpputest libs 2024-07-26 18:19:16 -07:00
jakeg00dwin 029b96aade Added two mock calls for the restore of the port state. 2024-07-26 18:19:05 -07:00
jakeg00dwin ce68803cef removed empty whitespace 2024-07-26 18:18:36 -07:00
jakeg00dwin f3c48ba643 Removed magic numbers from the Reading of the ZCD pin. 2024-07-26 18:18:23 -07:00
jakeg00dwin b987d81827 Cleaned up comments in the TriacOut module 2024-07-26 18:18:09 -07:00
jakeg00dwin 29426ad4a5 Updated to follow the mocks 2024-07-26 18:17:53 -07:00
jakeg00dwin f536024959 updated with new function for the RegEdit mock 2024-07-26 18:16:09 -07:00
jakeg00dwin af3a041df8 ignoring the cache and build dir now 2024-07-26 18:15:33 -07:00
jakeg00dwin c64fb08bec MPLABX config updates 2024-07-24 17:54:59 -07:00
jakeg00dwin 7c0fc29687 defined the F_CPU here 2024-07-24 17:54:41 -07:00
jakeg00dwin 437479b0b5 Commented out the unused function 2024-07-24 17:54:27 -07:00
jakeg00dwin 2be04980d1 Changed to using an initial value for u16. 2024-07-24 17:54:11 -07:00
jakeg00dwin 26993753fe Added more stuff to not track. 2024-07-24 17:21:57 -07:00
jakeg00dwin f80f61c9ff Converted to hybrid between MPLABX and Cmake for test harness. 2024-07-24 17:21:29 -07:00
jakeg00dwin 0a2c8b1dab Changed to using the reset default clock divider of 6. More stable given variable voltage, also reduces power consumption of attiny404. 2024-07-10 09:40:56 -07:00
jakeg00dwin c2424c47a8 updated new branch specifically for acting as the testing branch 2024-07-09 19:38:56 -07:00
116 changed files with 8327 additions and 503 deletions

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/RegEdit.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/ADC.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/TriacOut.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/main.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/RegEdit.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/zero_cross_detection.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/main.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/ADC.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/TriacOut.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/zero_cross_detection.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.c

View File

@ -1 +0,0 @@
$(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem /home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.c

5
.gitignore vendored
View File

@ -1 +1,6 @@
/docs/
build
dist/attiny404/production
.generated_files/flags/attiny404
.cache/clangd/index
build/default

View File

@ -0,0 +1,7 @@
add_library(module_name STATIC
module_name.c
)
target_include_directories(module_name PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

View 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
)

View 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;
}

View 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

View 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);
}

View File

View File

@ -0,0 +1,7 @@
add_library(module_name STATIC
module_name.c
)
target_include_directories(module_name PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

View 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
)

View 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;
}

View 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

View File

View 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);
}

76
CMakeLists.txt Normal file
View File

@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.20)
# Use the fancy version substitution
project(main
VERSION 1.0
DESCRIPTION "template for cmake + cpputest"
LANGUAGES C CXX
)
enable_testing()
set(TARGET_GROUP production CACHE STRING "Group to build")
if(MSVC OR MSYS OR MINGW)
message("### SETUP FOR WINDOWS ###")
add_definitions(-DWINDOWS)
else()
message("### SETUP FOR UNIX ###")
add_definitions(-DUNIX)
endif()
# For being able to used LSP
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Request C 17 standard features
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
# set(CMAKE_C_FLAGS "-Wall -Werror -Wpedantic")
# SETUP THE CXX flags for .cpp
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
# #######################################
# TESTING STUFF
# #######################################
if (UNIT_TESTING)
add_definitions(-DUNIT_TESTING)
if(DEFINED ENV{CPPUTEST_HOME})
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/lib)
set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
else()
find_package(PkgConfig REQUIRED)
pkg_search_module(CPPUTEST REQUIRED cpputest>=3.8)
message(STATUS "Found CppUTest version ${CPPUTEST_VERSION}")
endif()
include_directories(
${CPPUTEST_INCLUDE_DIRS}
/usr/include/c++/11/
./inc
./mocks
)
link_directories(${CPPUTEST_LIBRARIES})
add_subdirectory(mocks)
add_subdirectory(tests)
endif()
# #######################################
# PROJECT SPECIFIC
# #######################################
include_directories(
/usr/local/avr/avr/include
./inc
)
add_subdirectory(src)

View File

@ -949,7 +949,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = ./README.md ./
INPUT = ./README.md ./src/ ./inc/
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

View File

@ -1,4 +1,4 @@
# FG004_A(Low Power Mode)
# FG004_A(Triac Testing)
## Description
@ -38,6 +38,33 @@ RST:: Reset pin
## Project Layout
**Tree -L 1, output**
```
.
├── avr-gcc-toolchain.cmake
├── build
├── CMakeLists.txt
├── compile_commands.json -> ./build/compile_commands.json
├── docs
├── Doxyfile
├── inc
├── mocks
├── otto.sh
├── README.md
├── setup.sh
├── src
└── tests
6 directories, 7 files
```
The source code required to run/build the project is in the `/src` directory,
with the headers residing inside the `/inc` directory for most public modules.
All other directories are for supporting the development cycle and are used for
testitng the code base to ensure accuracy and quality. These are contained in
the `tests` and `mocks` directories.
Documentation that has been generated is inside the docs folder which contains
the html output that can be browswed via your regular web browser.
@ -66,3 +93,34 @@ elf files.
- cpputest(Unit testing harness.)
- Doxygen(For documentation)
- Git(For version control)
## Running Unit Tests
To run the cppunit tests you can use the included shell script inside a bash
shell.
```sh
echo "1" | ./otto.sh
```
The command runs the otto script which automates parts of the development cycle
such as running and building tests, compiling hex files and flashing the code
to a micro-controller using arvdude.
## Roadmap
Some stuff that still needs done.
- [X] Add ADC Mocked interface.
- [X] Write tests for ADC Mock
- [X] Write ZCD using ADC Mock.
- [ ] Write ADC version for devboard(328p)
- [ ] Write ADC version for ATtiny404
- [ ] Add GPIO mock?
- [ ] Add GPIO mock tests.
- [ ] Add GPIO module.
- [ ] Add Triac module.
- [ ] Add Triac tests.

57
avr-gcc-toolchain.cmake Normal file
View File

@ -0,0 +1,57 @@
# ###############################
# AVR-GCC toolchain file
# ###############################
# Specify the cross-compiler
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR avr)
# Without this flag, CMake is unable to pass the test compilation check
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# Specify the compiler and linker
#set(AVR_MCU atmega328p) # The old Classic
#set(AVR_MCU attiny85) # The older ATtiny series, avr25
set(AVR_MCU attiny404) # this is the avrxmega3 series
#set(AVR_MCU avr64dd28) # Newer DX series, avrxmega2
# The default frequency of an 328p devboard using the external crystal.
#set(F_CPU 16000000UL)
set(F_CPU 20000000UL)
#set(F_CPU 8000000)
#set(F_PER 3333333)
add_compile_definitions(F_CPU=${F_CPU})
# add_compile_definitions(MCU=atmega328p)
#add_compile_definitions(__AVR_ATmega328P__)
add_compile_definitions(__AVR_ATtiny404__)
# Set up the programmer for it
#set(PROGRAMMER usbasp-clone)
#set(PROGRAMMER arduino)
set(PROGRAMMER serialupdi)
# Set the Port for the programmer
set(PORT /dev/ttyUSB0)
# Define the toolchain executables
set(CMAKE_C_COMPILER avr-gcc)
set(CMAKE_CXX_COMPILER avr-g++)
set(CMAKE_ASM_COMPILER avr-gcc)
set(CMAKE_LINKER avr-ld)
set(CMAKE_OBJCOPY avr-objcopy)
set(CMAKE_SIZE avr-size)
# Define compile options
set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")
# Define the archiver and other tools
set(CMAKE_AR avr-ar)
set(CMAKE_RANLIB avr-ranlib)

Binary file not shown.

View File

@ -1,50 +0,0 @@
build/default/debug/ADC.o.d build/default/debug/ADC.o: ADC.c ADC.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h \
RegEdit.h c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h
ADC.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h:
RegEdit.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h:

Binary file not shown.

View File

@ -1,19 +0,0 @@
build/default/debug/RegEdit.o.d build/default/debug/RegEdit.o: RegEdit.c \
RegEdit.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h
RegEdit.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h:

Binary file not shown.

View File

@ -1,52 +0,0 @@
build/default/debug/TriacOut.o.d build/default/debug/TriacOut.o: \
TriacOut.c \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h \
TriacOut.h RegEdit.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h:
TriacOut.h:
RegEdit.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h:

Binary file not shown.

View File

@ -1,67 +0,0 @@
build/default/debug/main.o.d build/default/debug/main.o: main.c config.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h \
RegEdit.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h \
zero_cross_detection.h ADC.h TriacOut.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\util\delay.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\util\delay_basic.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\math.h
config.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h:
RegEdit.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h:
zero_cross_detection.h:
ADC.h:
TriacOut.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\io.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\sfr_defs.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\inttypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\features.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/xc8/avr/include/avr/iotn404.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\portpins.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\common.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\xmega.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\fuse.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\avr\lock.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\util\delay.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\util\delay_basic.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\math.h:

View File

@ -1,23 +0,0 @@
build/default/debug/zero_cross_detection.o.d \
build/default/debug/zero_cross_detection.o: zero_cross_detection.c \
zero_cross_detection.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h \
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h \
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h \
ADC.h
zero_cross_detection.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\alltypes.h:
c:\program\ files\microchip\xc8\v2.46\avr\avr\include\bits\stdint.h:
c:\program\ files\microchip\xc8\v2.46\avr\lib\gcc\avr\5.4.0\include\stdbool.h:
ADC.h:

Binary file not shown.

View File

@ -1,29 +0,0 @@
build/default/production/ADC.o.d build/default/production/ADC.o: ADC.c \
ADC.h C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h \
C:/Program\ Files/avr-gcc/avr/include/stdint.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h RegEdit.h \
C:/Program\ Files/avr-gcc/avr/include/avr/io.h \
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h \
C:/Program\ Files/avr-gcc/avr/include/inttypes.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h \
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h \
C:/Program\ Files/avr-gcc/avr/include/avr/common.h \
C:/Program\ Files/avr-gcc/avr/include/avr/version.h \
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h \
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h \
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h
ADC.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h:
C:/Program\ Files/avr-gcc/avr/include/stdint.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h:
RegEdit.h:
C:/Program\ Files/avr-gcc/avr/include/avr/io.h:
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h:
C:/Program\ Files/avr-gcc/avr/include/inttypes.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h:
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h:
C:/Program\ Files/avr-gcc/avr/include/avr/common.h:
C:/Program\ Files/avr-gcc/avr/include/avr/version.h:
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h:
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h:
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h:

Binary file not shown.

View File

@ -1,9 +0,0 @@
build/default/production/RegEdit.o.d build/default/production/RegEdit.o: \
RegEdit.c RegEdit.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h \
C:/Program\ Files/avr-gcc/avr/include/stdint.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h
RegEdit.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h:
C:/Program\ Files/avr-gcc/avr/include/stdint.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h:

Binary file not shown.

View File

@ -1,29 +0,0 @@
build/default/production/TriacOut.o.d build/default/production/TriacOut.o: \
TriacOut.c C:/Program\ Files/avr-gcc/avr/include/avr/io.h \
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h \
C:/Program\ Files/avr-gcc/avr/include/inttypes.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h \
C:/Program\ Files/avr-gcc/avr/include/stdint.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h \
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h \
C:/Program\ Files/avr-gcc/avr/include/avr/common.h \
C:/Program\ Files/avr-gcc/avr/include/avr/version.h \
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h \
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h \
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h TriacOut.h RegEdit.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h
C:/Program\ Files/avr-gcc/avr/include/avr/io.h:
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h:
C:/Program\ Files/avr-gcc/avr/include/inttypes.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h:
C:/Program\ Files/avr-gcc/avr/include/stdint.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h:
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h:
C:/Program\ Files/avr-gcc/avr/include/avr/common.h:
C:/Program\ Files/avr-gcc/avr/include/avr/version.h:
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h:
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h:
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h:
TriacOut.h:
RegEdit.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h:

Binary file not shown.

View File

@ -1,37 +0,0 @@
build/default/production/main.o.d build/default/production/main.o: main.c \
config.h C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h \
C:/Program\ Files/avr-gcc/avr/include/stdint.h RegEdit.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h \
zero_cross_detection.h ADC.h TriacOut.h \
C:/Program\ Files/avr-gcc/avr/include/avr/io.h \
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h \
C:/Program\ Files/avr-gcc/avr/include/inttypes.h \
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h \
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h \
C:/Program\ Files/avr-gcc/avr/include/avr/common.h \
C:/Program\ Files/avr-gcc/avr/include/avr/version.h \
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h \
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h \
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h \
C:/Program\ Files/avr-gcc/avr/include/util/delay.h \
C:/Program\ Files/avr-gcc/avr/include/util/delay_basic.h
config.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h:
C:/Program\ Files/avr-gcc/avr/include/stdint.h:
RegEdit.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h:
zero_cross_detection.h:
ADC.h:
TriacOut.h:
C:/Program\ Files/avr-gcc/avr/include/avr/io.h:
C:/Program\ Files/avr-gcc/avr/include/avr/sfr_defs.h:
C:/Program\ Files/avr-gcc/avr/include/inttypes.h:
C:/Program\ Files/Microchip/MPLABX/v6.20/packs/Microchip/ATtiny_DFP/3.1.260/include/avr/iotn404.h:
C:/Program\ Files/avr-gcc/avr/include/avr/portpins.h:
C:/Program\ Files/avr-gcc/avr/include/avr/common.h:
C:/Program\ Files/avr-gcc/avr/include/avr/version.h:
C:/Program\ Files/avr-gcc/avr/include/avr/xmega.h:
C:/Program\ Files/avr-gcc/avr/include/avr/fuse.h:
C:/Program\ Files/avr-gcc/avr/include/avr/lock.h:
C:/Program\ Files/avr-gcc/avr/include/util/delay.h:
C:/Program\ Files/avr-gcc/avr/include/util/delay_basic.h:

View File

@ -1,11 +0,0 @@
build/default/production/zero_cross_detection.o.d \
build/default/production/zero_cross_detection.o: zero_cross_detection.c \
zero_cross_detection.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h \
C:/Program\ Files/avr-gcc/avr/include/stdint.h \
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h ADC.h
zero_cross_detection.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdint.h:
C:/Program\ Files/avr-gcc/avr/include/stdint.h:
C:/Program\ Files/avr-gcc/lib/gcc/avr/14.1.0/include/stdbool.h:
ADC.h:

1
compile_commands.json Symbolic link
View File

@ -0,0 +1 @@
./build/compile_commands.json

0
inc/.git_dir Normal file
View File

71
inc/RegEdit.h Normal file
View File

@ -0,0 +1,71 @@
/**
* @brief Module/Interface for editing AVR registers
* @details This file is an interface to AVR registers or the avr/io.h
* @author Jake G
* @date 2024
* @copyright None
* @file RegEdit.h
*/
#ifndef REGEDIT_H
#define REGEDIT_H
#include <stdint.h>
#include <stdbool.h>
/**
* @brief Sets the value of the register to 0xFF.
* @param reg A pointer to a register
*/
void RegEdit_SetRegister(void *reg);
/**
* @brief Sets the value of the register to 0x00.
* @param reg A pointer to a register
*/
void RegEdit_ClearRegister(void *reg);
/**
* @brief Sets a single bit in the register.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
void RegEdit_SetBit(void *reg, uint8_t bit_num);
/**
* @brief Clears a single bit in the register.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
void RegEdit_ClearBit(void *reg, uint8_t bit_num);
/**
* @brief Checks if a single bit is set in the register.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num);
/**
* @brief Preforms logical OR Equals with the passed num.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
void RegEdit_OR_Num(void *reg, uint8_t num);
/**
* @brief Preforms logical AND Equals with the passed num.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
void RegEdit_AND_Num(void *reg, uint8_t num);
/**
* @brief Sets the register to the passed number value.
* @param reg A pointer to a register
* @param The bit's index or number in the register
*/
void RegEdit_SetNum(void *reg, uint8_t num);
#endif //REGEDIT_H

4713
inc/iotn404.h Normal file

File diff suppressed because it is too large Load Diff

0
mocks/.mocks_git_dir Normal file
View File

5
mocks/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
add_subdirectory(MockRegEdit)
add_subdirectory(MockADC)

View File

@ -0,0 +1,7 @@
add_library(MockADC STATIC
MockADC.c
)
target_include_directories(MockADC PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

64
mocks/MockADC/MockADC.c Normal file
View File

@ -0,0 +1,64 @@
/*
* Author: username
* Date: 2024
* filename: MockADC.c
* description: module_purpose
*/
#include "MockADC.h"
#include "CppUTestExt/MockSupport_c.h"
#define FAKESIZE 256
uint16_t fake_data[FAKESIZE];
int fake_index = 0;
void ADC_Init(uint8_t pin_num)
{
mock_c()->actualCall("ADC_Init")
->withUnsignedIntParameters("pin_num", pin_num);
}
void ADC_Enable(uint8_t pin_num)
{
mock_c()->actualCall("ADC_Enable")
->withUnsignedIntParameters("pin_num", pin_num);
}
void ADC_Disable()
{
mock_c()->actualCall("ADC_Disable");
}
uint16_t ADC_ReadValue_Impl(uint8_t pin_num)
{
mock_c()->actualCall("ADC_ReadValue_Impl")
->withUnsignedIntParameters("pin_num", pin_num);
if(fake_index == 0){
return 0;
}
return fake_data[--fake_index];
}
uint16_t (*ADC_ReadValue)(uint8_t pin_num) = ADC_ReadValue_Impl;
void MockADC_PushValue(uint16_t value){
if(fake_index >= FAKESIZE - 1){
return;
}
fake_data[fake_index++] = value;
}
void MockADC_ZeroIndex(void)
{
fake_index = 0;
}
int MockADC_GetIndex(void)
{
return fake_index;
}

30
mocks/MockADC/MockADC.h Normal file
View File

@ -0,0 +1,30 @@
/**
* @brief PUT_TEXT_HERE
* @details This file is...
* @author username
* @date todays_date
* @copyright None
* @file MOCKADC.h
*/
#ifndef MOCKADC_H
#define MOCKADC_H
#include <stdint.h>
#include <stdbool.h>
/**
* A function that adds two to a number
* @param a The first argument
*/
void ADC_Init(uint8_t pin_num);
void ADC_Enable(uint8_t pin_num);
void ADC_Disable();
extern uint16_t (*ADC_ReadValue)(uint8_t pin_num);
void MockADC_PushValue(uint16_t value);
void MockADC_ZeroIndex(void);
int MockADC_GetIndex(void);
#endif //MOCKADC_H

View File

@ -0,0 +1,12 @@
add_library(MockRegEdit STATIC
MockRegEdit.c
)
target_include_directories(MockRegEdit PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
target_link_libraries(MockRegEdit
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
)

View File

@ -0,0 +1,82 @@
/*
* Author: username
* Date: 2024
* filename: MockRegEdit.c
* description: module_purpose
*/
#include "MockRegEdit.h"
#include "CppUTestExt/MockSupport_c.h"
void RegEdit_SetRegister(void *reg)
{
mock_c()->actualCall("RegEdit_SetRegister")
->withPointerParameters("reg", reg);
}
void RegEdit_ClearRegister(void *reg)
{
mock_c()->actualCall("RegEdit_ClearRegister")
->withPointerParameters("reg", reg);
}
void RegEdit_SetBit(void *reg, uint8_t bit_num)
{
mock_c()->actualCall("RegEdit_SetBit")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("bit_num", bit_num);
}
void RegEdit_ClearBit(void *reg, uint8_t bit_num)
{
mock_c()->actualCall("RegEdit_ClearBit")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("bit_num", bit_num);
}
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num)
{
return mock_c()->actualCall("RegEdit_IsBitSet")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("bit_num", bit_num)
->returnBoolValueOrDefault(true);
//return mock_c()->returnBoolValueOrDefault(true);
}
void RegEdit_OR_Num(void *reg, uint8_t num)
{
mock_c()->actualCall("RegEdit_OR_Num")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("num", num);
}
void RegEdit_AND_Num(void *reg, uint8_t num)
{
mock_c()->actualCall("RegEdit_AND_Num")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("num", num);
}
void RegEdit_SetNum(void *reg, uint8_t num)
{
mock_c()->actualCall("RegEdit_SetNum")
->withPointerParameters("reg", reg)
->withUnsignedIntParameters("num", num);
}
uint8_t RegEdit_ReadReg(void *reg)
{
mock_c()->actualCall("RegEdit_ReadReg")
->withPointerParameters("reg", reg)
->returnUnsignedIntValueOrDefault(0);
//Return value is mock controlled. So it does actually return a uint8_t
}

View File

@ -0,0 +1,30 @@
/**
* @brief PUT_TEXT_HERE
* @details This file is...
* @author username
* @date todays_date
* @copyright None
* @file MockRegEdit.h
*/
#ifndef MOCKREGEDIT_H
#define MOCKREGEDIT_H
#include <stdint.h>
#include <stdbool.h>
void RegEdit_SetRegister(void *reg);
void RegEdit_ClearRegister(void *reg);
void RegEdit_SetBit(void *reg, uint8_t bit_num);
void RegEdit_ClearBit(void *reg, uint8_t bit_num);
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num);
void RegEdit_OR_Num(void *reg, uint8_t num);
void RegEdit_AND_Num(void *reg, uint8_t num);
void RegEdit_SetNum(void *reg, uint8_t num);
uint8_t RegEdit_ReadReg(void *reg);
#endif //MOCKREGEDIT_H

View File

@ -0,0 +1,51 @@
#include "u8_comparator.hpp"
#include "CppUTest/SimpleString.h"
/*
class MyTypeComparator : public MockNamedValueComparator
{
public:
virtual bool isEqual(const void* object1, const void* object2)
{
return object1 == object2;
}
virtual SimpleString valueToString(const void* object)
{
return StringFrom(object);
}
};
*/
bool UInt8PointerComparator::isEqual(const void* object1, const void* object2) {
const uint8_t* ptr1 = reinterpret_cast<const uint8_t*>(object1);
const uint8_t* ptr2 = reinterpret_cast<const uint8_t*>(object2);
return std::memcmp(ptr1, ptr2, sizeof(uint8_t)) == 0;
}
SimpleString UInt8PointerComparator::valueToString(const void* object) {
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(object);
return StringFromFormat("0x%02x", *ptr);
}
/*
bool UInt8PointerComparator::isEqual(const void* object1, const void* object2) const {
const uint8_t* ptr1 = static_cast<const uint8_t*>(object1);
const uint8_t* ptr2 = static_cast<const uint8_t*>(object2);
return std::memcmp(ptr1, ptr2, sizeof(uint8_t)) == 0;
}
SimpleString UInt8PointerComparator::valueToString(const void* object) const {
const uint8_t* ptr = static_cast<const uint8_t*>(object);
return StringFromFormat("0x%02x", *ptr);
}
*/
bool UInt8Comparator::isEqual(const void* object1, const void* object2) {
return (uint8_t*)object1 == (uint8_t *)object2;
}
SimpleString UInt8Comparator::valueToString(const void* object) {
//uint8_t value = reinterpret_cast<uint8_t>(object);
const uint8_t *ptr = reinterpret_cast<const uint8_t*>(object);
return StringFromFormat("0x%02x", *ptr);
}

View File

@ -0,0 +1,20 @@
#ifndef U8_COMPARATOR_H
#define U8_COMPARATOR_H
#include <cstdint>
#include <cstring>
#include <CppUTestExt/MockSupport.h>
class UInt8PointerComparator : public MockNamedValueComparator {
public:
virtual bool isEqual(const void* object1, const void* object2) override;
SimpleString valueToString(const void* object) override;
};
class UInt8Comparator : public MockNamedValueComparator {
public:
virtual bool isEqual(const void* object1, const void* object2) override;
SimpleString valueToString(const void* object) override;
};
#endif //U8_COMPARATOR_H

View File

@ -30,12 +30,12 @@ ifeq ($(TYPE_IMAGE), DEBUG_RUN)
IMAGE_TYPE=debug
OUTPUT_SUFFIX=elf
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
FINAL_IMAGE=${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
else
IMAGE_TYPE=production
OUTPUT_SUFFIX=hex
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
FINAL_IMAGE=${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
endif
ifeq ($(COMPARE_BUILD), true)
@ -51,17 +51,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
# Source Files Quoted if spaced
SOURCEFILES_QUOTED_IF_SPACED=main.c ADC.c RegEdit.c TriacOut.c zero_cross_detection.c load.c
SOURCEFILES_QUOTED_IF_SPACED=src/main.c src/ADC/ADC.c src/load/load.c src/RegEdit/RegEdit.c src/TriacOut/TriacOut.c src/usart/usart.c src/zero_cross_detection/zero_cross_detection.c
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/ADC.o ${OBJECTDIR}/RegEdit.o ${OBJECTDIR}/TriacOut.o ${OBJECTDIR}/zero_cross_detection.o ${OBJECTDIR}/load.o
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/ADC.o.d ${OBJECTDIR}/RegEdit.o.d ${OBJECTDIR}/TriacOut.o.d ${OBJECTDIR}/zero_cross_detection.o.d ${OBJECTDIR}/load.o.d
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/ADC/ADC.o ${OBJECTDIR}/src/load/load.o ${OBJECTDIR}/src/RegEdit/RegEdit.o ${OBJECTDIR}/src/TriacOut/TriacOut.o ${OBJECTDIR}/src/usart/usart.o ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o
POSSIBLE_DEPFILES=${OBJECTDIR}/src/main.o.d ${OBJECTDIR}/src/ADC/ADC.o.d ${OBJECTDIR}/src/load/load.o.d ${OBJECTDIR}/src/RegEdit/RegEdit.o.d ${OBJECTDIR}/src/TriacOut/TriacOut.o.d ${OBJECTDIR}/src/usart/usart.o.d ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d
# Object Files
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/ADC.o ${OBJECTDIR}/RegEdit.o ${OBJECTDIR}/TriacOut.o ${OBJECTDIR}/zero_cross_detection.o ${OBJECTDIR}/load.o
OBJECTFILES=${OBJECTDIR}/src/main.o ${OBJECTDIR}/src/ADC/ADC.o ${OBJECTDIR}/src/load/load.o ${OBJECTDIR}/src/RegEdit/RegEdit.o ${OBJECTDIR}/src/TriacOut/TriacOut.o ${OBJECTDIR}/src/usart/usart.o ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o
# Source Files
SOURCEFILES=main.c ADC.c RegEdit.c TriacOut.c zero_cross_detection.c load.c
SOURCEFILES=src/main.c src/ADC/ADC.c src/load/load.c src/RegEdit/RegEdit.c src/TriacOut/TriacOut.c src/usart/usart.c src/zero_cross_detection/zero_cross_detection.c
@ -82,84 +82,96 @@ FIXDEPS=fixDeps
ifneq ($(INFORMATION_MESSAGE), )
@echo $(INFORMATION_MESSAGE)
endif
${MAKE} -f nbproject/Makefile-attiny404.mk ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
${MAKE} -f nbproject/Makefile-attiny404.mk ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
MP_PROCESSOR_OPTION=ATtiny404
# ------------------------------------------------------------------------------------
# Rules for buildStep: compile
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
${OBJECTDIR}/main.o: main.c .generated_files/flags/attiny404/898e709c16268741653512f765f05795b54671b8 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/main.o.d
@${RM} ${OBJECTDIR}/main.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/main.o.d" -MT "${OBJECTDIR}/main.o.d" -MT ${OBJECTDIR}/main.o -o ${OBJECTDIR}/main.o main.c
${OBJECTDIR}/src/main.o: src/main.c .generated_files/flags/attiny404/973d092a94f4e52564d7ce86e36f69bac418b540 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src"
@${RM} ${OBJECTDIR}/src/main.o.d
@${RM} ${OBJECTDIR}/src/main.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/main.o.d" -MT "${OBJECTDIR}/src/main.o.d" -MT ${OBJECTDIR}/src/main.o -o ${OBJECTDIR}/src/main.o src/main.c
${OBJECTDIR}/ADC.o: ADC.c .generated_files/flags/attiny404/3531910cbc4dc67dbbc4c48de20725b7a0f45ade .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/ADC.o.d
@${RM} ${OBJECTDIR}/ADC.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/ADC.o.d" -MT "${OBJECTDIR}/ADC.o.d" -MT ${OBJECTDIR}/ADC.o -o ${OBJECTDIR}/ADC.o ADC.c
${OBJECTDIR}/src/ADC/ADC.o: src/ADC/ADC.c .generated_files/flags/attiny404/150e4fdaa98cfffac1465aa4432198132057d9bf .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/ADC"
@${RM} ${OBJECTDIR}/src/ADC/ADC.o.d
@${RM} ${OBJECTDIR}/src/ADC/ADC.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/ADC/ADC.o.d" -MT "${OBJECTDIR}/src/ADC/ADC.o.d" -MT ${OBJECTDIR}/src/ADC/ADC.o -o ${OBJECTDIR}/src/ADC/ADC.o src/ADC/ADC.c
${OBJECTDIR}/RegEdit.o: RegEdit.c .generated_files/flags/attiny404/6a9f39408c4d848bc358965a0bab7b09e4f4f96f .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/RegEdit.o.d
@${RM} ${OBJECTDIR}/RegEdit.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/RegEdit.o.d" -MT "${OBJECTDIR}/RegEdit.o.d" -MT ${OBJECTDIR}/RegEdit.o -o ${OBJECTDIR}/RegEdit.o RegEdit.c
${OBJECTDIR}/src/load/load.o: src/load/load.c .generated_files/flags/attiny404/a9b0751a67570a1e928536e1873e69792184c61f .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/load"
@${RM} ${OBJECTDIR}/src/load/load.o.d
@${RM} ${OBJECTDIR}/src/load/load.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/load/load.o.d" -MT "${OBJECTDIR}/src/load/load.o.d" -MT ${OBJECTDIR}/src/load/load.o -o ${OBJECTDIR}/src/load/load.o src/load/load.c
${OBJECTDIR}/TriacOut.o: TriacOut.c .generated_files/flags/attiny404/629b6032616bbf96e42829bc0a3203c42f2e42a1 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/TriacOut.o.d
@${RM} ${OBJECTDIR}/TriacOut.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/TriacOut.o.d" -MT "${OBJECTDIR}/TriacOut.o.d" -MT ${OBJECTDIR}/TriacOut.o -o ${OBJECTDIR}/TriacOut.o TriacOut.c
${OBJECTDIR}/src/RegEdit/RegEdit.o: src/RegEdit/RegEdit.c .generated_files/flags/attiny404/59d483a95ae705703b3e2355352363eaaeec2de9 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/RegEdit"
@${RM} ${OBJECTDIR}/src/RegEdit/RegEdit.o.d
@${RM} ${OBJECTDIR}/src/RegEdit/RegEdit.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/RegEdit/RegEdit.o.d" -MT "${OBJECTDIR}/src/RegEdit/RegEdit.o.d" -MT ${OBJECTDIR}/src/RegEdit/RegEdit.o -o ${OBJECTDIR}/src/RegEdit/RegEdit.o src/RegEdit/RegEdit.c
${OBJECTDIR}/zero_cross_detection.o: zero_cross_detection.c .generated_files/flags/attiny404/c044dab60059f8a60aab0012bce6eb0f44acd683 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/zero_cross_detection.o.d
@${RM} ${OBJECTDIR}/zero_cross_detection.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/zero_cross_detection.o.d" -MT "${OBJECTDIR}/zero_cross_detection.o.d" -MT ${OBJECTDIR}/zero_cross_detection.o -o ${OBJECTDIR}/zero_cross_detection.o zero_cross_detection.c
${OBJECTDIR}/src/TriacOut/TriacOut.o: src/TriacOut/TriacOut.c .generated_files/flags/attiny404/fc108d3f19af213d7ffab7fc8b221e2259566895 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/TriacOut"
@${RM} ${OBJECTDIR}/src/TriacOut/TriacOut.o.d
@${RM} ${OBJECTDIR}/src/TriacOut/TriacOut.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/TriacOut/TriacOut.o.d" -MT "${OBJECTDIR}/src/TriacOut/TriacOut.o.d" -MT ${OBJECTDIR}/src/TriacOut/TriacOut.o -o ${OBJECTDIR}/src/TriacOut/TriacOut.o src/TriacOut/TriacOut.c
${OBJECTDIR}/load.o: load.c .generated_files/flags/attiny404/e28cc3f4f7c4664001ea60f6fcf7cc157eb1ce02 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/load.o.d
@${RM} ${OBJECTDIR}/load.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/load.o.d" -MT "${OBJECTDIR}/load.o.d" -MT ${OBJECTDIR}/load.o -o ${OBJECTDIR}/load.o load.c
${OBJECTDIR}/src/usart/usart.o: src/usart/usart.c .generated_files/flags/attiny404/acddbea26e43a3ffb0db36cf85caa326e95b16a1 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/usart"
@${RM} ${OBJECTDIR}/src/usart/usart.o.d
@${RM} ${OBJECTDIR}/src/usart/usart.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/usart/usart.o.d" -MT "${OBJECTDIR}/src/usart/usart.o.d" -MT ${OBJECTDIR}/src/usart/usart.o -o ${OBJECTDIR}/src/usart/usart.o src/usart/usart.c
${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o: src/zero_cross_detection/zero_cross_detection.c .generated_files/flags/attiny404/94f26d3715aa7c0633c6bcffd6ff0f4f0cacb041 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/zero_cross_detection"
@${RM} ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d
@${RM} ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -g -DDEBUG -gdwarf-2 -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d" -MT "${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d" -MT ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o -o ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o src/zero_cross_detection/zero_cross_detection.c
else
${OBJECTDIR}/main.o: main.c .generated_files/flags/attiny404/68dda87a357f8de2238228cdfd349eeb9030ddcc .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/main.o.d
@${RM} ${OBJECTDIR}/main.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/main.o.d" -MT "${OBJECTDIR}/main.o.d" -MT ${OBJECTDIR}/main.o -o ${OBJECTDIR}/main.o main.c
${OBJECTDIR}/src/main.o: src/main.c .generated_files/flags/attiny404/b8ed6b97ab4da1f011bb7a3c8de719d5b59843ed .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src"
@${RM} ${OBJECTDIR}/src/main.o.d
@${RM} ${OBJECTDIR}/src/main.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/main.o.d" -MT "${OBJECTDIR}/src/main.o.d" -MT ${OBJECTDIR}/src/main.o -o ${OBJECTDIR}/src/main.o src/main.c
${OBJECTDIR}/ADC.o: ADC.c .generated_files/flags/attiny404/981755a239273dc10a1bcf0834eedc4b1adbc64b .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/ADC.o.d
@${RM} ${OBJECTDIR}/ADC.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/ADC.o.d" -MT "${OBJECTDIR}/ADC.o.d" -MT ${OBJECTDIR}/ADC.o -o ${OBJECTDIR}/ADC.o ADC.c
${OBJECTDIR}/src/ADC/ADC.o: src/ADC/ADC.c .generated_files/flags/attiny404/225c4037d222727e653624c1a5da19d0dee9de9a .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/ADC"
@${RM} ${OBJECTDIR}/src/ADC/ADC.o.d
@${RM} ${OBJECTDIR}/src/ADC/ADC.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/ADC/ADC.o.d" -MT "${OBJECTDIR}/src/ADC/ADC.o.d" -MT ${OBJECTDIR}/src/ADC/ADC.o -o ${OBJECTDIR}/src/ADC/ADC.o src/ADC/ADC.c
${OBJECTDIR}/RegEdit.o: RegEdit.c .generated_files/flags/attiny404/1cbc965ace553fb8a714ee81eec7817e6113fad9 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/RegEdit.o.d
@${RM} ${OBJECTDIR}/RegEdit.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/RegEdit.o.d" -MT "${OBJECTDIR}/RegEdit.o.d" -MT ${OBJECTDIR}/RegEdit.o -o ${OBJECTDIR}/RegEdit.o RegEdit.c
${OBJECTDIR}/src/load/load.o: src/load/load.c .generated_files/flags/attiny404/5e17c7ac963928818c89feccfcde0b0a2e93b9de .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/load"
@${RM} ${OBJECTDIR}/src/load/load.o.d
@${RM} ${OBJECTDIR}/src/load/load.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/load/load.o.d" -MT "${OBJECTDIR}/src/load/load.o.d" -MT ${OBJECTDIR}/src/load/load.o -o ${OBJECTDIR}/src/load/load.o src/load/load.c
${OBJECTDIR}/TriacOut.o: TriacOut.c .generated_files/flags/attiny404/bb3e00a740269277700d8323e35d491752ce69b4 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/TriacOut.o.d
@${RM} ${OBJECTDIR}/TriacOut.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/TriacOut.o.d" -MT "${OBJECTDIR}/TriacOut.o.d" -MT ${OBJECTDIR}/TriacOut.o -o ${OBJECTDIR}/TriacOut.o TriacOut.c
${OBJECTDIR}/src/RegEdit/RegEdit.o: src/RegEdit/RegEdit.c .generated_files/flags/attiny404/df76354fe7970e12f4d9e94d917742addacc88b6 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/RegEdit"
@${RM} ${OBJECTDIR}/src/RegEdit/RegEdit.o.d
@${RM} ${OBJECTDIR}/src/RegEdit/RegEdit.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/RegEdit/RegEdit.o.d" -MT "${OBJECTDIR}/src/RegEdit/RegEdit.o.d" -MT ${OBJECTDIR}/src/RegEdit/RegEdit.o -o ${OBJECTDIR}/src/RegEdit/RegEdit.o src/RegEdit/RegEdit.c
${OBJECTDIR}/zero_cross_detection.o: zero_cross_detection.c .generated_files/flags/attiny404/80f84bc10112480364a61baa6db5df64815205c6 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/zero_cross_detection.o.d
@${RM} ${OBJECTDIR}/zero_cross_detection.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/zero_cross_detection.o.d" -MT "${OBJECTDIR}/zero_cross_detection.o.d" -MT ${OBJECTDIR}/zero_cross_detection.o -o ${OBJECTDIR}/zero_cross_detection.o zero_cross_detection.c
${OBJECTDIR}/src/TriacOut/TriacOut.o: src/TriacOut/TriacOut.c .generated_files/flags/attiny404/bff14854247e779f0a090048c305a18397aaf78a .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/TriacOut"
@${RM} ${OBJECTDIR}/src/TriacOut/TriacOut.o.d
@${RM} ${OBJECTDIR}/src/TriacOut/TriacOut.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/TriacOut/TriacOut.o.d" -MT "${OBJECTDIR}/src/TriacOut/TriacOut.o.d" -MT ${OBJECTDIR}/src/TriacOut/TriacOut.o -o ${OBJECTDIR}/src/TriacOut/TriacOut.o src/TriacOut/TriacOut.c
${OBJECTDIR}/load.o: load.c .generated_files/flags/attiny404/d847cc8c176fc0b45a6bf3e12f13d4dec981239a .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}"
@${RM} ${OBJECTDIR}/load.o.d
@${RM} ${OBJECTDIR}/load.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/load.o.d" -MT "${OBJECTDIR}/load.o.d" -MT ${OBJECTDIR}/load.o -o ${OBJECTDIR}/load.o load.c
${OBJECTDIR}/src/usart/usart.o: src/usart/usart.c .generated_files/flags/attiny404/dc8767db7ed4e382808fc769a31f4b84fb9db449 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/usart"
@${RM} ${OBJECTDIR}/src/usart/usart.o.d
@${RM} ${OBJECTDIR}/src/usart/usart.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/usart/usart.o.d" -MT "${OBJECTDIR}/src/usart/usart.o.d" -MT ${OBJECTDIR}/src/usart/usart.o -o ${OBJECTDIR}/src/usart/usart.o src/usart/usart.c
${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o: src/zero_cross_detection/zero_cross_detection.c .generated_files/flags/attiny404/1896f92e23988334cd2f227686e6376a49636983 .generated_files/flags/attiny404/da39a3ee5e6b4b0d3255bfef95601890afd80709
@${MKDIR} "${OBJECTDIR}/src/zero_cross_detection"
@${RM} ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d
@${RM} ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -x c -D__$(MP_PROCESSOR_OPTION)__ -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -DXPRJ_attiny404=$(CND_CONF) $(COMPARISON_BUILD) -gdwarf-3 -mno-const-data-in-progmem -MD -MP -MF "${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d" -MT "${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o.d" -MT ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o -o ${OBJECTDIR}/src/zero_cross_detection/zero_cross_detection.o src/zero_cross_detection/zero_cross_detection.c
endif
@ -178,17 +190,17 @@ endif
# ------------------------------------------------------------------------------------
# Rules for buildStep: link
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${DISTDIR}
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/fg004a.X.${IMAGE_TYPE}.map -D__DEBUG=1 -DXPRJ_attiny404=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" -gdwarf-2 -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -gdwarf-3 -mno-const-data-in-progmem $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} -o ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--defsym=__MPLAB_DEBUG=1,--defsym=__DEBUG=1
@${RM} ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.hex
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.map -D__DEBUG=1 -DXPRJ_attiny404=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" -gdwarf-2 -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -gdwarf-3 -mno-const-data-in-progmem $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} -o ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--defsym=__MPLAB_DEBUG=1,--defsym=__DEBUG=1
@${RM} ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.hex
else
${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${DISTDIR}
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/fg004a.X.${IMAGE_TYPE}.map -DXPRJ_attiny404=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -Wall -gdwarf-3 -mno-const-data-in-progmem $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} -o ${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -Wl,--start-group -Wl,-lm -Wl,--end-group
${MP_CC_DIR}/avr-objcopy -O ihex "${DISTDIR}/fg004a.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX}" "${DISTDIR}/fg004a.X.${IMAGE_TYPE}.hex"
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.map -DXPRJ_attiny404=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="${DFP_DIR}/xc8" -Wl,--gc-sections -O1 -ffunction-sections -fdata-sections -fshort-enums -fno-common -funsigned-char -funsigned-bitfields -I"src/ADC" -I"src/load" -I"src/RegEdit" -I"src/TriacOut" -I"src/zero_cross_detection" -I"src/usart" -I"inc" -Wall -gdwarf-3 -mno-const-data-in-progmem $(COMPARISON_BUILD) -Wl,--memorysummary,${DISTDIR}/memoryfile.xml -o ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} -o ${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -Wl,--start-group -Wl,-lm -Wl,--end-group
${MP_CC_DIR}/avr-objcopy -O ihex "${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX}" "${DISTDIR}/fg004a_test.X.${IMAGE_TYPE}.hex"
endif

View File

@ -1,13 +1,13 @@
#
#Mon Jul 15 11:39:10 PDT 2024
#Wed Jul 24 17:51:50 PDT 2024
attiny404.com-microchip-mplab-mdbcore-PK5Tool-PK5ToolImpl.md5=8ed9aa4326bfc0c1a849e697826741b7
attiny404.languagetoolchain.version=2.46
attiny404.com-microchip-mplab-nbide-toolchain-xc8-XC8LanguageToolchain.md5=bf89cdcdd6c0a49174fe4b605ef2b42d
conf.ids=,attiny404
host.id=2ov5-ff4p-rv
configurations-xml=a8df58f0d8aebafa503466e35cdcf228
configurations-xml=635c55ff9add3625ec6ff71ce27eca38
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=f612087c95360c842296d189edfe3321
attiny404.languagetoolchain.dir=/opt/microchip/xc8/v2.46/bin
proj.dir=/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X
proj.dir=/home/ronin/Documents/projects/freelance/laith_naaman/fg004a_test.X
attiny404.Pack.dfplocation=/opt/microchip/mplabx/v6.20/packs/Microchip/ATtiny_DFP/3.1.260
host.platform=linux

View File

@ -24,7 +24,7 @@ CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=fg004a.X
PROJECTNAME=fg004a_test.X
# Active Configuration
DEFAULTCONF=attiny404

View File

@ -6,9 +6,9 @@
CND_BASEDIR=`pwd`
# default configuration
CND_ARTIFACT_DIR_default=dist/default/production
CND_ARTIFACT_NAME_default=fg004a.X.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/fg004a.X.production.hex
CND_ARTIFACT_NAME_default=fg004a_test.X.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/fg004a_test.X.production.hex
# attiny404 configuration
CND_ARTIFACT_DIR_attiny404=dist/attiny404/production
CND_ARTIFACT_NAME_attiny404=fg004a.X.production.hex
CND_ARTIFACT_PATH_attiny404=dist/attiny404/production/fg004a.X.production.hex
CND_ARTIFACT_NAME_attiny404=fg004a_test.X.production.hex
CND_ARTIFACT_PATH_attiny404=dist/attiny404/production/fg004a_test.X.production.hex

View File

@ -4,12 +4,13 @@
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>config.h</itemPath>
<itemPath>zero_cross_detection.h</itemPath>
<itemPath>RegEdit.h</itemPath>
<itemPath>ADC.h</itemPath>
<itemPath>TriacOut.h</itemPath>
<itemPath>load.h</itemPath>
<itemPath>src/ADC/ADC.h</itemPath>
<itemPath>src/load/load.h</itemPath>
<itemPath>src/RegEdit/RegEdit.h</itemPath>
<itemPath>src/TriacOut/TriacOut.h</itemPath>
<itemPath>src/usart/usart.h</itemPath>
<itemPath>src/zero_cross_detection/zero_cross_detection.h</itemPath>
<itemPath>inc/config.h</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
@ -23,12 +24,13 @@
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>ADC.c</itemPath>
<itemPath>RegEdit.c</itemPath>
<itemPath>TriacOut.c</itemPath>
<itemPath>zero_cross_detection.c</itemPath>
<itemPath>load.c</itemPath>
<itemPath>src/main.c</itemPath>
<itemPath>src/ADC/ADC.c</itemPath>
<itemPath>src/load/load.c</itemPath>
<itemPath>src/RegEdit/RegEdit.c</itemPath>
<itemPath>src/TriacOut/TriacOut.c</itemPath>
<itemPath>src/usart/usart.c</itemPath>
<itemPath>src/zero_cross_detection/zero_cross_detection.c</itemPath>
</logicalFolder>
</logicalFolder>
<sourceRootList>
@ -357,7 +359,8 @@
<property key="default-char-type" value="true"/>
<property key="define-macros" value=""/>
<property key="disable-optimizations" value="false"/>
<property key="extra-include-directories" value=""/>
<property key="extra-include-directories"
value="src/ADC;src/load;src/RegEdit;src/TriacOut;src/zero_cross_detection;src/usart;inc"/>
<property key="favor-optimization-for" value="-speed,+space"/>
<property key="garbage-collect-data" value="true"/>
<property key="garbage-collect-functions" value="true"/>

View File

@ -2,6 +2,11 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
<group>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a_test.X/src/load/load.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a_test.X/src/zero_cross_detection/zero_cross_detection.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a_test.X/src/main.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a_test.X/src/usart/usart.c</file>
</group>
</open-files>
</project-private>

335
otto.sh Normal file
View File

@ -0,0 +1,335 @@
#!/bin/sh
# Author: Jake Goodwin
# Date: 2024
# Filename: otto.sh
AVR_TC="$(pwd)/avr-gcc-toolchain.cmake"
CMAKE_VERBOSE="ON"
CROSS_COMPILE=1
TEMPLATE_FILES=".template_files"
MODULE_DIR="${TEMPLATE_FILES}/modules"
add_compile_commands () {
if [ -f ./compile_commands.json ]; then
echo "compile_commands.json already exists!\n"
else
echo "Creating new symlink for compile commands!\n"
ln -s ./build/compile_commands.json ./compile_commands.json
fi
}
clear_cmake_cache () {
cd ./build
rm -rf CMakeCache.txt CMakeFiles/
}
does_module_exist () {
local basename="$1"
if [ -d "src/${basename}" ]; then
echo "1"
else
echo "0"
fi
}
does_mock_exist () {
local basename="$1"
if [ -d "mocks/${basename}" ]; then
echo "1"
else
echo "0"
fi
}
add_module_to_cmakes () {
local basename="$1"
echo "add_subdirectory(${basename})" >> ./src/CMakeLists.txt
# Tests cmake file needs to be edited in place.
sed -i'' "s/# TEST_DIRS.*$/# TEST_DIRS\r\nadd_subdirectory(${basename})/g" ./tests/CMakeLists.txt
sed -i'' "s/# TEST_LINKS.*$/# TEST_LINKS\r\n\ttest_${basename}/g" ./tests/CMakeLists.txt
}
remove_module_from_cmakes () {
local basename="$1"
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./src/CMakeLists.txt
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./tests/CMakeLists.txt
sed -i'' "s/^.*test_${basename}.*$//g" ./tests/CMakeLists.txt
}
git_add_module () {
local basename="$1"
read -p "Auto add to git?(y/n):" CHOICE
if [ "${CHOICE}" = "n" ]; then
echo "not being added!"
return 0
fi
modsrc_dir="./src/${basename}"
modtest_dir="./tests/${basename}"
# Now we add the new files to the git tracked files
git add ${modsrc_dir}/*
git add ${modsrc_dir}
git add ${modtest_dir}/*
git add ${modtest_dir}
git add ./src/CMakeLists.txt
git add ./tests/CMakeLists.txt
}
git_remove_module () {
local basename="$1"
read -p "Auto del from git?(y/n):" CHOICE
if [ "${CHOICE}" -eq "n" ]; then
echo "not being removed!"
return 0
fi
modsrc_dir="./src/${basename}"
modtest_dir="./tests/${basename}"
# Now we add the new files to the git tracked files
git rm -r ${modsrc_dir}/*
git rm -r ${modsrc_dir}
git rm -r ${modtest_dir}/*
git rm -r ${modtest_dir}
git rm -r ./src/CMakeLists.txt
git rm -r ./tests/CMakeLists.txt
}
add_mock_module () {
read -p "Enter the name of the module:" modname
result=$(does_mock_exist "$modname")
if [ "${result}" -eq "1" ]; then
echo "Module already exists!"
echo "Exiting without changing anything"
exit
fi
modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g')
modsrc_dir="./mocks/${modname}"
modtest_dir="./tests/${modname}"
echo "creating: ${modsrc_dir}, ${modtest_dir}"
mkdir $modsrc_dir
mkdir $modtest_dir
#copy the template files.
echo "copying & customizing template files..."
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
# Add the module to the cmake lists files.
add_module_to_cmakes "${modname}"
echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir
tree -L 2 $modtest_dir
# Now we add the new files to the git tracked files
git_add_module "${modname}"
}
add_new_module () {
read -p "Enter the name of the module:" modname
result=$(does_module_exist "$modname")
if [ "${result}" -eq "1" ]; then
echo "Module already exists!"
echo "Exiting without changing anything"
exit
fi
modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g')
modsrc_dir="./src/${modname}"
modtest_dir="./tests/${modname}"
echo "creating: ${modsrc_dir}, ${modtest_dir}"
mkdir $modsrc_dir
mkdir $modtest_dir
#copy the template files.
echo "copying & customizing template files..."
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
# Add the module to the cmake lists files.
add_module_to_cmakes "${modname}"
echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir
tree -L 2 $modtest_dir
# Now we add the new files to the git tracked files
git_add_module "${modname}"
}
del_module () {
read -p "Enter the name of the module:" modname
rm -r ./tests/${modname}
rm -r ./src/${modname}
remove_module_from_cmakes "${modname}"
}
cross_compile () {
echo "ERROR: Currently no toolchain / target!"
}
build_release() {
clear_cmake_cache
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make
}
build_main () {
clear_cmake_cache
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make main
}
build_hex () {
clear_cmake_cache
CMAKE_ARGS="-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE}"
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
cmake ${CMAKE_ARGS} ../
make all
make hex
}
build_hex_optimized () {
clear_cmake_cache
CMAKE_ARGS="-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE}"
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
cmake ${CMAKE_ARGS} ../
make all
make hex-release
}
flash_avr () {
build_hex_optimized
make upload
}
run_c_tests () {
clear_cmake_cache
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make AllTests
make Mock_Tests
make TriacTests
./tests/AllTests -v -c
./tests/Mock_Tests -v -c
./tests/TriacTests -v -c
}
print_menu () {
echo "BUILD MENU:"
echo "0. Add Mock Module"
echo "1. Run Tests"
echo "2. Build Project(hex)"
echo "3. Build for release(hex)"
echo "4. Flash to AVR"
echo "5. Add new module to project"
echo "6. Delete module from project"
echo "7. Exit"
}
main() {
add_compile_commands
valid_choice=false
while [ "$valid_choice" != true ]; do
print_menu
read -p "Enter your choice: " choice
case $choice in
0)
echo "You selected Option 0"
valid_choice=true
add_mock_module
;;
1)
echo "You selected Option 1"
valid_choice=true
run_c_tests
;;
2)
echo "You selected Option 2"
valid_choice=true
build_hex
;;
3)
echo "You selected Option 3"
valid_choice=true
build_hex_optimized
;;
4)
echo "You selected Option 4"
valid_choice=true
flash_avr
;;
5)
echo "You selected Option 5"
valid_choice=true
add_new_module
;;
6)
echo "You selected Option 6"
valid_choice=true
del_module
;;
7)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice. Please select a valid option."
;;
esac
done
}
main

File diff suppressed because it is too large Load Diff

86
setup.sh Normal file
View File

@ -0,0 +1,86 @@
#!/bin/sh
#Author: Jake G
#Date: 2024
#Filename: setup.sh
PKG_MNGR=""
DEBIAN=0
FBSD=0
SYSINSTALL=0
DEV_UTILS="vim tmux fzf"
install_dev_utils () {
ICMD=""
if [ $DEBIAN -eq 1 ]; then
ICMD="sudo apt install"
elif [ $FBSD -eq 1 ]; then
ICMD="sudo pkg install"
fi
for util in $DEV_UTILS
do
${ICMD} ${util}
done
}
check_os () {
if [ -f /etc/debian_version ]; then
DEBIAN=1
elif [ -f /etc/freebsd-update.conf ]; then
FBSD=1
fi
}
remove_template_examples () {
echo "does nothing right now"
}
install_needed_dependencies () {
# Check the OS
echo "checking the OS..."
# If it's debian based then apt install
# If it's freeBSD then pkg
# If it's windows....you're SOL
}
create_project_symlinks () {
# Allows the clangd LSP to find it.
ln -s ./build/compile_commands.json ./compile_commands.json
}
build_cpputest () {
git submodule add https://github.com/cpputest/cpputest.git
git sumodule status
cd ./cpputest/build
cmake ../
if [ SYSINSTALL -eq 1]; then
make install
else
make
fi
}
# The default setup stuff.
default () {
remove_template_examples
install_needed_dependencies
create_project_symlinks
}
setup() {
echo "Setting up env"
check_os
install_dev_utils
}
setup

View File

@ -5,6 +5,10 @@
* description: module_purpose
*/
#ifndef __AVR_ATtiny404__
#define __AVR_ATtiny404__
#endif
#include "ADC.h"
#include "RegEdit.h"
#include "avr/io.h"
@ -22,12 +26,13 @@ static bool IsInvalidPin(uint8_t pin_num){
void ADC_Init(uint8_t pin_num)
{
//Save the porta status.
porta_out = PORTA.OUT;
porta_dir = PORTA.DIR;
if(IsInvalidPin(pin_num)){return;}
//Save the porta status.
porta_out = RegEdit_ReadReg((void *) &PORTA.OUT);
porta_dir = RegEdit_ReadReg((void *) &PORTA.DIR);
//set the direction to input
RegEdit_SetBit((void *) &PORTA.DIRCLR, pin_num);
@ -35,24 +40,19 @@ void ADC_Init(uint8_t pin_num)
RegEdit_SetBit((void *) &PORTA.OUTCLR, pin_num);
//Disable input buffer
//We do some kind of nasty address addition but it saves
//memory and means we don't need a switch statement.
//We do some kinda nasty address addition but it saves
//memory and means we don't need a switch statment.
//PORT_ISC_INPUT_DISABLE_gc
RegEdit_SetBit(
(void *) (&PORTA.PIN0CTRL)+pin_num,
PORT_ISC_INPUT_DISABLE_gc
);
/*
RegEdit_OR_Num(
(void *) (&PORTA.PIN0CTRL)+pin_num,
PORT_ISC_INPUT_DISABLE_gc
);*/
//Ensure we use full 10bit resolution
RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
//RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
//Use VDD as our voltage refernce.
RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
//RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
}
@ -78,8 +78,8 @@ void ADC_Disable()
RegEdit_ClearBit((void *) &ADC0.CTRLA, 0);
//Restore the port registers
PORTA.OUT = porta_out;
PORTA.DIR = porta_dir;
RegEdit_SetNum((void *) &PORTA.OUT, porta_out);
RegEdit_SetNum((void *) &PORTA.DIR, porta_dir);
}

22
src/ADC/CMakeLists.txt Normal file
View File

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

56
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,56 @@
add_executable(${PROJECT_NAME}
main.c
)
target_link_libraries(${PROJECT_NAME}
RegEdit
ADC
TriacOut
zero_cross_detection
load
)
# Ensure the build rules are defined
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".elf")
if(NOT TARGET size)
# Set the size utility to display the size of the final binary
add_custom_target(size ALL
COMMAND ${CMAKE_SIZE} --format=avr --mcu=${AVR_MCU} ${CMAKE_PROJECT_NAME}.elf
DEPENDS ${CMAKE_PROJECT_NAME}.elf
)
endif()
if(NOT TARGET hex)
# Define how to convert ELF to HEX
add_custom_target(hex ALL
COMMAND ${CMAKE_OBJCOPY} -O ihex -R .eeprom ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.hex
DEPENDS ${CMAKE_PROJECT_NAME}.elf
)
endif()
if(NOT TARGET bin)
# Define how to convert ELF to BIN
add_custom_target(bin ALL
COMMAND ${CMAKE_OBJCOPY} -O binary -R .eeprom ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.bin
DEPENDS ${CMAKE_PROJECT_NAME}.elf
)
endif()
if(NOT TARGET upload)
# Upload command (adjust according to your programmer)
add_custom_target(upload ALL
COMMAND avrdude -c ${PROGRAMMER} -P ${PORT} -p ${AVR_MCU} -U flash:w:${CMAKE_PROJECT_NAME}.hex
DEPENDS hex
)
endif()
add_subdirectory(zero_cross_detection)
add_subdirectory(ADC)
add_subdirectory(RegEdit)
add_subdirectory(usart)
add_subdirectory(TriacOut)
add_subdirectory(load)

View File

@ -0,0 +1,7 @@
add_library(RegEdit STATIC
RegEdit.c
)
target_include_directories(RegEdit PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -56,3 +56,10 @@ void RegEdit_SetNum(void *reg, uint8_t num)
uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr = num;
}
uint8_t RegEdit_ReadReg(void *reg)
{
uint8_t *reg_ptr = (uint8_t *)reg;
return *reg_ptr;
}

View File

@ -69,4 +69,10 @@ void RegEdit_AND_Num(void *reg, uint8_t num);
*/
void RegEdit_SetNum(void *reg, uint8_t num);
/**
*
* @param reg The register address.
*/
uint8_t RegEdit_ReadReg(void *reg);
#endif //REGEDIT_H

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

@ -13,13 +13,9 @@
#include "RegEdit.h"
void Delay_MicroSeconds_impl(double us){
return;
}
void Delay_MicroSeconds_impl(double us);
//Delay_MicroSeconds =
//void (*Delay_MicroSeconds)(double us) = Delay_MicroSeconds_impl;
void (*Delay_MicroSecnds)(double us) = Delay_MicroSeconds_impl;
void (*Delay_MicroSeconds)(double us) = &Delay_MicroSeconds_impl;
void TriacOut_InitTimerA(void)
{
@ -45,12 +41,13 @@ void TriacOut_SetAllHigh(void)
void TriacOut_PulsePins(uint16_t pulse_time)
{
Delay_MicroSeconds(pulse_time);
Delay_MicroSeconds(pulse_time);
RegEdit_ClearBit((void *) &PORTA.OUT, G1);
RegEdit_ClearBit((void *) &PORTB.OUT, G2);
RegEdit_ClearBit((void *) &PORTB.OUT, G3);
}
void Delay_MicroSeconds_impl(double us){
return;
}

View File

@ -44,4 +44,5 @@ void TriacOut_SetupPins(void);
void TriacOut_SetAllHigh(void);
#endif //TRIACOUT_H

22
src/load/CMakeLists.txt Normal file
View File

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

View File

@ -14,11 +14,11 @@ void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
{
ADC_Init(adc_pin);
ADC_Enable(adc_pin);
uint16_t val;
uint16_t val = 0;
for(int i = 0; i < 32; i++){
val = ADC_ReadValue(adc_pin);
val += ADC_ReadValue(adc_pin);
}
val /= 32;
ADC_Disable();
if(val < 527 || val > 1000){
RegEdit_ClearBit((void *) &PORTA.OUT, out_pin);
@ -30,7 +30,7 @@ void Load_HandleLoadPortB(uint8_t adc_pin, uint8_t out_pin)
{
ADC_Init(adc_pin);
ADC_Enable(adc_pin);
uint16_t val;
uint16_t val = 0;
for(int i = 0; i < 32; i++){
val = ADC_ReadValue(adc_pin);
}

View File

@ -12,13 +12,14 @@
//#define F_CPU 2000000UL
#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 util/delay.h library with the gcc toolchain
//This can prevent issues with utils/delay.h library with the gcc toolchain
#define __DELAY_BACKWARD_COMPATIBLE__
#include "config.h"
@ -37,12 +38,14 @@
void (*Delay_MicroSeconds)(double us) = _delay_us;
//void (*Delay_MicroSeconds)(double us) = _delay_ms;
/*
static void CLK_DisablePrescaler(void)
{
//CCP = CCP_IOREG_gc; /* Write the needed signature to CCP*/
//CCP = CCP_IOREG_gc; //Write the needed signature to CCP
ccp_write_io((void *) & (CLKCTRL.MCLKCTRLA), 0x00); //select internal 20MHz clock.
ccp_write_io((void *) & (CLKCTRL.MCLKCTRLB), 0x00); //Disable the pre-scaler.
}
*/
int main(int argc, char **argv)
@ -56,20 +59,6 @@ int main(int argc, char **argv)
TriacOut_SetAllHigh();
TriacOut_PulsePins(GatePulses[i]);
}
//The G1-G3 pins are low at this point.
_delay_ms(2500);
ZCD_Poll();
TriacOut_SetupPins();
TriacOut_SetAllHigh();
Load_HandleLoadPortA(ADC_LOAD1, 1);
Load_HandleLoadPortB(ADC_LOAD2, 3);
Load_HandleLoadPortB(ADC_LOAD3, 2);
while(true){
; //Do nothing until new Power cycle/reset occurs
}
}
}

7
src/usart/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
add_library(usart STATIC
usart.c
)
target_include_directories(usart PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

64
src/usart/usart.c Normal file
View File

@ -0,0 +1,64 @@
/*
* Author: username
* Date: 2024
* filename: usart.c
* description: module_purpose
*/
#include "usart.h"
#include <avr/io.h>
#include <string.h>
#define F_CPU 3333333UL
#define F_PER F_CPU / 6
#define USART0_BAUD_RATE(BAUD_RATE) ((float)(F_PER * 64 / (16 * (float)BAUD_RATE)) + 0.5)
//RX PIN6, TX PIN7
//ALT: RX PIN12 TX PIN11
void USART0_init(void)
{
//Config TxD as output, and rx as input?
PORTB.DIR &= ~(1<<3);
PORTB.DIR |= (1<<2);
//setup Alternate pints on PA1 and PA2
/*
PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc;
PORTA.DIRSET |= (1<<1);
PORTA.DIRSET &= ~(1<<2);
*/
//It says to set the TX pin high?
//PORTB.OUT |= (1<<2);
//PORTA.OUT |= (1<<11);
//set buad rate.
USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600);
//set the frame format.
USART0.CTRLC = 0x3; //setting 8-bit mode.
//Enable transmitter and receiver (USARTn.CTRLB)
//USART0.CTRLB |= (1<<7)|(1<<6);
USART0.CTRLB |= USART_TXEN_bm;
}
void USART0_sendChar(char c)
{
while (!(USART0.STATUS & USART_DREIF_bm)){
;
}
USART0.TXDATAL = c;
USART0.TXDATAH = c;
}
void USART0_sendString(char *str)
{
for(size_t i = 0; i < strlen(str); i++)
{
USART0_sendChar(str[i]);
}
}

33
src/usart/usart.h Normal file
View File

@ -0,0 +1,33 @@
/**
* @brief Universal Asynchronout Serial library.
* @details This file contains the functions for using the avr usart0 periph.
* @author Jake G
* @date 2024
* @copyright None
* @file USART.h
*/
#ifndef USART_H
#define USART_H
/**
* @brief Initializes the USART0 peripheral.
*/
void USART0_init(void);
/**
* @brief Sends a single char type variable over usart0.
* @param c The charecter to be sent over usart0.
*/
void USART0_sendChar(char c);
/**
* @brief Sends string over usart0
* @param str A C-style string.
*/
void USART0_sendString(char *str);
#endif //USART_H

View File

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

View File

@ -15,6 +15,8 @@
#include "MockADC/MockADC.h"
#endif
#define ZCD_PIN 0x07
void ZCD_Setup(void)
{
ADC_Init(7);
@ -25,11 +27,11 @@ bool ZCD_IsTriggered()
{
uint16_t first, second;
ZCD_Setup();
first = ADC_ReadValue(7);
first = ADC_ReadValue(ZCD_PIN);
ADC_Disable();
ZCD_Setup();
second = ADC_ReadValue(7);
second = ADC_ReadValue(ZCD_PIN);
ADC_Disable();
if(second < TRIGGERVAL){

View File

@ -0,0 +1,49 @@
/**
* @file zero_cross_detection.h
* @author Jake G
* @date 16 June 2024
* @brief File contains the zero cross detection functions
*
* This file holds all the code/functions needed to read the value of the AC
* waveform. It uses the trigger value from the `config.h` file to evaluate the
* state.
*
* This module depends on the ADC.h module to get readings from the ADC
* hardware.
*/
#ifndef ZERO_CROSS_DETECTION
#define ZERO_CROSS_DETECTION
#include <stdint.h>
#include <stdbool.h>
/**
* @brief Zero Cross Detection Setup
*
* Sets up the hardware to read the values coming from the AC input waveform.
*
*/
void ZCD_Setup(void);
//int ZCD_Setup(volatile uint8_t *ddrx, uint8_t *port, uint8_t pin);
/**
* @brief Checks if ZCD should trigger on value
*
* The function checks for a positive edge first using the ZCD_IsPositiveEdge
* function. If a positive edge was found, then it takes an addition set of
* samples and averages them; only triggering(returning true) in the case
* that the average is higher than the previous sample.
*/
bool ZCD_IsTriggered(void);
/**
* @brief Function blocks execution until ZCD is triggered.
*
*/
void ZCD_Poll(void);
#endif //ZERO_CROSS_DETECTION

17
tests/ADC/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
# TEST_RUNNER
add_library(test_ADC
test_ADC.cpp
)
target_link_libraries(test_ADC
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
ADC
MockRegEdit
)
#Needed for the tests to function
include_directories(
/usr/local/avr/include/avr
#/usr/lib/avr/include/avr
)

175
tests/ADC/test_ADC.cpp Normal file
View File

@ -0,0 +1,175 @@
/*
* Author: Jake G
* Date: 2024
* filename: test_ADC.c
* description: module_purpose
*/
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTestExt/MockSupport.h"
#include <cstdint>
//This define allows us to dircetly include the device header without error.
#define _AVR_IO_H_
extern "C"
{
#include <iotn404.h> //ATtiny404 header fille.
#include "ADC.h"
}
TEST_GROUP(test_ADC)
{
void setup()
{
}
void teardown()
{
mock().checkExpectations();
mock().clear();
}
};
TEST(test_ADC, FirstTest)
{
CHECK(true);
}
static void ADCStoresPortState(void){
mock().expectOneCall("RegEdit_ReadReg")
.withPointerParameter("reg", (void *) &PORTA.OUT)
.andReturnValue(0xFF);
mock().expectOneCall("RegEdit_ReadReg")
.withPointerParameter("reg", (void *) &PORTA.DIR)
.andReturnValue(0xFF);
}
TEST(test_ADC, ADC_InitPortAPin7UsesCorrectRegisters)
{
ADCStoresPortState();
//Check for setting the direction to input.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.DIRCLR)
.withUnsignedIntParameter("bit_num", 7);
//Check that the pullup is off
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.OUTCLR)
.withUnsignedIntParameter("bit_num", 7);
//Set the ISC(input sense config) to disable digital input
//buffering and reduce the noise on ADC usage.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.PIN7CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
ADC_Init(7);
}
TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters)
{
ADCStoresPortState();
//Check for setting the direction to input.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.DIRCLR)
.withUnsignedIntParameter("bit_num", 0);
//Check that the pullup is off
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.OUTCLR)
.withUnsignedIntParameter("bit_num", 0);
//Set the ISC(input sense config) to disable digital input
//buffering and reduce the noise on ADC usage.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTA.PIN0CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
ADC_Init(0);
}
TEST(test_ADC, ADC_InitDoesNothingOnHighPinNumbers)
{
mock().expectNoCall("RegEdit_SetBit");
ADC_Init(8);
}
TEST(test_ADC, ADC_EnableSuccessOnPin7)
{
//Set the MUXPOS or the ADC pin stuff.
mock().expectOneCall("RegEdit_OR_Num")
.withPointerParameter("reg", (void *) &ADC0.MUXPOS)
.withUnsignedIntParameter("num", ADC_MUXPOS_AIN7_gc);
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 0);
ADC_Enable(7);
}
TEST(test_ADC, ADC_EnableNothingOnHighPinNumbers)
{
mock().expectNoCall("RegEdit_SetBit");
ADC_Enable(8);
}
TEST(test_ADC, ADC_DisablePasses)
{
//Clears the muxpos register
mock().expectOneCall("RegEdit_ClearRegister")
.withPointerParameter("reg", (void *) &ADC0.MUXPOS);
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 0);
mock().expectOneCall("RegEdit_SetNum")
.withPointerParameter("reg", (void*) &PORTA.OUT)
.ignoreOtherParameters();
mock().expectOneCall("RegEdit_SetNum")
.withPointerParameter("reg", (void*) &PORTA.DIR)
.ignoreOtherParameters();
ADC_Disable();
}
static uint16_t ADC_ReadValueFake(uint8_t pin_num)
{
return 512;
}
TEST_GROUP(test_ADCRead)
{
void setup()
{
UT_PTR_SET(ADC_ReadValue, ADC_ReadValueFake);
}
void teardown()
{
}
};
TEST(test_ADCRead, FunctionPointerSwapWorks)
{
uint16_t value = ADC_ReadValue(0);
LONGS_EQUAL(512, value);
}

15
tests/AllTests.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "CppUTest/CommandLineTestRunner.h"
//ImportTestGroups
IMPORT_TEST_GROUP(simple_test);
IMPORT_TEST_GROUP(test_ADC);
IMPORT_TEST_GROUP(test_RegEdit);
//START: main
int main(int argc, char** argv)
{
return RUN_ALL_TESTS(argc, argv);
}
//END: main

50
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,50 @@
project(Tests)
# TEST_DIRS
#add_subdirectory(usart)
add_subdirectory(MockADC)
add_subdirectory(ADC)
add_subdirectory(MockRegEdit)
add_subdirectory(RegEdit)
add_subdirectory(simple_test)
add_subdirectory(zero_cross_detection)
add_subdirectory(TriacOut)
# TEST_RUNNER
add_executable(AllTests
AllTests.cpp
)
target_link_libraries(AllTests
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
# TEST_LINKS
test_ADC
test_RegEdit
simple_test
)
add_executable(Mock_Tests
MockTests.cpp
)
target_link_libraries(Mock_Tests
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
test_MockRegEdit
test_MockADC
test_zero_cross_detection
)
add_executable(TriacTests
TriacTests.cpp
)
target_link_libraries(TriacTests
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
test_TriacOut
)

Some files were not shown because too many files have changed in this diff Show More