diff --git a/ideas/delay_structure.cpp b/ideas/delay_structure.cpp new file mode 100644 index 0000000..56b7344 --- /dev/null +++ b/ideas/delay_structure.cpp @@ -0,0 +1,45 @@ +// check it out on Compiler Explorer : https://godbolt.org/ +struct Delay +{ + virtual void wait() = 0; +}; + + +struct FreeRTOS_Delay : Delay +{ + void wait() override + { + _wait(); + } + private: + static void _wait() + { + for(volatile int i = 0; i < 10; i++); + } +}; + +struct STM_Hal_Delay : Delay +{ + void wait() override + { + _wait(); + } + private: + static void _wait() + { + // systick stuff here + for(volatile int i = 0; i < 1000; i++); + } +}; + + + + +int main() +{ + FreeRTOS_Delay dly; + + dly.wait(); + return 0; +} +