Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
34typedef int (*can_transceiver_enable_t)(const struct device *dev, can_mode_t mode);
35
40typedef int (*can_transceiver_disable_t)(const struct device *dev);
41
42__subsystem struct can_transceiver_driver_api {
43 can_transceiver_enable_t enable;
44 can_transceiver_disable_t disable;
45};
46
64static inline int can_transceiver_enable(const struct device *dev, can_mode_t mode)
65{
66 const struct can_transceiver_driver_api *api =
67 (const struct can_transceiver_driver_api *)dev->api;
68
69 return api->enable(dev, mode);
70}
71
86static inline int can_transceiver_disable(const struct device *dev)
87{
88 const struct can_transceiver_driver_api *api =
89 (const struct can_transceiver_driver_api *)dev->api;
90
91 return api->disable(dev);
92}
93
98#ifdef __cplusplus
99}
100#endif
101
102#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:116
static int can_transceiver_enable(const struct device *dev, can_mode_t mode)
Enable CAN transceiver.
Definition: transceiver.h:64
static int can_transceiver_disable(const struct device *dev)
Disable CAN transceiver.
Definition: transceiver.h:86
Runtime device structure (in ROM) per driver instance.
Definition: device.h:387
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:393