package ti.mcu.cc23xx
from em.hal import UsCounterI
import Mcu
module UsCounter: UsCounterI
end
def start()
^^SysTick->CTRL = (1 << SysTick_CTRL_CLKSOURCE_Pos) | (1 << SysTick_CTRL_ENABLE_Pos)^^
^^SysTick->LOAD = 0xFFFFFF^^
^^SysTick->VAL = 0^^
end
def stop()
auto lr = <uint32>^^SysTick->LOAD^^
auto vr = <uint32>^^SysTick->VAL^^
auto dt = (((lr - vr) << 1) / (Mcu.mclkFrequency / 1000000)) >> 1
^^SysTick->CTRL = 0^^
return dt
end