LCOV - code coverage report
Current view: top level - zephyr/drivers/can - transceiver.h Hit Total Coverage
Test: new.info Lines: 2 3 66.7 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       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
      14             : extern "C" {
      15             : #endif
      16             : 
      17             : /**
      18             :  * @brief CAN Transceiver Driver APIs
      19             :  * @defgroup can_transceiver CAN Transceiver
      20             :  * @since 3.1
      21             :  * @version 0.1.0
      22             :  * @ingroup io_interfaces
      23             :  * @{
      24             :  */
      25             : 
      26             : /**
      27             :  * @cond INTERNAL_HIDDEN
      28             :  *
      29             :  * For internal driver use only, skip these in public documentation.
      30             :  */
      31             : 
      32             : /**
      33             :  * @brief Callback API upon enabling CAN transceiver
      34             :  * See @a can_transceiver_enable() for argument description
      35             :  */
      36             : typedef int (*can_transceiver_enable_t)(const struct device *dev, can_mode_t mode);
      37             : 
      38             : /**
      39             :  * @brief Callback API upon disabling CAN transceiver
      40             :  * See @a can_transceiver_disable() for argument description
      41             :  */
      42             : typedef 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             : 
      49             : /** @endcond */
      50             : 
      51             : /**
      52             :  * @brief Enable CAN transceiver
      53             :  *
      54             :  * Enable the CAN transceiver.
      55             :  *
      56             :  * @note The CAN transceiver is controlled by the CAN controller driver and
      57             :  *       should not normally be controlled by the application.
      58             :  *
      59             :  * @see can_start()
      60             :  *
      61             :  * @param dev Pointer to the device structure for the driver instance.
      62             :  * @param mode Operation mode.
      63             :  * @retval 0 If successful.
      64             :  * @retval -EIO General input/output error, failed to enable device.
      65             :  */
      66           1 : static inline int can_transceiver_enable(const struct device *dev, can_mode_t mode)
      67             : {
      68             :         return DEVICE_API_GET(can_transceiver, dev)->enable(dev, mode);
      69             : }
      70             : 
      71             : /**
      72             :  * @brief Disable CAN transceiver
      73             :  *
      74             :  * Disable the CAN transceiver.
      75             : 
      76             :  * @note The CAN transceiver is controlled by the CAN controller driver and
      77             :  *       should not normally be controlled by the application.
      78             :  *
      79             :  * @see can_stop()
      80             :  *
      81             :  * @param dev Pointer to the device structure for the driver instance.
      82             :  * @retval 0 If successful.
      83             :  * @retval -EIO General input/output error, failed to disable device.
      84             :  */
      85           1 : static inline int can_transceiver_disable(const struct device *dev)
      86             : {
      87             :         return DEVICE_API_GET(can_transceiver, dev)->disable(dev);
      88             : }
      89             : 
      90             : /**
      91             :  * @}
      92             :  */
      93             : 
      94             : #ifdef __cplusplus
      95             : }
      96             : #endif
      97             : 
      98             : #endif /* ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_ */

Generated by: LCOV version 1.14