Automated the project configuration file. I need now to moove all the auto include funtions in one file

master
Kerem Yollu 2 years ago
parent 00a6e0c8e7
commit 6a4ec9adcf

@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.15)
####################################################################################################
# CMAKE Features
####################################################################################################
set(CMAKE_VERBOSE_MAKEFILE off) #Should CMake print everythign ?
set(CMAKE_VERBOSE_MAKEFILE ON) #Should CMake print everythign ?
set(OUTPUT_DOXYGEN FALSE) #Should CMake generate Doxygen output ?
@ -21,7 +20,7 @@ set(PERIFERALS_DIR ${CMAKE_SOURCE_DIR}/periferals) #Directory fot the written -
#INCLUDES
####################################################################################################
include(config/cmakeProjectConfig.cmake) #For the moment there are only colors
include(${PROJECT_DIR}/project.conf) #Here is the include Where the user sould define his project sources and headers
include(${PROJECT_DIR}/projectDefinitions.cmake) #Here is the include Where the user sould define his project sources and headers
####################################################################################################
# Cheking if the choosen CSL exists, this i redundant because run.sh makes that alredy but makes the
@ -68,7 +67,7 @@ set(STARTUP_UCODE sub::startup)
####################################################################################################
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin)
set(NEW_ELEMENT null)
set(NEW_PERIPHERAL null)
message("${BoldYellow}")
message("+-------------------------------+")
@ -76,8 +75,8 @@ message("Cheking Periferals")
message("+-------------------------------+")
foreach(X IN LISTS PERIPHERALS_LIST)
addPeripheral("${X}" "NEW_ELEMENT")
list(APPEND PERIPHERAL_LIBS ${NEW_ELEMENT})
addPeripheral("${X}" "NEW_PERIPHERAL")
list(APPEND PERIPHERAL_LIBS ${NEW_PERIPHERAL})
endforeach()
message("+-------------------------------+")
@ -101,11 +100,44 @@ endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
#User's project definitions
####################################################################################################
message("${BoldYellow}")
message("+-------------------------------+")
message("Cheking User's Project")
message("+-------------------------------+")
message("Declared Project Headers :")
foreach(X IN LISTS PROJECT_HEADERS_DIR)
message("|-->${X}")
endforeach()
message("Included Project Headers :")
projectHeadersCheck()
message("Decalred Project Sources :")
foreach(X IN LISTS PROJECT_SOURCES_DIR)
message("|-->${X}")
endforeach()
message("Included Project Sources :")
projectCheckSourcesCheck()
message("Declared sources :")
foreach(X IN LISTS PROJECT_SOURCES_DIR_LIST)
message("|-->${X}")
endforeach()
message("Creating Libraries for declared sources :")
foreach(X IN LISTS PROJECT_SOURCES_DIR_LIST)
projectAddItem("${X}" "NEW_PROJECT_ITEM")
list(APPEND PROJECT_LIBS ${NEW_PROJECT_ITEM})
endforeach()
message("+-------------------------------+")
####################################################################################################
#Stick All the libraries together, only for code redability futher down.
####################################################################################################
foreach(X IN LISTS STARTUP_UCODE PERIPHERAL_LIBS DRIVER_LIBS)
foreach(X IN LISTS STARTUP_UCODE PROJECT_LIBS PERIPHERAL_LIBS DRIVER_LIBS )
list(APPEND GENERATED_LIBRARIES ${X})
endforeach()
@ -139,12 +171,15 @@ foreach(X IN LISTS DRIVERS_LIST)
message(" |->${X}")
endforeach()
message(" |--> Generated Library Submodules ${Magenta}!!!This list order also defines the compilation order of submodules!!!${ColourReset}")
message("${BoldBlue}")
foreach(X IN LISTS GENERATED_LIBRARIES)
message(" |--> Project sources to be implemented:")
foreach(X IN LISTS PROJECT_SOURCES_DIR_LIST)
message(" |->${X}")
endforeach()
message(" |--> Generated Library Submodules ${Magenta}!!!This list order also defines the compilation order of submodules!!!${ColourReset}${BoldBlue}")
foreach(X IN LISTS GENERATED_LIBRARIES)
message(" |->${X}")
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
@ -154,7 +189,7 @@ message("${ColourReset}")
add_executable(${EXECUTABLE} ${PROJECT_DIR}/main.c)
target_compile_options(${EXECUTABLE} PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${EXECUTABLE} PRIVATE ${MAIN_DEFS})
target_include_directories(${EXECUTABLE} PUBLIC ${PROJEC_HEADERS} ${PROJECT_SOURCES} ${MAIN_INCLUDES})
target_include_directories(${EXECUTABLE} PUBLIC ${PROJECT_HEADERS_DIR} ${PROJECT_SOURCES_DIR} ${MAIN_INCLUDES})
####################################################################################################
#LINKING EXECUTEABLE

