|
|
|
@ -14,7 +14,6 @@
|
|
|
|
|
template <typename Derived>
|
|
|
|
|
struct PinBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
void set(bool logic)
|
|
|
|
|
{
|
|
|
|
|
static_cast<Derived*>(this)->setImp(logic);
|
|
|
|
@ -59,6 +58,11 @@ struct PinBase
|
|
|
|
|
|
|
|
|
|
struct STM32_Pin : PinBase<STM32_Pin>
|
|
|
|
|
{
|
|
|
|
|
STM32_Pin()
|
|
|
|
|
{
|
|
|
|
|
std::cout << "created STM32_Pin" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setImp(bool logic)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "stm32 pin set to " << logic << std::endl;
|
|
|
|
@ -73,10 +77,21 @@ struct STM32_Pin : PinBase<STM32_Pin>
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void STM32_stuff()
|
|
|
|
|
{
|
|
|
|
|
std::cout << "STM_32 specific stuff" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AVR_Pin : PinBase<AVR_Pin>
|
|
|
|
|
{
|
|
|
|
|
AVR_Pin()
|
|
|
|
|
{
|
|
|
|
|
std::cout << "created AVR_Pin" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setImp(bool logic)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "AVR pin set to " << logic << std::endl;
|
|
|
|
@ -91,6 +106,11 @@ struct AVR_Pin : PinBase<AVR_Pin>
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void avr_stuff()
|
|
|
|
|
{
|
|
|
|
|
std::cout << "AVR specific stuff" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
@ -106,6 +126,11 @@ int main(void)
|
|
|
|
|
STM32_Pin pin1;
|
|
|
|
|
AVR_Pin pin2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pin1.STM32_stuff();
|
|
|
|
|
|
|
|
|
|
pin2.avr_stuff();
|
|
|
|
|
|
|
|
|
|
foo(pin1);
|
|
|
|
|
foo(pin2);
|
|
|
|
|
|
|
|
|
|