RISC-V/V203F6P6/blink/main.cpp

29 lines
713 B
C++
Raw Normal View History

2025-01-25 10:55:11 +01:00
#include "system.h"
#include "gpio.h"
////////////////////////////////////////////////////////////////////////
static constexpr unsigned ticks = SYSTEM_CORE_CLOCK / 1000u;
static volatile unsigned counter = 0u;
extern "C" [[gnu::interrupt]] void SysTick_Handler ();
////////////////////////////////////////////////////////////////////////
void SysTick_Handler () {
SysTick.SR = 0u;
if (counter) counter -= 1u;
}
static void delay (const unsigned dly = 200u) {
counter = dly;
while (counter);
}
int main () {
GpioClass led (GPIOB, 8);
SysTick.Config (ticks);
unsigned pass_cnt = 0u;
for (;;) {
delay();
const bool b = pass_cnt & 1u;
led << b;
pass_cnt += 1u;
}
return 0;
}