Working with ./run nucleo_f042K6 and ./run raspberry but must cahnge the headers. I will make a cmake configuration that will configure the main.hpp automatically

interrupts
key 4 years ago
parent 69d64d5127
commit 3f78936c4e

@ -8,9 +8,6 @@ if(EXISTS ${BSL_DIR}) # Cheking if the directory exists
message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}")
set(COMPILER_DEFS ${BSL_DIR}/bslCompiler.cmake)
set(PROJECT_DEFS ${BSL_DIR}/bslConfig.cmake)
elseif(BSL_USED STREQUAL "raspberry")
message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}")
else()
message( FATAL_ERROR "${BoldRed}Please Select a valid BSL, CMake will exit.${ColourReset}" )
endif()
@ -33,11 +30,6 @@ set(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/bsl/csl/interfaces)
include(${PROJECT_DEFS})
add_subdirectory(bsl)
#The order is important
list(APPEND EXTRA_LIBS sub::startup)
list(APPEND EXTRA_LIBS sub::translator)
list(APPEND EXTRA_LIBS sub::sources)
list(APPEND EXTRA_LIBS sub::gpio)
message("${BoldBlue}Project Info ${ColourReset}")
message("${Blue} |--> Exec Name \t: ${EXECUTABLE} ${ColourReset}")
@ -63,6 +55,8 @@ if(IS_NO_SYS)
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS})
else ()
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
endif()
####################################################################################################

@ -1,2 +1 @@
project(Csl_Stm)
add_subdirectory(stm32f042)
add_subdirectory(${CLS_USED})

@ -1,8 +1,4 @@
project(Csl_Stm32f0xx ASM C CXX) # do this intead sf declaring languages in the beginning it will prevent loop errors.
####################################################################################################
#SUBDIRECTORIES
####################################################################################################
add_subdirectory(Drivers)
add_subdirectory(startup)
add_subdirectory(Src)
#add_subdirectory(Src)

@ -2,5 +2,5 @@ add_library(rpiGpio gpio.cpp)
target_compile_options(rpiGpio PRIVATE ${C_FLAGS})
target_compile_definitions(rpiGpio PRIVATE ${C_DEFS})
target_include_directories(rpiGpio PUBLIC ${INTERFACES_DIR} ../Inc)
target_include_directories(rpiGpio PRIVATE ${INTERFACES_DIR} ../Inc)
add_library(sub::gpio ALIAS rpiGpio)

@ -1,6 +1,5 @@
#add_subdirectory(periferals)
add_library(stmTranslator bsl_nucleo_f042k6.cpp)
target_compile_options(stmTranslator PRIVATE ${C_FLAGS})
target_compile_definitions(stmTranslator PRIVATE ${C_DEFS})
target_include_directories(stmTranslator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CSL_INCLUDES})

@ -11,8 +11,3 @@ set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs") #AS we provide our own linker
option(IS_NO_SYS "Use a custom linker script" ON)
option(NEED_OBJCOPY "If objcopy is neede for cross compilation" ON)
####################################################################################################
#PROJECT & LIBRARIES : defined by user and important that it comes after the VARIABLES otherwise the Set varibale will not be used.
####################################################################################################
set(BSL_NAME nucleo_f042k6)

