added structure idea for KED

master
polymurph 4 years ago
parent c3104ab657
commit cfc7c07bb1

@ -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

@ -0,0 +1,12 @@
#ifndef __HW_PLATTFORM_HPP__
#define __HW_PLATTFORM_HPP__
#include "./../csl/implementations/dummy/dummy_pin.hpp"
struct HW_plattform
{
Dummy_Pin pin_0, pin_1;
};
#endif // __HW_PLATTFORM_HPP__

@ -0,0 +1,37 @@
#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__

@ -0,0 +1,38 @@
#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__

@ -0,0 +1,37 @@
#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__

@ -0,0 +1,23 @@
#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__

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

Binary file not shown.
Loading…
Cancel
Save