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

Fake comparator driver. More...

Files

file  fake_comp.h
 Fake comparator driver API functions.

Functions

int comp_fake_comp_get_output (const struct device *)
 Fake implementation of the comparator_driver_api::get_output driver operation.
int comp_fake_comp_set_trigger (const struct device *, enum comparator_trigger)
 Fake implementation of the comparator_driver_api::set_trigger driver operation.
int comp_fake_comp_set_trigger_callback (const struct device *, comparator_callback_t, void *)
 Fake implementation of the comparator_driver_api::set_trigger_callback driver operation.
int comp_fake_comp_trigger_is_pending (const struct device *)
 Fake implementation of the comparator_driver_api::trigger_is_pending driver operation.

Detailed Description

Fake comparator driver.

This is a Fake Function Framework (FFF) implementation of the Comparator API, provided for use in tests. It is enabled by CONFIG_COMPARATOR_FAKE_COMP and instantiated from zephyr,fake-comp devicetree nodes.

Each fake below is paired with an FFF control structure named after it with an additional _fake suffix, which tests use to set return values, install custom fakes, or inspect call counts and captured arguments. The control structures are not listed here; see Mocking via FFF.

Use return_val for fakes that only report status; a fake with output parameters must be driven with a custom_fake, as return_val leaves those parameters untouched.

When CONFIG_ZTEST is enabled, a ztest rule resets every fake before each test case.

const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(fake_comp));
comp_fake_comp_get_output_fake.return_val = 1;
zassert_equal(1, comp_fake_comp_get_output_fake.call_count);
zassert_equal(dev, comp_fake_comp_get_output_fake.arg0_val);
int comparator_get_output(const struct device *dev)
Get comparator's output state.
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:323
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
#define zassert_equal(a, b,...)
Assert that a equals b.
Definition ztest_assert.h:321
Runtime device structure (in ROM) per driver instance.
Definition device.h:543

Function Documentation

◆ comp_fake_comp_get_output()

int comp_fake_comp_get_output ( const struct device * )

#include <zephyr/drivers/comparator/fake_comp.h>

Fake implementation of the comparator_driver_api::get_output driver operation.

◆ comp_fake_comp_set_trigger()

int comp_fake_comp_set_trigger ( const struct device * ,
enum comparator_trigger )

#include <zephyr/drivers/comparator/fake_comp.h>

Fake implementation of the comparator_driver_api::set_trigger driver operation.

◆ comp_fake_comp_set_trigger_callback()

int comp_fake_comp_set_trigger_callback ( const struct device * ,
comparator_callback_t ,
void *  )

#include <zephyr/drivers/comparator/fake_comp.h>

Fake implementation of the comparator_driver_api::set_trigger_callback driver operation.

◆ comp_fake_comp_trigger_is_pending()

int comp_fake_comp_trigger_is_pending ( const struct device * )

#include <zephyr/drivers/comparator/fake_comp.h>

Fake implementation of the comparator_driver_api::trigger_is_pending driver operation.