Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Fake LED controller

Fake LED controller driver. More...

Files

file  led_fake.h
 Fake LED controller driver API functions.

Functions

 DECLARE_FAKE_VALUE_FUNC (int, fake_led_on, const struct device *, uint32_t)
 @fake_of{led_driver_api::on}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_off, const struct device *, uint32_t)
 @fake_of{led_driver_api::off}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_set_brightness, const struct device *, uint32_t, uint8_t)
 @fake_of{led_driver_api::set_brightness}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_blink, const struct device *, uint32_t, uint32_t, uint32_t)
 @fake_of{led_driver_api::blink}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_get_info, const struct device *, uint32_t, const struct led_info **)
 @fake_of{led_driver_api::get_info}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_set_color, const struct device *, uint32_t, uint8_t, const uint8_t *)
 @fake_of{led_driver_api::set_color}
 DECLARE_FAKE_VALUE_FUNC (int, fake_led_write_channels, const struct device *, uint32_t, uint32_t, const uint8_t *)
 @fake_of{led_driver_api::write_channels}

Detailed Description

Fake LED controller driver.

@driver_fake{led_interface,CONFIG_LED_FAKE,zephyr\,fake-leds}

fake_led_get_info() and fake_led_set_color() are given a default custom_fake resolving the LED index and colour count against the devicetree node, re-installed on every reset. Install your own custom_fake in the test case to change what they report.

const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(fake_leds));
fake_led_on_fake.return_val = -EIO;
zassert_equal(1, fake_led_on_fake.call_count);
zassert_equal(2, fake_led_on_fake.arg1_val);
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:317
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
int led_on(const struct device *dev, uint32_t led)
Turn on an LED.
#define EIO
I/O error.
Definition errno.h:44
#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:525

Function Documentation

◆ DECLARE_FAKE_VALUE_FUNC() [1/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_blink ,
const struct device * ,
uint32_t ,
uint32_t ,
uint32_t  )

#include <led_fake.h>

@fake_of{led_driver_api::blink}

◆ DECLARE_FAKE_VALUE_FUNC() [2/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_get_info ,
const struct device * ,
uint32_t ,
const struct led_info **  )

#include <led_fake.h>

@fake_of{led_driver_api::get_info}

◆ DECLARE_FAKE_VALUE_FUNC() [3/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_off ,
const struct device * ,
uint32_t  )

#include <led_fake.h>

@fake_of{led_driver_api::off}

◆ DECLARE_FAKE_VALUE_FUNC() [4/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_on ,
const struct device * ,
uint32_t  )

#include <led_fake.h>

@fake_of{led_driver_api::on}

◆ DECLARE_FAKE_VALUE_FUNC() [5/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_set_brightness ,
const struct device * ,
uint32_t ,
uint8_t  )

◆ DECLARE_FAKE_VALUE_FUNC() [6/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_set_color ,
const struct device * ,
uint32_t ,
uint8_t ,
const uint8_t *  )

#include <led_fake.h>

@fake_of{led_driver_api::set_color}

◆ DECLARE_FAKE_VALUE_FUNC() [7/7]

DECLARE_FAKE_VALUE_FUNC ( int ,
fake_led_write_channels ,
const struct device * ,
uint32_t ,
uint32_t ,
const uint8_t *  )