Reorganisation itteration 2

interrupts
key 4 years ago
parent 4dc986dbba
commit dc0aa76818

@ -1,29 +0,0 @@
cpp_src = $(wildcard *.cpp)
#cpp_src += $(wildcard ./utils/*.cpp)
#cpp_src += $(wildcard ./driver/*.cpp)
cpp_obj = $(cpp_src:.cpp=.o)
c_obj = $(c_src:.c=.o)
CC = g++
CFLAGS = -Wall -pedantic -li2c
LDFLAGS =
EXEC = runtest
all : $(EXEC)
$(EXEC): $(cpp_obj) $(c_obj)
$(CC) -o $@ $^ $(LDFLAGS)
debug : $(EXEC)
$(EXEC): $(cpp_obj) $(c_obj)
$(CC) -g -o $@ $^ $(LDFLAGS)
clean:
rm -rf $(c_obj) $(cpp_obj) $(EXEC)
clear
cleanall:
rm -rf $(c_obj) $(cpp_obj) $(EXEC)
clear

@ -1,42 +0,0 @@
#ifndef __HW_PLATTFORM_HPP__
#define __HW_PLATTFORM_HPP__
#include <iostream>
//
// csl ressources
//
#include "./../csl/implementations/dummy/dummy_pin.hpp"
//
// drivers
//
#include "./../drivers/LED.hpp"
struct HW_plattform
{
HW_plattform():
pin_0(),
pin_1(),
led_0(pin_0)
{}
void init()
{
std::cout << "bsl init..." << std::endl;
pin_0.set(false);
pin_1.set(false);
std::cout << "...done!" << std::endl;
};
private:
Dummy_Pin pin_0, pin_1;
public:
LED<Dummy_Pin> led_0;
};
#endif // __HW_PLATTFORM_HPP__

@ -1,37 +0,0 @@
#ifndef __AVR_PIN_HPP__
#define __AVR_PIN_HPP__
#include <iostream>
#include "./../../interfaces/pin.hpp"
struct AVR_Pin : Pin<AVR_Pin>
{
AVR_Pin()
{
std::cout << "created AVR_Pin" << std::endl;
}
void setImp(bool logic)
{
std::cout << "AVR pin set to " << logic << std::endl;
}
void toggleImp()
{
std::cout << "toggled AVR pin" << std::endl;
}
bool getImp()
{
return true;
}
void avr_stuff()
{
std::cout << "AVR specific stuff" << std::endl;
}
};
#endif // __AVR_PIN_HPP__

@ -1,38 +0,0 @@
#ifndef __DUMMY_PIN_HPP__
#define __DUMMY_PIN_HPP__
#include "./../../interfaces/pin.hpp"
#include <iostream>
struct Dummy_Pin : Pin<Dummy_Pin>
{
Dummy_Pin()
{
std::cout << "created Dummy_Pin" << std::endl;
}
void setImp(bool logic)
{
std::cout << "Dummy pin set to " << logic << std::endl;
}
void toggleImp()
{
std::cout << "toggled Dummy pin" << std::endl;
}
bool getImp()
{
return true;
}
void dummy_stuff()
{
std::cout << "dummy specific stuff" << std::endl;
}
};
#endif // __DUMMY_PIN_HPP__

@ -1,37 +0,0 @@
#ifndef __STM_PIN_HPP__
#define __STM_PIN_HPP__
#include "./../../interfaces/pin.hpp"
#include <iostream>
truct STM32_Pin : Pin<STM32_Pin>
{
STM32_Pin()
{
std::cout << "created STM32_Pin" << std::endl;
}
void setImp(bool logic)
{
std::cout << "stm32 pin set to " << logic << std::endl;
}
void toggleImp()
{
std::cout << "toggled stm32 pin" << std::endl;
}
bool getImp()
{
return true;
}
void STM32_stuff()
{
std::cout << "STM_32 specific stuff" << std::endl;
}
};
#endif // __STM_PIN_HPP__

@ -1,23 +0,0 @@
#ifndef __PIN_HPP__
#define __PIN_HPP__
template <typename Derived>
struct Pin
{
void set(bool logic)
{
static_cast<Derived*>(this)->setImp(logic);
}
void toggle()
{
static_cast<Derived*>(this)->toggleImp();
}
bool get(void)
{
return static_cast<Derived*>(this)->getImp();
}
};
#endif // __PIN_HPP__

@ -1,35 +0,0 @@
#ifndef __LED_HPP__
#define __LED_HPP__
#include "./../csl/interfaces/pin.hpp"
template <typename T>
class LED
{
public:
LED(Pin<T>& pin) :
pin(pin)
{}
void turnOn()
{
pin.set(true);
}
void turnOff()
{
pin.set(false);
}
void toggle()
{
pin.toggle();
}
private:
Pin<T>& pin;
};
#endif // __LED_HPP__

@ -1,16 +0,0 @@
#include <iostream>
#include "./bsl/hw_plattform.hpp"
int main()
{
HW_plattform hw;
hw.init();
//hw.pin_1.set(true);
hw.led_0.turnOn();
return 1;
}

Binary file not shown.

@ -1,7 +1,10 @@
set (STMSRC_INCLUDES
../Inc )
../Inc
${INTERFACES_DIR}
)
set(STMSRC_SOURCES
gpio.cpp
stm32f0xx_csl.c
stm32f0xx_it.c
system_stm32f0xx.c)
@ -13,3 +16,11 @@ target_include_directories(stmSources PUBLIC ${STMSRC_INCLUDES})
target_link_libraries(stmSources sub::drivers)
add_library(sub::sources ALIAS stmSources)
add_library(stmGpio gpio.cpp)
target_compile_options(stmGpio PRIVATE ${C_FLAGS})
target_compile_definitions(stmGpio PRIVATE ${C_DEFS})
target_include_directories(stmGpio PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES})
add_library(sub::gpio ALIAS stmGpio)

@ -1,6 +1,5 @@
#include "gpio.hpp"
#include "../../bsl_nucleo_f042k6.h"
#include "./../../../csl/stm32f042/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h"
#include "../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h"
#define PIN_COUNT 20

@ -1,4 +1,4 @@
add_subdirectory(periferals)
#add_subdirectory(periferals)
add_library(stmTranslator bsl_nucleo_f042k6.cpp)
target_compile_options(stmTranslator PRIVATE ${C_FLAGS})

@ -1,3 +1,7 @@
####################################################################################################
# bsl_nucleo_f042k6.cmake
####################################################################################################
set(CPU_MCU "-mcpu=cortex-m0")
set(IDIR_BIN "/home/key/Git/ked/bsl/nucleo_f042k6/bin")
@ -13,6 +17,7 @@ set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING TRUE)
set(LINKER ${CMAKE_SOURCE_DIR}/bsl/csl/stm32f042/startup/STM32F042K6Tx_FLASH.ld)
set(BSL_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
####################################################################################################
#VARIABLES : defined by user
####################################################################################################

@ -1,6 +0,0 @@
add_library(stmGpio gpio.cpp)
target_compile_options(stmGpio PRIVATE ${C_FLAGS})
target_compile_definitions(stmGpio PRIVATE ${C_DEFS})
target_include_directories(stmGpio PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES})
add_library(sub::gpio ALIAS stmGpio)

@ -8,9 +8,9 @@ int main(int argc, char *argv[])
while(1)
{
LL_mDelay(500);
LL_mDelay(50);
gpio.writePin(1,1);
LL_mDelay(500);
LL_mDelay(50);
gpio.writePin(1,0);
}
return 1;

Loading…
Cancel
Save