Automated the project configuration file. I need now to moove all the auto include funtions in one file
parent
00a6e0c8e7
commit
6a4ec9adcf
@ -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 */
|
@ -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()
|
Loading…
Reference in new issue