diff --git a/.gitmodules b/.gitmodules index c3b0e3c..b1c4b8d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "external/cmake-microchip"] path = external/cmake-microchip - url = git://github.com/Elemecca/cmake-microchip.git + url = git://github.com/enbyted/cmake-microchip.git diff --git a/CMakeLists.txt b/CMakeLists.txt index dc682be..a8dd96a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,15 @@ set(CMAKE_TOOLCHAIN_FILE external/cmake-microchip/toolchain.cmake) # set the default MCU model set(MICROCHIP_MCU PIC16F18857) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + project(xc8-cmake C) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic") +set(CMAKE_C_FLAGS_DEBUG "-g") +set(CMAKE_C_FLAGS_RELEASE "-O3") + +add_subdirectory(hal/) add_subdirectory(app/) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index f1ef07c..0cd18e8 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -4,3 +4,5 @@ set(SOURCES add_executable(app ${SOURCES}) target_include_directories(app PRIVATE include/) + +target_link_libraries(app hal) diff --git a/app/src/main.c b/app/src/main.c index 7e475c5..ee1ffa6 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -1,9 +1,9 @@ #include "configuration_bits.h" -#include +#include void main() { - LATCbits.LATC1 = 0; + hal_init(); while(1) { diff --git a/external/cmake-microchip b/external/cmake-microchip index c7462ae..c519125 160000 --- a/external/cmake-microchip +++ b/external/cmake-microchip @@ -1 +1 @@ -Subproject commit c7462ae5f7487aa49415581675bc235ffa7ea998 +Subproject commit c51912565b290908403e03d59ef90a128031b8ce diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt new file mode 100644 index 0000000..91592c9 --- /dev/null +++ b/hal/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SOURCES + src/hal.c +) + +add_library(hal ${SOURCES}) +target_include_directories(hal PUBLIC include-public/) diff --git a/hal/include-public/hal/hal.h b/hal/include-public/hal/hal.h new file mode 100644 index 0000000..647c6ad --- /dev/null +++ b/hal/include-public/hal/hal.h @@ -0,0 +1,6 @@ +#ifndef __HAL_H__ +#define __HAL_H__ + +void hal_init(void); + +#endif \ No newline at end of file diff --git a/hal/src/hal.c b/hal/src/hal.c new file mode 100644 index 0000000..b2c89f4 --- /dev/null +++ b/hal/src/hal.c @@ -0,0 +1,7 @@ +#include "hal/hal.h" +#include + +void hal_init(void) +{ + LATCbits.LATC1 = 0; +} \ No newline at end of file