Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

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.

Detailed Description

Scheduled precision clock outputs.

Since
4.6
Version
0.1.0

Enumeration Type Documentation

◆ precision_clock_output_caps_flags

#include <zephyr/precision_timing/precision_clock_output.h>

Precision clock output capability flags.

Enumerator
PRECISION_CLOCK_OUTPUT_CAP_WAVEFORM 

Channel can generate periodic output waveforms.

PRECISION_CLOCK_OUTPUT_CAP_PROGRAMMABLE_WIDTH 

Channel supports an exact programmable high-pulse width.

PRECISION_CLOCK_OUTPUT_CAP_HARDWARE_ACTIVE 

Channel can observe whether its hardware output generator is armed or running.

◆ precision_clock_output_kind

#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.

◆ precision_clock_output_width_policy

#include <zephyr/precision_timing/precision_clock_output.h>

Precision clock output high-pulse width policy for periodic waveforms.

Enumerator
PRECISION_CLOCK_OUTPUT_WIDTH_PROVIDER_DEFAULT 

Use the provider's native default high-pulse width.

PRECISION_CLOCK_OUTPUT_WIDTH_EXACT 

Use the exact high-pulse width supplied in the configuration.

Function Documentation

◆ precision_clock_output_get_caps()

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.

Parameters
precision_clkClock whose outputs are queried.
capsDestination for the channel count and read-only channel table.
Return values
0on success.
-EINVALif an argument or clock API is invalid.
-ENOTSUPif scheduled output is unsupported.
Returns
A provider-specific negative error code on failure.

◆ precision_clock_output_get_status()

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.

Parameters
precision_clkClock that owns the output channel.
channelProvider-defined, zero-based output channel index.
statusDestination for the configuration and hardware-active state.
Return values
0on success.
-EINVALif an argument or clock API is invalid.
-ENOTSUPif status reporting or channel is unsupported.
Returns
A provider-specific negative error code on failure.

◆ precision_clock_output_next_start_time()

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.

Parameters
nowCurrent time of the output clock.
period_nsPositive output period in nanoseconds.
min_lead_time_nsNon-negative time required before the first edge.
start_timeDestination for the aligned start time.
Return values
0on success.
-EINVALif an argument, period, or lead time is invalid.
-ERANGEif calculating the aligned start time overflows.

◆ precision_clock_output_start()

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.

Parameters
precision_clkClock that owns the output channel.
channelProvider-defined, zero-based output channel index.
configOutput kind and its configuration.
Return values
0on success.
-EINVALif an argument, output kind, width policy, or interval relationship is invalid, or the provider reports a non-positive resolution for the selected channel.
-ENOTSUPif periodic waveforms, programmable width, or channel is unsupported.
-ERANGEif a value is outside channel limits or not representable.
-ETIMEif the first rising edge does not meet the minimum lead time; the caller may retry with a new start time without stopping the channel.
-EBUSYif the channel is already configured for output, is in use by another device function, or is reserved by the driver.
-EINPROGRESSif programming failed and this attempt retained the channel.
-EIOif a capability query or clock read failed with -ETIME or -EINPROGRESS, which have distinct meanings for start.
Returns
A provider-specific negative error code on failure.

◆ precision_clock_output_stop()

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.

Parameters
precision_clkClock that owns the output channel.
channelProvider-defined, zero-based output channel index.
Return values
0on success or if the channel is already unconfigured.
-EINVALif the clock or clock API is invalid.
-ENOTSUPif scheduled output or channel is unsupported.
Returns
A provider-specific negative error code on failure.