@ -1,4 +1,4 @@
#include"deviceSetup.h"
#include "deviceSetup.h"
#include "stm32f042x6.h"

@ -1,5 +1,3 @@
add_subdirectory(max31865)
function(addDriver alias _currentDriver)
if(EXISTS ${DRIVERS_DIR}/${alias} ) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Driver directory : ${DRIVERS_DIR}/${alias} = FOUND")

@ -0,0 +1,17 @@
#ifndef UART_COMM_H
#define UART_COMM_H
#ifdef __cplusplus
extern "C" {
#endif
void uartCommInit();
void uartCommPrintWellcome();
void uartCommPrintSensorActivate();
void uartCommPrintSensorDeActivate();
#ifdef __cplusplus
}
#endif
#endif /* UART_COMM_H */

@ -1,33 +1,22 @@
#include "main.h"
#include "delay.h"
#include "pin.h"
#include "deviceSetup.h"
#include "usart.h"
#include "ascii.h"
#include "uartComm.h"
#include "sensor.h"
int main(int argc, char *argv[])
{
uint8_t i = 0;
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
pinConfig(pinB3, output, pushPull, def_res, def_speed);
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
usartInit( usart2,
pinA2,
pinA15,
115200,
eight,
NO_PARITY_CTRL,
noFlowControl);
//clears screen and send the wellcome messgae
print_Usart(usart2, ASCII_clear);
print_Usart(usart2, "Hello to our KED project\n\r");
uartCommInit();
//blinks 10 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 2 ; i++) {
delayMs(100);
@ -35,13 +24,9 @@ int main(int argc, char *argv[])
delayMs(100);
}
pinWrite(pinB3,0);
print_Usart(usart2, "\n\r");
print_Usart(usart2, "\n\r");
print_Usart(usart2, "\n\r");
print_Usart(usart2, "All is working fine\n\r");
uartCommPrintWellcome();
sensorActivate(1);
sensorActivate(0);
while(1)
{

@ -0,0 +1,62 @@
#Declareing header directory for the project
#To add a new directory
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
#Declaring sources directory for the project
#To add a new directory
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/src)
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/sensors)
#Declaring sources to be compiled for the project.
#CMake will look in each previsouly declarec sources directory until to find this files.
set(PROJECT_SOURCES_DIR_LIST uartComm.c sensor.c)
#Searching if the given header directory exists if not we brake the compilation
function(projectHeadersCheck)
foreach(X IN LISTS PROJECT_HEADERS_DIR)
if(EXISTS ${X})
message("|--> ${X} : INCLUDED")
else()
message(FATAL_ERROR "Header directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()
#Searching if the given Source exists if not we brake the compilation
function(projectCheckSourcesCheck)
foreach(X IN LISTS PROJECT_SOURCES_DIR)
if(EXISTS ${X})
message("|--> ${X} : INCLUDED")
else()
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()
#Searching each sources directory to find the desired source file and generate a libaray submodule for the linker
function(projectAddItem alias _currentItem)
foreach(X IN LISTS PROJECT_SOURCES_DIR)
if(EXISTS ${X})
if(EXISTS ${X}/${alias}) #For each directory we chanek if the given source file exitst
message("|-->${alias} FOUND in : ${X}")
message(" |-> Creating sub::${alias} library submodule")
add_library(${alias}_submodule ${X}/${alias})
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PROJECT_HEADERS_DIR} ${PERIFERALS_DIR} ${CSL_INCLUDES})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentItem} sub::${alias} PARENT_SCOPE)
endif()
else()
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()

@ -0,0 +1,14 @@
#include "sensor.h"
void sensorActivate(uint8_t activate)
{
if(activate == 1)
{
uartCommPrintSensorActivate();
}
else
{
uartCommPrintSensorDeActivate();
}
}

