RISC-V/V203/test/main.cpp
2024-05-07 11:46:49 +02:00

28 lines
720 B
C++

#include "system.h"
#include "gpio.h"
////////////////////////////////////////////////////////////////////////
static constexpr unsigned ticks = SYSTEM_CORE_CLOCK / 1000u;
static volatile unsigned counter = 0u;
extern "C" void SysTick_Handler ()__attribute__((interrupt));
////////////////////////////////////////////////////////////////////////
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 (GPIOA, 0);
SysTick.Config (ticks);
unsigned pass_cnt = 0u;
for (;;) {
delay();
const bool b = pass_cnt & 1u;
led << b;
pass_cnt += 1u;
}
return 0;
}