Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/add tasks #20

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[Bb]uild/
[Dd]atasheets/
[Hh]ardware/
.vscode/
42 changes: 42 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/avr-gcc",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
"-mmcu=atmega168a",
"-DF_CPU=1000000UL",
"-Os"
]
},
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22000.0",
"compilerPath": "C:/avr8-gnu-toolchain/bin/avr-gcc",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
"-mmcu=atmega168a",
"-DF_CPU=1000000UL",
"-Os"
]
}
],
"version": 4
}
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Configure Project",
"command": "cmake",
"args": [
"-B", "${workspaceFolder}/Build"
],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"type": "shell",
"label": "Build Project",
"dependsOn": "Configure Project",
"command": "cmake --build .",
"options": {
"cwd": "${workspaceFolder}/Build"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"base": "$gcc",
"fileLocation": ["relative", ""]
}
}
]
}
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
cmake_minimum_required(VERSION 3.20)

set(CMAKE_TOOLCHAIN_FILE toolchain.cmake)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/toolchain.cmake)
message(STATUS "CMAKE_TOOLCHAIN_FILE is: ${CMAKE_TOOLCHAIN_FILE}")

# export compile commands to use for clang-tidy
# export compile commands for clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

project(AtmegaTddExample VERSION 0.1.0 DESCRIPTION "ATmega TDD Example" LANGUAGES C)

set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

message(STATUS "CMAKE_C_COMPILER is: ${CMAKE_C_COMPILER}")

# set serial port, works under Windows only
set(PORT_NUMBER COM6)
message(STATUS "Serial port set to: ${PORT_NUMBER}")

add_subdirectory(Src Bin)
4 changes: 2 additions & 2 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
add_executable(${EXECUTABLE} led.c low_power.c main.c superloop.c timer.c)

target_include_directories(${EXECUTABLE} PUBLIC ${PROJECT_SOURCE_DIR}/Inc)
target_include_directories(${EXECUTABLE} PRIVATE ${PROJECT_SOURCE_DIR}/Inc)

set_target_properties(${EXECUTABLE} PROPERTIES OUTPUT_NAME ${EXECUTABLE}.elf)

add_custom_target(size ALL ${AVR_SIZE} --format=avr --mcu=${AVR_MCU} ${EXECUTABLE}.elf)
add_custom_target(hex ALL ${AVR_OBJCOPY} -j .text -j .data -O ihex ${EXECUTABLE}.elf ${EXECUTABLE}.hex)

add_custom_target(erase COMMAND ${AVR_DUDE} -p ${AVR_PARTNO} -P ${PORT_NUMBER} -c ${AVR_PROGRAMMER} -e)
add_custom_target(upload COMMAND ${AVR_DUDE} -p ${AVR_PARTNO} -P ${PORT_NUMBER} -c ${AVR_PROGRAMMER} -U flash:w:${EXECUTABLE}.hex)
add_custom_target(upload COMMAND ${AVR_DUDE} -p ${AVR_PARTNO} -P ${PORT_NUMBER} -c ${AVR_PROGRAMMER} -U flash:w:${EXECUTABLE}.hex)
22 changes: 2 additions & 20 deletions atmega-tdd-example.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,8 @@
],
"settings": {
"files.associations": {
"delay.h": "c",
"stdint.h": "c",
"io.h": "c",
"iom168a.h": "c",
"iom168.h": "c",
"main.h": "c",
"led.h": "c",
"utils.h": "c",
"bit_manipulation.h": "c",
"runner.h": "c",
"executor.h": "c",
"stdbool.h": "c",
"superloop.h": "c",
"timer.h": "c",
"interrupt.h": "c",
"sleep.h": "c",
"low_power.h": "c",
"testable_mcu_registers.h": "c",
"fff.h": "c",
"commandlinetestrunner.h": "c"
"*.c": "c",
"*.h": "c"
},
"cSpell.words": [
"Atmel",
Expand Down
21 changes: 14 additions & 7 deletions toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ set(AVR_PARTNO m168)
set(AVR_PROGRAMMER avrispv2)
set(F_CPU "1000000UL")

# set serial port, works under Windows only
set(PORT_NUMBER COM6)

# set linker flags
set(CMAKE_EXE_LINKER_FLAGS -mmcu=${AVR_MCU})

# set compile options
add_compile_options(
-Wall
-g
-Os
-mmcu=${AVR_MCU}
-DF_CPU=${F_CPU})
-DF_CPU=${F_CPU}
)

# set linker options
add_link_options(
-mmcu=${AVR_MCU}
)

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)