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

Emulated counter backend API. More...

Functions

int counter_capture_emul_input_set (const struct device *dev, uint8_t chan_id, int level)
 Set the emulated capture input level on a channel.
static int counter_capture_emul_input_set_dt (const struct counter_capture_dt_spec *spec, int level)
 Set the emulated capture input level on a channel from a DT spec.
int counter_capture_emul_input_get (const struct device *dev, uint8_t chan_id)
 Get the emulated capture input level on a channel.
static int counter_capture_emul_input_get_dt (const struct counter_capture_dt_spec *spec)
 Get the emulated capture input level on a channel from a DT spec.

Detailed Description

Emulated counter backend API.

Behaviour of the emulated counter capture is application-defined. Tests drive a capture event by setting the emulated input level on a capture channel with counter_capture_emul_input_set. When the level transition matches the edge the channel was configured for (via counter_capture_configure) and the channel is enabled, the registered capture callback is invoked synchronously, much like gpio_emul_input_set fires GPIO interrupt callbacks.

The edges an emulated counter supports are declared in devicetree using the rising-edge and falling-edge boolean properties on the counter node.

Function Documentation

◆ counter_capture_emul_input_get()

int counter_capture_emul_input_get ( const struct device * dev,
uint8_t chan_id )

#include <zephyr/drivers/counter/counter_capture_emul.h>

Get the emulated capture input level on a channel.

Parameters
devEmulated counter device
chan_idCapture channel ID
Returns
the current input level (0 or 1) on success
-EINVAL if chan_id is out of range

◆ counter_capture_emul_input_get_dt()

int counter_capture_emul_input_get_dt ( const struct counter_capture_dt_spec * spec)
inlinestatic

#include <zephyr/drivers/counter/counter_capture_emul.h>

Get the emulated capture input level on a channel from a DT spec.

Equivalent to:

counter_capture_emul_input_get(spec->dev, spec->chan_id);
Parameters
specCounter capture DT spec
Returns
a value from counter_capture_emul_input_get()

◆ counter_capture_emul_input_set()

int counter_capture_emul_input_set ( const struct device * dev,
uint8_t chan_id,
int level )

#include <zephyr/drivers/counter/counter_capture_emul.h>

Set the emulated capture input level on a channel.

Drives level on the emulated capture input of chan_id. If the resulting edge matches the channel's configured capture flags and the channel is enabled, the capture callback is invoked synchronously with the current counter value.

Parameters
devEmulated counter device
chan_idCapture channel ID
levelNew input level (0 or non-zero)
Returns
0 on success
-EINVAL if chan_id is out of range

◆ counter_capture_emul_input_set_dt()

int counter_capture_emul_input_set_dt ( const struct counter_capture_dt_spec * spec,
int level )
inlinestatic

#include <zephyr/drivers/counter/counter_capture_emul.h>

Set the emulated capture input level on a channel from a DT spec.

Equivalent to:

counter_capture_emul_input_set(spec->dev, spec->chan_id, level);
Parameters
specCounter capture DT spec
levelNew input level (0 or non-zero)
Returns
a value from counter_capture_emul_input_set()