LCOV - code coverage report
Current view: top level - zephyr/drivers/usb - emul_bc12.h Coverage Total Hit
Test: new.info Lines: 100.0 % 3 3
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2022 Google LLC
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @brief Backend APIs for the BC1.2 emulators.
      10              :  */
      11              : 
      12              : #ifndef ZEPHYR_INCLUDE_DRIVERS_USB_EMUL_BC12_H_
      13              : #define ZEPHYR_INCLUDE_DRIVERS_USB_EMUL_BC12_H_
      14              : 
      15              : #include <zephyr/drivers/emul.h>
      16              : #include <zephyr/drivers/usb/usb_bc12.h>
      17              : 
      18              : #ifdef __cplusplus
      19              : extern "C" {
      20              : #endif
      21              : 
      22              : /**
      23              :  * @brief BC1.2 backend emulator APIs
      24              :  * @defgroup b12_emulator_backend BC1.2 backed emulator APIs
      25              :  * @ingroup b12_interface
      26              :  * @ingroup io_emulators
      27              :  * @{
      28              :  */
      29              : 
      30              : /**
      31              :  * @cond INTERNAL_HIDDEN
      32              :  *
      33              :  * These are for internal use only, so skip these in public documentation.
      34              :  */
      35              : __subsystem struct bc12_emul_driver_api {
      36              :         int (*set_charging_partner)(const struct emul *emul, enum bc12_type partner_type);
      37              :         int (*set_pd_partner)(const struct emul *emul, bool connected);
      38              : };
      39              : /**
      40              :  * @endcond
      41              :  */
      42              : 
      43              : /**
      44              :  * @brief Set the charging partner type connected to the BC1.2 device.
      45              :  *
      46              :  * The corresponding BC1.2 emulator updates the vendor specific registers
      47              :  * to simulate connection of the specified charging partner type.  The emulator
      48              :  * also generates an interrupt for processing by the real driver, if supported.
      49              :  *
      50              :  * @param target Pointer to the emulator structure for the BC1.2 emulator instance.
      51              :  * @param partner_type The simulated partner type.  Set to BC12_TYPE_NONE to
      52              :  * disconnect the charging partner.
      53              :  *
      54              :  * @retval 0 If successful.
      55              :  * @retval -EINVAL if the partner type is not supported.
      56              :  */
      57            1 : static inline int bc12_emul_set_charging_partner(const struct emul *target,
      58              :                                                  enum bc12_type partner_type)
      59              : {
      60              :         const struct bc12_emul_driver_api *backend_api =
      61              :                 (const struct bc12_emul_driver_api *)target->backend_api;
      62              : 
      63              :         return backend_api->set_charging_partner(target, partner_type);
      64              : }
      65              : 
      66              : /**
      67              :  * @brief Set the portable device partner state.
      68              :  *
      69              :  * The corresponding BC1.2 emulator updates the vendor specific registers
      70              :  * to simulate connection or disconnection of a portable device partner.
      71              :  * The emulator also generates an interrupt for processing by the real driver,
      72              :  * if supported.
      73              :  *
      74              :  * @param target Pointer to the emulator structure for the BC1.2 emulator instance.
      75              :  * @param connected If true, emulate a connection of a portable device partner. If
      76              :  * false, emulate a disconnect event.
      77              :  *
      78              :  * @retval 0 If successful.
      79              :  * @retval -EINVAL if the connection/disconnection of PD partner is not supported.
      80              :  */
      81            1 : static inline int bc12_emul_set_pd_partner(const struct emul *target, bool connected)
      82              : {
      83              :         const struct bc12_emul_driver_api *backend_api =
      84              :                 (const struct bc12_emul_driver_api *)target->backend_api;
      85              : 
      86              :         return backend_api->set_pd_partner(target, connected);
      87              : }
      88              : 
      89              : #ifdef __cplusplus
      90              : }
      91              : #endif
      92              : 
      93              : /**
      94              :  * @}
      95              :  */
      96              : 
      97              : #endif /* ZEPHYR_INCLUDE_DRIVERS_USB_EMUL_BC12_H_ */
        

Generated by: LCOV version 2.0-1