|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Scheduled precision clock outputs. More...
Topics | |
| Precision clock output provider | |
| Precision clock output provider extension. | |
Data Structures | |
| struct | precision_clock_output_channel_caps |
| Capabilities and limits of a precision clock output channel. More... | |
| struct | precision_clock_output_caps |
| Capabilities of all scheduled-output channels on a precision clock. More... | |
| struct | precision_clock_output_waveform_config |
| Configuration of a periodic clock output waveform. More... | |
| struct | precision_clock_output_config |
| Requested or accepted configuration of a scheduled clock output channel. More... | |
| struct | precision_clock_output_status |
| Observable status of a precision clock output channel. More... | |
Enumerations | |
| enum | precision_clock_output_width_policy { PRECISION_CLOCK_OUTPUT_WIDTH_PROVIDER_DEFAULT = 0 , PRECISION_CLOCK_OUTPUT_WIDTH_EXACT = 1 } |
| Precision clock output high-pulse width policy for periodic waveforms. More... | |
| enum | precision_clock_output_kind { PRECISION_CLOCK_OUTPUT_KIND_WAVEFORM = 1 } |
| Kind of scheduled output configured on a precision clock output channel. More... | |
| enum | precision_clock_output_caps_flags { PRECISION_CLOCK_OUTPUT_CAP_WAVEFORM = BIT(0) , PRECISION_CLOCK_OUTPUT_CAP_PROGRAMMABLE_WIDTH = BIT(1) , PRECISION_CLOCK_OUTPUT_CAP_HARDWARE_ACTIVE = BIT(2) } |
| Precision clock output capability flags. More... | |
Functions | |
| int | precision_clock_output_get_caps (const struct precision_clock *precision_clk, struct precision_clock_output_caps *caps) |
| Query capabilities of all scheduled-output channels. | |
| int | precision_clock_output_next_start_time (precision_time_t now, precision_time_t period_ns, precision_time_t min_lead_time_ns, precision_time_t *start_time) |
| Calculate the next aligned clock-output start time. | |
| int | precision_clock_output_start (const struct precision_clock *precision_clk, uint32_t channel, const struct precision_clock_output_config *config) |
| Start a scheduled clock output. | |
| int | precision_clock_output_stop (const struct precision_clock *precision_clk, uint32_t channel) |
| Stop a scheduled clock output. | |
| int | precision_clock_output_get_status (const struct precision_clock *precision_clk, uint32_t channel, struct precision_clock_output_status *status) |
| Query scheduled clock output status. | |
Scheduled precision clock outputs.
#include <zephyr/precision_timing/precision_clock_output.h>
Precision clock output capability flags.
#include <zephyr/precision_timing/precision_clock_output.h>
Kind of scheduled output configured on a precision clock output channel.
| Enumerator | |
|---|---|
| PRECISION_CLOCK_OUTPUT_KIND_WAVEFORM | Periodic waveform. |
#include <zephyr/precision_timing/precision_clock_output.h>
Precision clock output high-pulse width policy for periodic waveforms.
| int precision_clock_output_get_caps | ( | const struct precision_clock * | precision_clk, |
| struct precision_clock_output_caps * | caps ) |
#include <zephyr/precision_timing/precision_clock_output.h>
Query capabilities of all scheduled-output channels.
The returned channel table is provider-owned and remains valid and unchanged for the lifetime of the initialized clock. No caller allocation is required. The provider is responsible for returning valid capabilities.
Call from thread context. The provider operation may block.
| precision_clk | Clock whose outputs are queried. |
| caps | Destination for the channel count and read-only channel table. |
| 0 | on success. |
| -EINVAL | if an argument or clock API is invalid. |
| -ENOTSUP | if scheduled output is unsupported. |
| int precision_clock_output_get_status | ( | const struct precision_clock * | precision_clk, |
| uint32_t | channel, | ||
| struct precision_clock_output_status * | status ) |
#include <zephyr/precision_timing/precision_clock_output.h>
Query scheduled clock output status.
Reports whether the provider holds a configuration for the channel, the configured kind and accepted configuration, and the physical output state when observable. The provider validates channel and returns a consistent status. This operation does not query capabilities or revalidate the accepted configuration against the current time.
Call from thread context. The provider operation may block.
| precision_clk | Clock that owns the output channel. |
| channel | Provider-defined, zero-based output channel index. |
| status | Destination for the configuration and hardware-active state. |
| 0 | on success. |
| -EINVAL | if an argument or clock API is invalid. |
| -ENOTSUP | if status reporting or channel is unsupported. |
| int precision_clock_output_next_start_time | ( | precision_time_t | now, |
| precision_time_t | period_ns, | ||
| precision_time_t | min_lead_time_ns, | ||
| precision_time_t * | start_time ) |
#include <zephyr/precision_timing/precision_clock_output.h>
Calculate the next aligned clock-output start time.
Finds the earliest integer multiple of period_ns at or after the sum of now and min_lead_time_ns. Negative clock values are supported.
| now | Current time of the output clock. |
| period_ns | Positive output period in nanoseconds. |
| min_lead_time_ns | Non-negative time required before the first edge. |
| start_time | Destination for the aligned start time. |
| 0 | on success. |
| -EINVAL | if an argument, period, or lead time is invalid. |
| -ERANGE | if calculating the aligned start time overflows. |
| int precision_clock_output_start | ( | const struct precision_clock * | precision_clk, |
| uint32_t | channel, | ||
| const struct precision_clock_output_config * | config ) |
#include <zephyr/precision_timing/precision_clock_output.h>
Start a scheduled clock output.
Set config kind to PRECISION_CLOCK_OUTPUT_KIND_WAVEFORM to generate a periodic waveform described by config waveform. The first rising edge occurs at first_rising_time and subsequent edges are separated by period_ns. The channel must advertise PRECISION_CLOCK_OUTPUT_CAP_WAVEFORM. When width_policy is PRECISION_CLOCK_OUTPUT_WIDTH_EXACT the channel must also advertise PRECISION_CLOCK_OUTPUT_CAP_PROGRAMMABLE_WIDTH and the pulse width must be positive and shorter than the period; otherwise the provider default width is used and pulse_width_ns is ignored. Configuration values must be exactly representable at the channel resolution. Starting an already configured channel is rejected; stop the channel before reconfiguring it.
Only a return of 0 or -EINPROGRESS gives the caller ownership of the channel. -EINPROGRESS means programming failed and the provider retained the configuration because it could not safely release the channel. In that case, the caller must stop the output successfully before retrying or releasing the underlying device. No other failure gives the caller ownership or authorizes it to stop the channel.
Call from thread context. The provider operation may block.
| precision_clk | Clock that owns the output channel. |
| channel | Provider-defined, zero-based output channel index. |
| config | Output kind and its configuration. |
| 0 | on success. |
| -EINVAL | if an argument, output kind, width policy, or interval relationship is invalid, or the provider reports a non-positive resolution for the selected channel. |
| -ENOTSUP | if periodic waveforms, programmable width, or channel is unsupported. |
| -ERANGE | if a value is outside channel limits or not representable. |
| -ETIME | if the first rising edge does not meet the minimum lead time; the caller may retry with a new start time without stopping the channel. |
| -EBUSY | if the channel is already configured for output, is in use by another device function, or is reserved by the driver. |
| -EINPROGRESS | if programming failed and this attempt retained the channel. |
| -EIO | if a capability query or clock read failed with -ETIME or -EINPROGRESS, which have distinct meanings for start. |
| int precision_clock_output_stop | ( | const struct precision_clock * | precision_clk, |
| uint32_t | channel ) |
#include <zephyr/precision_timing/precision_clock_output.h>
Stop a scheduled clock output.
Stopping a channel that is already unconfigured is idempotent. The operation is delegated directly to the provider so a capability-query failure cannot prevent an active output from being stopped.
Call from thread context. The provider operation may block.
| precision_clk | Clock that owns the output channel. |
| channel | Provider-defined, zero-based output channel index. |
| 0 | on success or if the channel is already unconfigured. |
| -EINVAL | if the clock or clock API is invalid. |
| -ENOTSUP | if scheduled output or channel is unsupported. |