std1.0.0-beta-7 SafeC docs

std :: hal::timer

Struct std::Timer

#include <std/hal/timer.h> source

generic<C: TimerChip> struct Timer {
    &volatile unsigned int base;
    unsigned int prescaler;
    C chip;
}

Fields

§&volatile unsigned int basesource

MMIO base address

§unsigned int prescalersource

clock divider

§C chipsource

Methods

§static struct Timer<C> new(&volatile unsigned int base, unsigned int prescaler)source · definition

Initialize a hardware timer at base with the given prescaler (STM32: the counter runs at clock / (prescaler + 1)). The chip type comes from the target.

§void set_period(unsigned int period)source · definition

Set the auto-reload (period) value.

§void start()source · definition

Start the timer.

§void stop()source · definition

Stop the timer.

§unsigned int read() constsource · definition

Read the current counter value.

§void clear_flag()source · definition

Clear the interrupt/overflow flag.

§int flag_set() constsource · definition

Check if the overflow/compare flag is set. Returns 1 if set.