@ -18,11 +18,10 @@ set(CMAKE_CROSSCOMPILING TRUE)
set(LINKER ${CMAKE_SOURCE_DIR}/bsl/csl/stm32f042/startup/STM32F042K6Tx_FLASH.ld)
set(BSL_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CLS_USED ${CMAKE_SOURCE_DIR}/bsl/csl/stm32f042)
####################################################################################################
#VARIABLES : defined by user
####################################################################################################
set(CPU_MCU "-mcpu=cortex-m0")
set(CSL_INCLUDES
${CMAKE_SOURCE_DIR}/bsl/csl/stm32f042/Inc
@ -54,9 +53,6 @@ set(C_DEFS
-DINSTRUCTION_CACHE_ENABLE=0
-DDATA_CACHE_ENABLE=0)
set (CPP_INCLUDES ${CMAKE_SOURCE_DIR})
set (CPP_FLAGS ${C_FLAGS})
set (CPP_DEFS ${C_DEFS})
set(LINKER_FLAGS
${CPU_MCU}
@ -68,3 +64,13 @@ set(LINKER_FLAGS
-lnosys
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections)
#The order is important
set (CPP_INCLUDES ${CMAKE_SOURCE_DIR})
set (CPP_FLAGS ${C_FLAGS})
set (CPP_DEFS ${C_DEFS})
list(APPEND EXTRA_LIBS sub::startup)
list(APPEND EXTRA_LIBS sub::translator)
list(APPEND EXTRA_LIBS sub::sources)
list(APPEND EXTRA_LIBS sub::gpio)

@ -1,8 +1,20 @@
#include "bsl_nucleo_f042k6.h"
#include "bsl_nucleo_f042k6.hpp"
#include "../csl/interfaces/pin.hpp"
int cppHook()
int startBSL()
{
stmStart();
stmStart();
Pin pin;
while(1)
{
LL_mDelay(50);
pin.write(true);
LL_mDelay(50);
pin.write(false);
}
return 1;
}

@ -2,15 +2,7 @@
#define BSL_NUCLEO_F042K6_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f0xx_csl.h"
int cppHook();
#ifdef __cplusplus
} // closing brace for extern "C"
#endif
int startBSL();
#endif /* BSL_NUCLEO_F042K6_H */

@ -0,0 +1,7 @@
add_library(rpiTranslator bsl_raspberry.cpp)
target_compile_options(rpiTranslator PRIVATE ${C_FLAGS})
target_compile_definitions(rpiTranslator PRIVATE ${C_DEFS})
target_include_directories(rpiTranslator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(sub::translator ALIAS rpiTranslator)

@ -0,0 +1,14 @@
####################################################################################################
# bsl_nucleo_f042k6_compiler.cmake
####################################################################################################
set(CMAKE_SIZE "/usr/bin/size")
set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
option(IS_NO_SYS "Use a custom linker script" OFF)
option(NEED_OBJCOPY "If objcopy is neede for cross compilation" OFF)
####################################################################################################
#PROJECT & LIBRARIES : defined by user and important that it comes after the VARIABLES otherwise the Set varibale will not be used.
####################################################################################################

@ -0,0 +1,26 @@
####################################################################################################
# bsl_nucleo_f042k6.cmake
####################################################################################################
####################################################################################################
#PROJECT & LIBRARIES : defined by user and important that it comes after the VARIABLES otherwise the Set varibale will not be used.
####################################################################################################
set(CMAKE_CXX_STANDARD 11)
set(BSL_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CLS_USED ${CMAKE_SOURCE_DIR}/bsl/csl/rpi)
####################################################################################################
#VARIABLES : defined by user
####################################################################################################
set(C_FLAGS
-Wall #Error : If you don't know this one please chek basical compiling
-fdiagnostics-color=always
$<$<CONFIG:Debug>:-O -g -gdwarf-2>)
set(C_DEFS -DSET_ALARM)
set (CPP_INCLUDES ${CMAKE_SOURCE_DIR})
set (CPP_FLAGS ${C_FLAGS})
set (CPP_DEFS ${C_DEFS})
list(APPEND EXTRA_LIBS sub::translator)

@ -0,0 +1,8 @@
#include "bsl_raspberry.hpp"
int startBSL()
{
std::cout << "Hello from raspberry" << std::endl;
return 1;
}

@ -0,0 +1,8 @@
#ifndef BSL_RASPBERRY_HPP
#define BSL_RASPBERRY_HPP
#include <stdio.h>
#include <iostream>
int startBSL();
#endif

@ -1,18 +1,10 @@
#include"main.hpp"
#include "bsl/csl/interfaces/pin.hpp"
#include "bsl/raspberry/bsl_raspberry.hpp"
//#include "bsl/nucleo_f042k6/bsl_nucleo_f042k6.hpp"
int main(int argc, char *argv[])
{
Pin pin;
cppHook();
while(1)
{
LL_mDelay(500);
pin.write(true);
LL_mDelay(500);
pin.write(false);
}
startBSL();
return 1;
}

@ -1,5 +1,4 @@
#ifndef MAIN_H
#define MAIN_H
#include "bsl_nucleo_f042k6.h"
#endif /* MAIN_H */

Loading…
Cancel
Save