diff --git a/KED_structure_idea/Makefile b/KED_structure_idea/Makefile new file mode 100644 index 0000000..db99c6d --- /dev/null +++ b/KED_structure_idea/Makefile @@ -0,0 +1,29 @@ +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 diff --git a/KED_structure_idea/bsl/hw_plattform.hpp b/KED_structure_idea/bsl/hw_plattform.hpp new file mode 100644 index 0000000..31d711d --- /dev/null +++ b/KED_structure_idea/bsl/hw_plattform.hpp @@ -0,0 +1,42 @@ +#ifndef __HW_PLATTFORM_HPP__ +#define __HW_PLATTFORM_HPP__ + +#include + +// +// 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 led_0; +}; + + +#endif // __HW_PLATTFORM_HPP__ diff --git a/KED_structure_idea/csl/implementations/avr/avr_pin.hpp b/KED_structure_idea/csl/implementations/avr/avr_pin.hpp new file mode 100644 index 0000000..42c49ec --- /dev/null +++ b/KED_structure_idea/csl/implementations/avr/avr_pin.hpp @@ -0,0 +1,37 @@ +#ifndef __AVR_PIN_HPP__ +#define __AVR_PIN_HPP__ + +#include +#include "./../../interfaces/pin.hpp" + + + +struct AVR_Pin : 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__ \ No newline at end of file diff --git a/KED_structure_idea/csl/implementations/dummy/dummy_pin.hpp b/KED_structure_idea/csl/implementations/dummy/dummy_pin.hpp new file mode 100644 index 0000000..96b1cb6 --- /dev/null +++ b/KED_structure_idea/csl/implementations/dummy/dummy_pin.hpp @@ -0,0 +1,38 @@ +#ifndef __DUMMY_PIN_HPP__ +#define __DUMMY_PIN_HPP__ + +#include "./../../interfaces/pin.hpp" + +#include + + +struct Dummy_Pin : 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__ diff --git a/KED_structure_idea/csl/implementations/stm/stm_pin.hpp b/KED_structure_idea/csl/implementations/stm/stm_pin.hpp new file mode 100644 index 0000000..2d4cf74 --- /dev/null +++ b/KED_structure_idea/csl/implementations/stm/stm_pin.hpp @@ -0,0 +1,37 @@ +#ifndef __STM_PIN_HPP__ +#define __STM_PIN_HPP__ + +#include "./../../interfaces/pin.hpp" + +#include + +truct STM32_Pin : 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__ diff --git a/KED_structure_idea/csl/interfaces/pin.hpp b/KED_structure_idea/csl/interfaces/pin.hpp new file mode 100644 index 0000000..3c9c76d --- /dev/null +++ b/KED_structure_idea/csl/interfaces/pin.hpp @@ -0,0 +1,23 @@ +#ifndef __PIN_HPP__ +#define __PIN_HPP__ + +template +struct Pin +{ + void set(bool logic) + { + static_cast(this)->setImp(logic); + } + + void toggle() + { + static_cast(this)->toggleImp(); + } + + bool get(void) + { + return static_cast(this)->getImp(); + } +}; + +#endif // __PIN_HPP__ diff --git a/KED_structure_idea/drivers/LED.hpp b/KED_structure_idea/drivers/LED.hpp new file mode 100644 index 0000000..dfaec72 --- /dev/null +++ b/KED_structure_idea/drivers/LED.hpp @@ -0,0 +1,35 @@ +#ifndef __LED_HPP__ +#define __LED_HPP__ + +#include "./../csl/interfaces/pin.hpp" + +template +class LED +{ + public: + + LED(Pin& pin) : + pin(pin) + {} + + void turnOn() + { + pin.set(true); + } + + void turnOff() + { + pin.set(false); + } + + void toggle() + { + pin.toggle(); + } + + private: + + Pin& pin; +}; + +#endif // __LED_HPP__ diff --git a/KED_structure_idea/main.cpp b/KED_structure_idea/main.cpp new file mode 100644 index 0000000..522a52f --- /dev/null +++ b/KED_structure_idea/main.cpp @@ -0,0 +1,16 @@ +#include + +#include "./bsl/hw_plattform.hpp" + + +int main() +{ + HW_plattform hw; + hw.init(); + + //hw.pin_1.set(true); + + hw.led_0.turnOn(); + + return 1; +} \ No newline at end of file diff --git a/KED_structure_idea/runtest b/KED_structure_idea/runtest new file mode 100755 index 0000000..13f81ba Binary files /dev/null and b/KED_structure_idea/runtest differ