File syn_hpclock.c¶
FileList > drivers > syn_hpclock.c
Go to the source code of this file
High-precision clock — resolution and conversion implementation.
#include "../util/syn_assert.h"#include "syn_hpclock.h"
Public Attributes¶
| Type | Name |
|---|---|
| volatile uint32_t | syn_hpclock_msb Global overflow counter — incremented by the platform ISR. |
Public Functions¶
| Type | Name |
|---|---|
| uint64_t | syn_hpclock_elapsed (const SYN_HPTimestamp * start, const SYN_HPTimestamp * end) Compute elapsed ticks between two timestamps. |
| uint64_t | syn_hpclock_resolve (const SYN_HPTimestamp * ts) Resolve a raw timestamp into a 64-bit tick count. |
| uint64_t | syn_hpclock_ticks_to_ns (uint64_t ticks) Convert a tick count to nanoseconds. |
Public Attributes Documentation¶
variable syn_hpclock_msb¶
Global overflow counter — incremented by the platform ISR.
Declared here so both the port ISR and the driver can access it. Defined in syn_hpclock.c.
Public Functions Documentation¶
function syn_hpclock_elapsed¶
Compute elapsed ticks between two timestamps.
Resolves both timestamps and returns the difference. Assumes end was captured after start.
Parameters:
startEarlier timestamp.endLater timestamp.
Returns:
Elapsed ticks (end - start).
function syn_hpclock_resolve¶
Resolve a raw timestamp into a 64-bit tick count.
If msb_1 == msb_2, no overflow occurred and either MSB is correct. If they differ, the overflow happened during the capture window and the LSB value determines which side of the wrap it was captured on: a small LSB (< 0x80000000) means post-wrap (use msb_2), a large LSB means pre-wrap (use msb_1).
This is a pure function — no side effects, no hardware access.
Parameters:
tsPointer to a captured timestamp.
Returns:
64-bit tick count at system clock precision.
function syn_hpclock_ticks_to_ns¶
Convert a tick count to nanoseconds.
Uses integer-only arithmetic: ns = ticks * 1000000000 / freq_hz. The division is performed with 64-bit precision to avoid overflow.
Parameters:
ticksTick count from syn_hpclock_resolve().
Returns:
Equivalent time in nanoseconds.
The documentation for this class was generated from the following file src/syntropic/drivers/syn_hpclock.c