Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
abstract_driver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef _ABSTRACT_DRIVER_H_
8#define _ABSTRACT_DRIVER_H_
9
10#include <zephyr/ztest.h>
11#include <zephyr/device.h>
12#include <zephyr/sys/check.h>
13
14/* define subsystem common API for drivers */
15typedef int (*abstract_do_this_t)(const struct device *dev, int foo, int bar);
16typedef void (*abstract_do_that_t)(const struct device *dev, unsigned int *baz);
17
22
23__syscall int abstract_do_this(const struct device *dev, int foo, int bar);
24
25static inline int z_impl_abstract_do_this(const struct device *dev, int foo, int bar)
26{
27 __ASSERT_NO_MSG(DEVICE_API_IS(abstract, dev));
28
29 return DEVICE_API_GET(abstract, dev)->do_this(dev, foo, bar);
30}
31
32__syscall void abstract_do_that(const struct device *dev, unsigned int *baz);
33
34static inline void z_impl_abstract_do_that(const struct device *dev, unsigned int *baz)
35{
36 __ASSERT_NO_MSG(DEVICE_API_IS(abstract, dev));
37
38 DEVICE_API_GET(abstract, dev)->do_that(dev, baz);
39}
40
41#include <syscalls/abstract_driver.h>
42
43#endif /* _ABSTRACT_DRIVER_H_ */
int abstract_do_this(const struct device *dev, int foo, int bar)
void abstract_do_that(const struct device *dev, unsigned int *baz)
void(* abstract_do_that_t)(const struct device *dev, unsigned int *baz)
Definition abstract_driver.h:16
int(* abstract_do_this_t)(const struct device *dev, int foo, int bar)
Definition abstract_driver.h:15
#define DEVICE_API_IS(_class, _dev)
Macro that evaluates to a boolean that can be used to check if a device is of a particular class.
Definition device.h:1340
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1328
Definition abstract_driver.h:18
abstract_do_this_t do_this
Definition abstract_driver.h:19
abstract_do_that_t do_that
Definition abstract_driver.h:20
Runtime device structure (in ROM) per driver instance.
Definition device.h:504
Definition main.c:25
Zephyr Testsuite.