@ -0,0 +1,14 @@
#ifndef SENSOR_H
#define SENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "uartComm.h"
void sensorActivate(uint8_t activate);
#ifdef __cplusplus
}
#endif
#endif /* SENSOR_H */

@ -0,0 +1,32 @@
#include "usart.h"
#include "ascii.h"
#include "pin.h"
void uartCommInit()
{
usartInit( usart2,
pinA2,
pinA15,
115200,
eight,
NO_PARITY_CTRL,
noFlowControl);
}
void uartCommPrintWellcome()
{
print_Usart(usart2, ASCII_clear);
print_Usart(usart2, "Hello to our KED project\n\r");
print_Usart(usart2, "\n\r");
print_Usart(usart2, "All is working fine\n\r");
}
void uartCommPrintSensorDeActivate()
{
print_Usart(usart2, "Sensor De-Activated\n\r");
}
void uartCommPrintSensorActivate()
{
print_Usart(usart2, "Sensor Activated\n\r");
}

@ -0,0 +1,55 @@
#include "main.h"
#include "delay.h"
#include "deviceSetup.h"
#include "usart.h"
#include "ascii.h"
int main(int argc, char *argv[])
{
uint8_t i = 0;
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
pinConfig(pinB3, output, pushPull, def_res, def_speed);
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
usartInit( usart2,
pinA2,
pinA15,
115200,
eight,
NO_PARITY_CTRL,
noFlowControl);
//clears screen and send the wellcome messgae
print_Usart(usart2, ASCII_clear);
print_Usart(usart2, "Hello to our KED project\n\r");
//blinks 10 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 2 ; i++) {
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
pinWrite(pinB3,0);
print_Usart(usart2, "\n\r");
print_Usart(usart2, "\n\r");
print_Usart(usart2, "\n\r");
print_Usart(usart2, "All is working fine\n\r");
while(1)
{
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
return 1;
}

@ -0,0 +1,12 @@
#ifndef MAIN_H
#define MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* MAIN_H */

@ -0,0 +1,62 @@
#Declareing header directory for the project
#To add a new directory
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
#Declaring sources directory for the project
#To add a new directory
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
# list() = List declaration "DON'T CHANGE"
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/src)
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/sensors)
#Declaring sources to be compiled for the project.
#CMake will look in each previsouly declarec sources directory until to find this files.
set(PROJECT_SOURCES_DIR_LIST uartComm.c sensor.c)
#Searching if the given header directory exists if not we brake the compilation
function(projectHeadersCheck)
foreach(X IN LISTS PROJECT_HEADERS_DIR)
if(EXISTS ${X})
message("|--> ${X} : INCLUDED")
else()
message(FATAL_ERROR "Header directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()
#Searching if the given Source exists if not we brake the compilation
function(projectCheckSourcesCheck)
foreach(X IN LISTS PROJECT_SOURCES_DIR)
if(EXISTS ${X})
message("|--> ${X} : INCLUDED")
else()
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()
#Searching each sources directory to find the desired source file and generate a libaray submodule for the linker
function(projectAddItem alias _currentItem)
foreach(X IN LISTS PROJECT_SOURCES_DIR)
if(EXISTS ${X})
if(EXISTS ${X}/${alias}) #For each directory we chanek if the given source file exitst
message("|-->${alias} FOUND in : ${X}")
message(" |-> Creating sub::${alias} library submodule")
add_library(${alias}_submodule ${X}/${alias})
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PROJECT_HEADERS_DIR} ${PERIFERALS_DIR} ${CSL_INCLUDES})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentItem} sub::${alias} PARENT_SCOPE)
endif()
else()
message(FATAL_ERROR "Source directory ${X} : NOT FOUND")
endif()
endforeach()
endfunction()

@ -72,13 +72,8 @@ autoInit()
build
else
echo "Main.c is not fount"
echo "Creating sample project"
mkdir $PROJECT_DIR/headers
mkdir $PROJECT_DIR/src
cp $SCRIPT_DIR/examples/autoInit/main.h $PROJECT_DIR/headers
cp $SCRIPT_DIR/examples/autoInit/main.c $PROJECT_DIR/
cp $SCRIPT_DIR/examples/autoInit/project.conf $PROJECT_DIR/
echo "Creating sample project"
cp -r $SCRIPT_DIR/examples/autoInit/* $PROJECT_DIR/
build
fi
}

Loading…
Cancel
Save