13#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_MONITOR_H_
14#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_MONITOR_H_
209static inline int z_impl_clock_monitor_configure(
const struct device *dev,
249static inline int z_impl_clock_monitor_start(
const struct device *dev)
271static inline int z_impl_clock_monitor_stop(
const struct device *dev)
297static inline int z_impl_clock_monitor_get_rate(
const struct device *dev,
331static inline int z_impl_clock_monitor_set_source(
const struct device *dev,
341 return api->
set_source(dev, reference, target);
352#include <zephyr/syscalls/clock_monitor.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
int(* clock_monitor_api_stop)(const struct device *dev)
Callback API for stopping the clock monitor (ISR-safe).
Definition clock_monitor.h:149
int(* clock_monitor_api_configure)(const struct device *dev, const struct clock_monitor_config *cfg)
Callback API for configuring a clock monitor.
Definition clock_monitor.h:142
int(* clock_monitor_api_start)(const struct device *dev)
Callback API for starting the configured mode.
Definition clock_monitor.h:146
int(* clock_monitor_api_set_source)(const struct device *dev, uint32_t reference, uint32_t target)
Callback API for switching the reference / target clock inputs.
Definition clock_monitor.h:156
int(* clock_monitor_api_get_rate)(const struct device *dev, uint32_t *rate_hz)
Callback API for polling the most recent measured rate.
Definition clock_monitor.h:152
void(* clock_monitor_callback_t)(const struct device *dev, const struct clock_monitor_event_data *evt, void *user_data)
Callback invoked on clock monitor events.
Definition clock_monitor.h:107
int clock_monitor_set_source(const struct device *dev, uint32_t reference, uint32_t target)
Switch the reference / target clock inputs at runtime.
int clock_monitor_start(const struct device *dev)
Start operation of the configured mode.
int clock_monitor_stop(const struct device *dev)
Stop the monitor.
int clock_monitor_configure(const struct device *dev, const struct clock_monitor_config *cfg)
Apply a monitor configuration.
int clock_monitor_get_rate(const struct device *dev, uint32_t *rate_hz)
Poll the most recent completed measurement.
clock_monitor_mode
Operating mode of a clock monitor instance.
Definition clock_monitor.h:42
@ CLOCK_MONITOR_EVT_MEASURE_DONE
Frequency measurement completed.
Definition clock_monitor.h:68
@ CLOCK_MONITOR_EVT_CLOCK_LOST
Monitored clock stopped or stuck.
Definition clock_monitor.h:66
@ CLOCK_MONITOR_EVT_FREQ_HIGH
Monitored frequency exceeded the upper threshold.
Definition clock_monitor.h:62
@ CLOCK_MONITOR_EVT_FREQ_LOW
Monitored frequency fell below the lower threshold.
Definition clock_monitor.h:64
@ CLOCK_MONITOR_MODE_WINDOW
Continuous high/low threshold window check: the frequency of the monitored clock is continuously comp...
Definition clock_monitor.h:48
@ CLOCK_MONITOR_MODE_MEASURE
One frequency measurement per clock_monitor_start, reported in Hz through the configure-time callback...
Definition clock_monitor.h:56
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Top-level configuration handed to clock_monitor_configure.
Definition clock_monitor.h:120
struct clock_monitor_measure_cfg measure
Honored when mode is MEASURE.
Definition clock_monitor.h:128
void * user_data
Opaque user pointer passed to callback.
Definition clock_monitor.h:133
enum clock_monitor_mode mode
Operating mode to activate.
Definition clock_monitor.h:122
struct clock_monitor_window_cfg window
Honored when mode is WINDOW.
Definition clock_monitor.h:126
clock_monitor_callback_t callback
Optional callback for asynchronous event delivery.
Definition clock_monitor.h:131
<span class="mlabel">Driver Operations</span> CLOCK_MONITOR driver operations
Definition clock_monitor.h:163
clock_monitor_api_configure configure
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition clock_monitor.h:167
clock_monitor_api_stop stop
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition clock_monitor.h:175
clock_monitor_api_get_rate get_rate
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition clock_monitor.h:179
clock_monitor_api_start start
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition clock_monitor.h:171
clock_monitor_api_set_source set_source
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition clock_monitor.h:183
Event payload delivered to the user callback.
Definition clock_monitor.h:88
uint32_t events
Bitmask of latched CLOCK_MONITOR_EVT_* flags.
Definition clock_monitor.h:90
uint32_t measured_hz
Result of the measurement that completed with this event (Hz); valid when events & CLOCK_MONITOR_EVT_...
Definition clock_monitor.h:94
Configuration for CLOCK_MONITOR_MODE_MEASURE.
Definition clock_monitor.h:82
uint32_t window_ns
Measurement window duration in ns.
Definition clock_monitor.h:84
Configuration for CLOCK_MONITOR_MODE_WINDOW.
Definition clock_monitor.h:72
uint32_t expected_hz
Nominal expected frequency of the monitored clock (Hz).
Definition clock_monitor.h:74
uint32_t tolerance_ppm
Acceptable deviation in parts-per-million (± value).
Definition clock_monitor.h:76
uint32_t window_ns
Measurement window duration in ns.
Definition clock_monitor.h:78
Runtime device structure (in ROM) per driver instance.
Definition device.h:513