I will soon womit CMAKE but its taking ever more shape, if we finr an implmentation without header it wil generate an fatal error, now i will implement a check to find out if two source file or two header files have the same name

master
kerem yollu 2 years ago
parent 36be0a0f9e
commit 9fb6a9fcb3

@ -109,16 +109,16 @@ message("${BoldBlue}")
message("+-------------------------------+")
message("Adding Header Directories")
message("+-------------------------------+")
message("|-->For Drivers")
createHeaderDirList("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVERS_HEADERS_DIR")
message("|-->For System")
createHeaderDirList("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_HEADERS_DIR")
message("${BoldBlue}|-->For Peripherals")
createHeaderDirList("${PERIPHERALS_DIR}" "${PERIPHERALS_LIST}" "PERIPHERALS_HEADERS_DIR")
message("${BoldBlue}|-->For Drivers")
createHeaderDirList("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVERS_HEADERS_DIR")
message("${BoldBlue}|-->For Libraries")
createHeaderDirList("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_HEADERS_DIR")
message("${BoldBlue}|-->For Project")
checkDirectories("${PROJECT_HEADERS_DIR}")
message("${BoldBlue}|-->For System")
createHeaderDirList("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_HEADERS_DIR")
message("${BoldBlue}+-------------------------------+${ColourReset}")
set (COMMON_HEADERS ${CSL_HEADERS_DIR}
@ -135,23 +135,28 @@ message("${BoldBlue}")
message("+-------------------------------+")
message("Making Submolues")
message("+-------------------------------+")
message("|-->For Drivers")
makeSubmodules("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVER_LIBS")
message("|-->For System")
makeSubmodules("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_LIBS")
message("${BoldBlue}|-->For Peripherals")
makeSubmodules("${PERIPHERALS_DIR}" "${PERIPHERALS_LIST}" "PERIPHERAL_LIBS")
message("${BoldBlue}|-->For Drivers")
makeSubmodules("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVER_LIBS")
message("${BoldBlue}|-->For Libraries")
makeSubmodules("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_LIBS")
message("${BoldBlue}|-->For Project")
makeSubmodules("${PROJECT_DIR}" "${PROJECT_SOURCES_DIR_LIST}" "PROJECT_LIBS")
message("${BoldBlue}|-->For System")
makeSubmodules("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_LIBS")
message("${BoldBlue}+-------------------------------+${ColourReset}")
####################################################################################################
# Stick All the libraries together, only for code redability futher down.
####################################################################################################
foreach(X IN LISTS STARTUP_UCODE PROJECT_LIBS PERIPHERAL_LIBS DRIVER_LIBS LIBRARIES_LIBS SYSTEM_LIBS)
foreach(X IN LISTS STARTUP_UCODE
PROJECT_LIBS
PERIPHERAL_LIBS
DRIVER_LIBS
LIBRARIES_LIBS
SYSTEM_LIBS)
list(APPEND GENERATED_LIBRARIES ${X})
endforeach()

@ -35,48 +35,120 @@ function(createHeaderDirList _directory _list _headersList)
set(${_headersList} ${_newheaderDirList} PARENT_SCOPE)
endfunction()
# This function searches for the given header file name (_alias) if it has benn included
# If it finds it it retursn the directory where the header is Located
# If it doesn't find a header it generates a fatal error
function(checkIfHeaderFileIncluded _alias _retDir)
set(_headerFound FALSE)
set(_headerDirFound)
foreach(_headerDir IN LISTS COMMON_HEADERS)
if(EXISTS ${_headerDir}/${alias}.h)
set(_headerFound TRUE)
set(_headerDirFound ${_headerDir})
endif()
endforeach()
if(_headerFound)
set(${_retDir} ${_headerDirFound}/${alias}.h PARENT_SCOPE)
else()
errorHFileNotFound(${_headerDirFound} ${_alias})
endif()
endfunction()
# This function searches for the given header file name (_alias) if it has benn included
# If it finds it it retursn the directory where the header is Located
# If it doesn't find a header it returns a Non Found Message
function(searchHeaderFile _alias _retDir)
set(_headerFound FALSE)
set(_headerDirFound)
foreach(_headerDir IN LISTS COMMON_HEADERS)
if(EXISTS ${_headerDir}/${alias}.h)
set(_headerFound TRUE)
set(_headerDirFound ${_headerDir})
endif()
endforeach()
if(_headerFound)
set(${_retDir} ${_headerDirFound}/${alias}.h PARENT_SCOPE)
else()
set(${_retDir} "Not Found" PARENT_SCOPE)
endif()
endfunction()
####################################################################################################
# SUBMODULE MANAGEMENT
####################################################################################################
function(makeSubmodules _directory _aliasList _submoduleList)
set(_newSubmoduleList)
set(_headerLoc)
#For each alias of element present on the list that have been given as argument
foreach(alias IN LISTS _aliasList)
checkDirectory("${_directory}/${alias}")
if(EXISTS ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
message("${BoldYellow} |-> Target Found : ${alias} ")
if(EXISTS ${_directory}/${alias}/${alias}.${PL})
message(" |-> Imp source : ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
checkDirectory("${_directory}/${alias}") # Does the directory exists (If not fatal error)
#Does the given element has an implmenetation for a CSL
if(EXISTS ${CSL_SOURCES_DIR}/imp_${alias}.${PL}) #If yes
message("${BoldCyan} |-> Target Found : ${alias} ${BoldYellow} ")
checkIfHeaderFileIncluded("${alias}" "_headerLoc") #Every Implementation has to have a header (if not Fatal Error)
#Does the given element has an predefined standart usage library
if(EXISTS ${_directory}/${alias}/${alias}.${PL}) # If yes then add this to the compiling list
message(" |-> Def Header : ${_headerLoc}")
message(" |-> Lib Source : ${_directory}/${alias}/${alias}.${PL} ")
message(" |-> Imp source : ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
add_library(${alias}_submodule ${_directory}/${alias}/${alias}.${PL} ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
else()
else() # If No than just compile the implmentation source
message(" |-> Def Header : ${_headerLoc}")
message(" |-> Imp source : ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
add_library(${alias}_submodule ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
endif()
message(" |-> Name : sub::${alias}")
message(" |-> Name : sub::${alias}")
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS})
add_library(sub::${alias} ALIAS ${alias}_submodule)
#Append the internal submodule list with the newly compiled element
list(APPEND _newSubmoduleList sub::${alias})
else()
else() # Else, when the element has no implmentation for a CSL
#If the element has an source file
if(EXISTS ${_directory}/${alias}/${alias}.${PL})
message("${BoldYellow} |-> Target Found : ${alias} ")
searchHeaderFile("${alias}" "_headerLoc") #Searches if there is an Header (if not it will not generate any error)
message("${BoldCyan} |-> Target Found : ${alias} ${BoldYellow} ")
message(" |-> Header : ${_headerLoc}")
message(" |-> Source : ${_directory}/${alias}/${alias}.${PL}")
message(" |-> Name : sub::${alias}")
add_library(${alias}_submodule ${_directory}/${alias}/${alias}.${PL})
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS})
add_library(sub::${alias} ALIAS ${alias}_submodule)
#Append the internal submodule list with the newly compiled element
list(APPEND _newSubmoduleList sub::${alias})
else()
else() # When the element has no source file and is only a header.
message("${BoldMagenta} |-> No Source file for target : ${alias}")
message(" |-> Only headers will be added")
endif()
endif()
endforeach()
message("${ColourReset}")
#New submodule list with the names of the compiled elements
set(${_submoduleList} ${_newSubmoduleList} PARENT_SCOPE)
endfunction()
####################################################################################################
@ -87,4 +159,3 @@ function(printList _txt _list)
message("${_txt}${X}")
endforeach()
endfunction()

@ -15,7 +15,7 @@ function(errorOut)
message("#########################################\n\n")
endfunction()
function(errorDirNotFound)
function(errorDirNotFound _searchedDir)
errorDetected()
message(" |-->GIVEN DIRECTORY NOT FOUND")
message(" |-> Given dir : ${DIR}")

@ -1,9 +1,9 @@
#include "main.h"
#include "delay.h"
#include "pin.h"
#include "deviceSetup.h"
#include "uartComm.h"
#include "sensor.h"
#include "usart.h"
#include "ascii.h"
#include "timer.h"
int main(int argc, char *argv[])
{
@ -16,17 +16,11 @@ int main(int argc, char *argv[])
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
uartCommInit();
//blinks 10 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 2 ; i++) {
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
usartInit(usart2, pinA2, pinA15, 115200, eight, NO_PARITY_CTRL, noFlowControl);
uartCommPrintWellcome();
sensorActivate(1);
sensorActivate(0);
//clears screen and send the wellcome messgae
print_Usart(usart2, ASCII_clear);
print_Usart(usart2, "Hello to our KED project\n\r");
while(1)
{
@ -37,4 +31,3 @@ int main(int argc, char *argv[])
return 1;
}

@ -0,0 +1,15 @@
#ifndef MAIN_H
#define MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#ifdef __cplusplus
}
#endif
#endif /* MAIN_H */

@ -4,7 +4,7 @@
# 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)
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR})
#Declaring sources directory for the project
#To add a new directory
@ -12,10 +12,9 @@ list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
# 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)
list(APPEND PROJECT_SOURCES_DIR)
#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 sensor)
set(PROJECT_SOURCES_DIR_LIST)

@ -15,7 +15,17 @@ int main(int argc, char *argv[])
uint8_t registerToRead = 0x00;
uint8_t i2cRecieved = 0;
uint8_t i2cData = 0xFF;
i2c_t i2c_1;
i2c_t i2c_1 = { I2C_CH_1, /*!< The harware channel to be used */
i2c_mode_master, /*!< Master Mode */
0x00, /*!< First and Main address of the device */
0x00, /*!< Second address if dual addresse mode is configured */
i2c_address_count_single, /*!< Single address */
i2c_address_size_7b, /*!< 10 or 7 bit address size */
i2c_clk_speed_standart, /*!< Bus Speed: standart */
i2c_clk_stretching_disable, /*!< Clock Streching disabeled */
i2c_wake_disabled /*!< Wake up condition : None */
};
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
@ -46,7 +56,7 @@ int main(int argc, char *argv[])
pinWrite(pinB3,0);
i2c_init(&i2c_1, I2C_CH_1, i2c_mode_master, 0x00,0x00, i2c_address_count_single, i2c_address_size_7b, i2c_clk_speed_standart, i2c_clk_stretching_disable, i2c_wake_disabled);
i2c_init(&i2c_1);
slaveAddress = SSD1306_I2C_ADDRESS;
registerToRead = 0x02;

@ -12,9 +12,9 @@ list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR})
# 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)
#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 sensor)
set(PROJECT_SOURCES_DIR_LIST)

@ -0,0 +1,40 @@
#include "main.h"
#include "delay.h"
#include "pin.h"
#include "deviceSetup.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.
uartCommInit();
//blinks 10 times to indicate the sicsessfull init if the device
for(i = 0 ; i < 2 ; i++) {
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
uartCommPrintWellcome();
sensorActivate(1);
sensorActivate(0);
while(1)
{
delayMs(100);
pinToggle(pinB3);
delayMs(100);
}
return 1;
}

@ -0,0 +1,21 @@
#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 sensor)
Loading…
Cancel
Save