Zephyr API 3.6.99
Loading...
Searching...
No Matches
transceiver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Vestas Wind Systems A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_
8#define ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_
9
10#include <zephyr/drivers/can.h>
11#include <zephyr/device.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
36typedef int (*can_transceiver_enable_t)(const struct device *dev, can_mode_t mode);
37
42typedef int (*can_transceiver_disable_t)(const struct device *dev);
43
44__subsystem struct can_transceiver_driver_api {
45 can_transceiver_enable_t enable;
46 can_transceiver_disable_t disable;
47};
48
66static inline int can_transceiver_enable(const struct device *dev, can_mode_t mode)
67{
68 const struct can_transceiver_driver_api *api =
69 (const struct can_transceiver_driver_api *)dev->api;
70
71 return api->enable(dev, mode);
72}
73
88static inline int can_transceiver_disable(const struct device *dev)
89{
90 const struct can_transceiver_driver_api *api =
91 (const struct can_transceiver_driver_api *)dev->api;
92
93 return api->disable(dev);
94}
95
100#ifdef __cplusplus
101}
102#endif
103
104#endif /* ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_ */
Controller Area Network (CAN) driver API.
uint32_t can_mode_t
Provides a type to hold CAN controller configuration flags.
Definition can.h:125
static int can_transceiver_enable(const struct device *dev, can_mode_t mode)
Enable CAN transceiver.
Definition transceiver.h:66
static int can_transceiver_disable(const struct device *dev)
Disable CAN transceiver.
Definition transceiver.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409