Module/sys.cpp
2024-01-16 20:05:11 +01:00

22 lines
414 B
C++

module;
#include "CortexM4.h"
#include "system.h"
export module sys;
static volatile unsigned count = 0u;
extern "C" void SysTick_Handler () {
if (count) count -= 1u;
}
namespace sys {
export void delay (const unsigned ms = 500) {
count = ms;
while (count) {
asm volatile ("wfi");
}
}
export void init () {
EnableDebugOnSleep();
SysTick.Config (SystemCoreClock / 1000u);
}
};