Module/sys.cpp

23 lines
414 B
C++
Raw Permalink Normal View History

2024-01-16 20:05:11 +01:00
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);
}
};