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

Fake CAN controller driver. More...

Files

file  can_fake.h
 Fake CAN controller driver API functions.

Functions

int fake_can_start (const struct device *)
 Fake implementation of the can_driver_api::start driver operation.
int fake_can_stop (const struct device *)
 Fake implementation of the can_driver_api::stop driver operation.
int fake_can_set_timing (const struct device *, const struct can_timing *)
 Fake implementation of the can_driver_api::set_timing driver operation.
int fake_can_set_timing_data (const struct device *, const struct can_timing *)
 Fake implementation of the can_driver_api::set_timing_data driver operation.
int fake_can_get_capabilities (const struct device *, can_mode_t *)
 Fake implementation of the can_driver_api::get_capabilities driver operation.
int fake_can_set_mode (const struct device *, can_mode_t)
 Fake implementation of the can_driver_api::set_mode driver operation.
int fake_can_send (const struct device *, const struct can_frame *, k_timeout_t, can_tx_callback_t, void *)
 Fake implementation of the can_driver_api::send driver operation.
int fake_can_add_rx_filter (const struct device *, can_rx_callback_t, void *, const struct can_filter *)
 Fake implementation of the can_driver_api::add_rx_filter driver operation.
void fake_can_remove_rx_filter (const struct device *, int)
 Fake implementation of the can_driver_api::remove_rx_filter driver operation.
int fake_can_recover (const struct device *, k_timeout_t)
 Fake implementation of the can_driver_api::recover driver operation.
int fake_can_get_state (const struct device *, enum can_state *, struct can_bus_err_cnt *)
 Fake implementation of the can_driver_api::get_state driver operation.
int fake_can_state_change_callbacks_enabled (const struct device *, bool)
 Fake implementation of the can_driver_api::state_change_callbacks_enabled driver operation.
int fake_can_get_max_filters (const struct device *, bool)
 Fake implementation of the can_driver_api::get_max_filters driver operation.
int fake_can_get_core_clock (const struct device *, uint32_t *)
 Fake implementation of the can_driver_api::get_core_clock driver operation.

Detailed Description

Fake CAN controller driver.

This is a Fake Function Framework (FFF) implementation of the CAN API, provided for use in tests. It is enabled by CONFIG_CAN_FAKE and instantiated from zephyr,fake-can 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.

fake_can_get_capabilities(), fake_can_get_state() and fake_can_get_core_clock() are given a default custom_fake that fills in their output parameters with usable values, re-installed on every reset. Install your own custom_fake in the test case to change what they report.

Function Documentation

◆ fake_can_add_rx_filter()

int fake_can_add_rx_filter ( const struct device * ,
can_rx_callback_t ,
void * ,
const struct can_filter *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::add_rx_filter driver operation.

◆ fake_can_get_capabilities()

int fake_can_get_capabilities ( const struct device * ,
can_mode_t *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::get_capabilities driver operation.

◆ fake_can_get_core_clock()

int fake_can_get_core_clock ( const struct device * ,
uint32_t *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::get_core_clock driver operation.

◆ fake_can_get_max_filters()

int fake_can_get_max_filters ( const struct device * ,
bool  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::get_max_filters driver operation.

◆ fake_can_get_state()

int fake_can_get_state ( const struct device * ,
enum can_state * ,
struct can_bus_err_cnt *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::get_state driver operation.

◆ fake_can_recover()

int fake_can_recover ( const struct device * ,
k_timeout_t  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::recover driver operation.

◆ fake_can_remove_rx_filter()

void fake_can_remove_rx_filter ( const struct device * ,
int  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::remove_rx_filter driver operation.

◆ fake_can_send()

int fake_can_send ( const struct device * ,
const struct can_frame * ,
k_timeout_t ,
can_tx_callback_t ,
void *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::send driver operation.

◆ fake_can_set_mode()

int fake_can_set_mode ( const struct device * ,
can_mode_t  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::set_mode driver operation.

◆ fake_can_set_timing()

int fake_can_set_timing ( const struct device * ,
const struct can_timing *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::set_timing driver operation.

◆ fake_can_set_timing_data()

int fake_can_set_timing_data ( const struct device * ,
const struct can_timing *  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::set_timing_data driver operation.

◆ fake_can_start()

int fake_can_start ( const struct device * )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::start driver operation.

◆ fake_can_state_change_callbacks_enabled()

int fake_can_state_change_callbacks_enabled ( const struct device * ,
bool  )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::state_change_callbacks_enabled driver operation.

◆ fake_can_stop()

int fake_can_stop ( const struct device * )

#include <zephyr/drivers/can/can_fake.h>

Fake implementation of the can_driver_api::stop driver operation.