LCOV - code coverage report
Current view: top level - zephyr/drivers - uart_emul.h Coverage Total Hit
Test: new.info Lines: 77.8 % 9 7
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright 2024 Basalte bv
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : #ifndef ZEPHYR_INCLUDE_DRIVERS_UART_EMUL_H_
       8              : #define ZEPHYR_INCLUDE_DRIVERS_UART_EMUL_H_
       9              : 
      10              : #include <zephyr/device.h>
      11              : #include <zephyr/drivers/emul.h>
      12              : #include <zephyr/drivers/uart.h>
      13              : #include <zephyr/sys/slist.h>
      14              : #include <zephyr/types.h>
      15              : 
      16              : /**
      17              :  * @file
      18              :  *
      19              :  * @brief Public APIs for the UART device emulation drivers.
      20              :  */
      21              : 
      22              : /**
      23              :  * @brief UART Emulation Interface
      24              :  * @defgroup uart_emul_interface UART Emulation Interface
      25              :  * @ingroup io_emulators
      26              :  * @ingroup uart_interface
      27              :  * @{
      28              :  */
      29              : 
      30              : #ifdef __cplusplus
      31              : extern "C" {
      32              : #endif
      33              : 
      34              : struct uart_emul_device_api;
      35              : 
      36              : /**
      37              :  * @brief Define the emulation callback function signature
      38              :  *
      39              :  * @param dev UART device instance
      40              :  * @param size Number of available bytes in TX buffer
      41              :  * @param target pointer to emulation context
      42              :  */
      43            1 : typedef void (*uart_emul_device_tx_data_ready_t)(const struct device *dev, size_t size,
      44              :                                                  const struct emul *target);
      45              : 
      46              : /** Node in a linked list of emulators for UART devices */
      47            1 : struct uart_emul {
      48            0 :         sys_snode_t node;
      49              :         /** Target emulator - REQUIRED for all emulated bus nodes of any type */
      50            1 :         const struct emul *target;
      51              :         /** API provided for this device */
      52            1 :         const struct uart_emul_device_api *api;
      53              : };
      54              : 
      55              : /** Definition of the emulator API */
      56            1 : struct uart_emul_device_api {
      57            0 :         uart_emul_device_tx_data_ready_t tx_data_ready;
      58              : };
      59              : 
      60              : /**
      61              :  * Register an emulated device on the controller
      62              :  *
      63              :  * @param dev Device that will use the emulator
      64              :  * @param emul UART emulator to use
      65              :  * @return 0 indicating success
      66              :  */
      67            1 : int uart_emul_register(const struct device *dev, struct uart_emul *emul);
      68              : 
      69              : #ifdef __cplusplus
      70              : }
      71              : #endif
      72              : 
      73              : /**
      74              :  * @}
      75              :  */
      76              : 
      77              : #endif /* ZEPHYR_INCLUDE_DRIVERS_UART_EMUL_H_ */
        

Generated by: LCOV version 2.0-1