LCOV - code coverage report
Current view: top level - zephyr/drivers/can - transceiver.h Coverage Total Hit
Test: new.info Lines: 100.0 % 3 3
Test Date: 2025-09-05 20:47:19

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2022 Vestas Wind Systems A/S
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @ingroup can_transceiver
      10              :  * @brief Header file for CAN transceiver driver API
      11              :  */
      12              : 
      13              : #ifndef ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_
      14              : #define ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_
      15              : 
      16              : #include <zephyr/drivers/can.h>
      17              : #include <zephyr/device.h>
      18              : 
      19              : #ifdef __cplusplus
      20              : extern "C" {
      21              : #endif
      22              : 
      23              : /**
      24              :  * @brief Interfaces for CAN transceivers
      25              :  * @defgroup can_transceiver CAN Transceiver
      26              :  * @since 3.1
      27              :  * @version 0.1.0
      28              :  * @ingroup can_interface
      29              :  * @{
      30              :  */
      31              : 
      32              : /**
      33              :  * @cond INTERNAL_HIDDEN
      34              :  *
      35              :  * For internal driver use only, skip these in public documentation.
      36              :  */
      37              : 
      38              : /**
      39              :  * @brief Callback API upon enabling CAN transceiver
      40              :  * See @a can_transceiver_enable() for argument description
      41              :  */
      42              : typedef int (*can_transceiver_enable_t)(const struct device *dev, can_mode_t mode);
      43              : 
      44              : /**
      45              :  * @brief Callback API upon disabling CAN transceiver
      46              :  * See @a can_transceiver_disable() for argument description
      47              :  */
      48              : typedef int (*can_transceiver_disable_t)(const struct device *dev);
      49              : 
      50              : __subsystem struct can_transceiver_driver_api {
      51              :         can_transceiver_enable_t enable;
      52              :         can_transceiver_disable_t disable;
      53              : };
      54              : 
      55              : /** @endcond */
      56              : 
      57              : /**
      58              :  * @brief Enable CAN transceiver
      59              :  *
      60              :  * Enable the CAN transceiver.
      61              :  *
      62              :  * @note The CAN transceiver is controlled by the CAN controller driver and
      63              :  *       should not normally be controlled by the application.
      64              :  *
      65              :  * @see can_start()
      66              :  *
      67              :  * @param dev Pointer to the device structure for the driver instance.
      68              :  * @param mode Operation mode.
      69              :  * @retval 0 If successful.
      70              :  * @retval -EIO General input/output error, failed to enable device.
      71              :  */
      72            1 : static inline int can_transceiver_enable(const struct device *dev, can_mode_t mode)
      73              : {
      74              :         return DEVICE_API_GET(can_transceiver, dev)->enable(dev, mode);
      75              : }
      76              : 
      77              : /**
      78              :  * @brief Disable CAN transceiver
      79              :  *
      80              :  * Disable the CAN transceiver.
      81              : 
      82              :  * @note The CAN transceiver is controlled by the CAN controller driver and
      83              :  *       should not normally be controlled by the application.
      84              :  *
      85              :  * @see can_stop()
      86              :  *
      87              :  * @param dev Pointer to the device structure for the driver instance.
      88              :  * @retval 0 If successful.
      89              :  * @retval -EIO General input/output error, failed to disable device.
      90              :  */
      91            1 : static inline int can_transceiver_disable(const struct device *dev)
      92              : {
      93              :         return DEVICE_API_GET(can_transceiver, dev)->disable(dev);
      94              : }
      95              : 
      96              : /**
      97              :  * @}
      98              :  */
      99              : 
     100              : #ifdef __cplusplus
     101              : }
     102              : #endif
     103              : 
     104              : #endif /* ZEPHYR_INCLUDE_DRIVERS_CAN_TRANSCEIVER_H_ */
        

Generated by: LCOV version 2.0-1