LCOV - code coverage report
Current view: top level - zephyr/drivers/mfd - npm13xx.h Coverage Total Hit
Test: new.info Lines: 83.3 % 12 10
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2023 Nordic Semiconductor ASA
       3              :  * SPDX-License-Identifier: Apache-2.0
       4              :  */
       5              : 
       6              : #ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_
       7              : #define ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_
       8              : 
       9              : #ifdef __cplusplus
      10              : extern "C" {
      11              : #endif
      12              : 
      13              : /**
      14              :  * @defgroup mfd_interface_npm13xx MFD NPM13XX Interface
      15              :  * @ingroup mfd_interfaces
      16              :  * @{
      17              :  */
      18              : 
      19              : #include <stddef.h>
      20              : #include <stdint.h>
      21              : 
      22              : #include <zephyr/device.h>
      23              : #include <zephyr/drivers/gpio.h>
      24              : 
      25            0 : enum mfd_npm13xx_event_t {
      26              :         NPM13XX_EVENT_CHG_COMPLETED,
      27              :         NPM13XX_EVENT_CHG_ERROR,
      28              :         NPM13XX_EVENT_BATTERY_DETECTED,
      29              :         NPM13XX_EVENT_BATTERY_REMOVED,
      30              :         NPM13XX_EVENT_SHIPHOLD_PRESS,
      31              :         NPM13XX_EVENT_SHIPHOLD_RELEASE,
      32              :         NPM13XX_EVENT_WATCHDOG_WARN,
      33              :         NPM13XX_EVENT_VBUS_DETECTED,
      34              :         NPM13XX_EVENT_VBUS_REMOVED,
      35              :         NPM13XX_EVENT_GPIO0_EDGE,
      36              :         NPM13XX_EVENT_GPIO1_EDGE,
      37              :         NPM13XX_EVENT_GPIO2_EDGE,
      38              :         NPM13XX_EVENT_GPIO3_EDGE,
      39              :         NPM13XX_EVENT_GPIO4_EDGE,
      40              :         NPM13XX_EVENT_MAX
      41              : };
      42              : 
      43              : /**
      44              :  * @brief Read multiple registers from npm13xx
      45              :  *
      46              :  * @param dev npm13xx mfd device
      47              :  * @param base Register base address (bits 15..8 of 16-bit address)
      48              :  * @param offset Register offset address (bits 7..0 of 16-bit address)
      49              :  * @param data Pointer to buffer for received data
      50              :  * @param len Number of bytes to read
      51              :  * @retval 0 If successful
      52              :  * @retval -errno In case of any bus error (see i2c_write_read_dt())
      53              :  */
      54            1 : int mfd_npm13xx_reg_read_burst(const struct device *dev, uint8_t base, uint8_t offset, void *data,
      55              :                                size_t len);
      56              : 
      57              : /**
      58              :  * @brief Read single register from npm13xx
      59              :  *
      60              :  * @param dev npm13xx mfd device
      61              :  * @param base Register base address (bits 15..8 of 16-bit address)
      62              :  * @param offset Register offset address (bits 7..0 of 16-bit address)
      63              :  * @param data Pointer to buffer for received data
      64              :  * @retval 0 If successful
      65              :  * @retval -errno In case of any bus error (see i2c_write_read_dt())
      66              :  */
      67            1 : int mfd_npm13xx_reg_read(const struct device *dev, uint8_t base, uint8_t offset, uint8_t *data);
      68              : 
      69              : /**
      70              :  * @brief Write single register to npm13xx
      71              :  *
      72              :  * @param dev npm13xx mfd device
      73              :  * @param base Register base address (bits 15..8 of 16-bit address)
      74              :  * @param offset Register offset address (bits 7..0 of 16-bit address)
      75              :  * @param data data to write
      76              :  * @retval 0 If successful
      77              :  * @retval -errno In case of any bus error (see i2c_write_dt())
      78              :  */
      79            1 : int mfd_npm13xx_reg_write(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data);
      80              : 
      81              : /**
      82              :  * @brief Write two registers to npm13xx
      83              :  *
      84              :  * @param dev npm13xx mfd device
      85              :  * @param base Register base address (bits 15..8 of 16-bit address)
      86              :  * @param offset Register offset address (bits 7..0 of 16-bit address)
      87              :  * @param data1 first byte of data to write
      88              :  * @param data2 second byte of data to write
      89              :  * @retval 0 If successful
      90              :  * @retval -errno In case of any bus error (see i2c_write_dt())
      91              :  */
      92            1 : int mfd_npm13xx_reg_write2(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data1,
      93              :                            uint8_t data2);
      94              : 
      95              : /**
      96              :  * @brief Update selected bits in npm13xx register
      97              :  *
      98              :  * @param dev npm13xx mfd device
      99              :  * @param base Register base address (bits 15..8 of 16-bit address)
     100              :  * @param offset Register offset address (bits 7..0 of 16-bit address)
     101              :  * @param data data to write
     102              :  * @param mask mask of bits to be modified
     103              :  * @retval 0 If successful
     104              :  * @retval -errno In case of any bus error (see i2c_write_read_dt(), i2c_write_dt())
     105              :  */
     106            1 : int mfd_npm13xx_reg_update(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data,
     107              :                            uint8_t mask);
     108              : 
     109              : /**
     110              :  * @brief Write npm13xx timer register
     111              :  *
     112              :  * @param dev npm13xx mfd device
     113              :  * @param time_ms timer value in ms
     114              :  * @retval 0 If successful
     115              :  * @retval -EINVAL if time value is too large
     116              :  * @retval -errno In case of any bus error (see i2c_write_dt())
     117              :  */
     118            1 : int mfd_npm13xx_set_timer(const struct device *dev, uint32_t time_ms);
     119              : 
     120              : /**
     121              :  * @brief npm13xx full power reset
     122              :  *
     123              :  * @param dev npm13xx mfd device
     124              :  * @retval 0 If successful
     125              :  * @retval -errno In case of any bus error (see i2c_write_dt())
     126              :  */
     127            1 : int mfd_npm13xx_reset(const struct device *dev);
     128              : 
     129              : /**
     130              :  * @brief npm13xx hibernate
     131              :  *
     132              :  * Enters low power state, and wakes after specified time
     133              :  *
     134              :  * @param dev npm13xx mfd device
     135              :  * @param time_ms timer value in ms
     136              :  * @retval 0 If successful
     137              :  * @retval -EINVAL if time value is too large
     138              :  * @retval -errno In case of any bus error (see i2c_write_dt())
     139              :  */
     140            1 : int mfd_npm13xx_hibernate(const struct device *dev, uint32_t time_ms);
     141              : 
     142              : /**
     143              :  * @brief Add npm13xx event callback
     144              :  *
     145              :  * @param dev npm13xx mfd device
     146              :  * @param callback callback
     147              :  * @return 0 on success, -errno on failure
     148              :  */
     149            1 : int mfd_npm13xx_add_callback(const struct device *dev, struct gpio_callback *callback);
     150              : 
     151              : /**
     152              :  * @brief Remove npm13xx event callback
     153              :  *
     154              :  * @param dev npm13xx mfd device
     155              :  * @param callback callback
     156              :  * @return 0 on success, -errno on failure
     157              :  */
     158            1 : int mfd_npm13xx_remove_callback(const struct device *dev, struct gpio_callback *callback);
     159              : 
     160              : /** @} */
     161              : 
     162              : #ifdef __cplusplus
     163              : }
     164              : #endif
     165              : 
     166              : #endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_ */
        

Generated by: LCOV version 2.0-1