Functions
The following functions are available globally.
-
When you invoke the wait function, the CPU keeps on working and checking if the time set (in microsecond)is up. In addition, this function is more accurate than the sleep function.
Declaration
Swift
@inline(__always) public func wait(us: Int)
-
The sleep function will suspend the processor’s work in a given time period (in millisecond).
Declaration
Swift
@inline(__always) public func sleep(ms: Int)
-
Get the elapsed time in millisecond since the board powered up.
Declaration
Swift
@inline(__always) public func getPowerUpMilliseconds() -> Int64
Return Value
The elapsed time since power up in millisecond.
-
Get the current clock cycle of the low level 32bit timer.
Attention
This value is got from a 32bit register driven by the CPU frequency, it would overflow every a few seconds. This function is only used to measure very short time duration with
cyclesToNanoseconds(start: UInt, stop: UInt)
.Declaration
Swift
@inline(__always) public func getClockCycle() -> UInt
Return Value
The current clock cycle in UInt.
-
Convert the clock cycle into nanoseconds. This function is usually used together with
getClockCycle()
.Declaration
Swift
public func cyclesToNanoseconds(start: UInt, stop: UInt) -> Int64
Parameters
start
The start cycle get by
getClockCycle()
.stop
The stop cycle get by
getClockCycle()
.Return Value
The duration in nanoseconds.