nrf_drv_lpcomp.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #ifndef NRF_DRV_LPCOMP_H__
  13. #define NRF_DRV_LPCOMP_H__
  14. #include "nrf_lpcomp.h"
  15. #include "sdk_errors.h"
  16. #include "nrf_drv_common.h"
  17. #include "nrf_drv_config.h"
  18. /**
  19. * @addtogroup nrf_lpcomp LPCOMP HAL and driver
  20. * @ingroup nrf_drivers
  21. * @brief Low Power Comparator (LPCOMP) APIs.
  22. * @details The LPCOMP HAL provides basic APIs for accessing the registers of Low Power Comparator.
  23. * The LPCOMP driver provides APIs on a higher level.
  24. *
  25. * @defgroup nrf_drivers_lpcomp LPCOMP driver
  26. * @{
  27. * @ingroup nrf_lpcomp
  28. * @brief Low Power Comparator (LPCOMP) driver.
  29. */
  30. /**@brief LPCOMP event handler function type.
  31. * @param[in] event LPCOMP event.
  32. */
  33. typedef void (* lpcomp_events_handler_t)(nrf_lpcomp_event_t event);
  34. /**@brief LPCOMP configuration.
  35. */
  36. typedef struct
  37. {
  38. nrf_lpcomp_config_t hal; /**< LPCOMP HAL configuration. */
  39. nrf_lpcomp_input_t input; /**< Input to be monitored. */
  40. uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */
  41. } nrf_drv_lpcomp_config_t;
  42. /** @brief LPCOMP driver default configuration including the LPCOMP HAL configuration. */
  43. #define NRF_DRV_LPCONF_DEFAULT_CONFIG \
  44. { \
  45. .hal = {LPCOMP_CONFIG_REFERENCE , LPCOMP_CONFIG_DETECTION}, \
  46. .input = LPCOMP_CONFIG_INPUT, \
  47. .interrupt_priority = LPCOMP_CONFIG_IRQ_PRIORITY \
  48. }
  49. /**
  50. * @brief Function for initializing the LPCOMP driver.
  51. *
  52. * This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts.
  53. * To start the driver, call the function nrf_drv_lpcomp_enable() after initialization.
  54. *
  55. * If no configuration structure is provided, the driver is initialized with the default settings.
  56. *
  57. * @param[in] p_config Initial configuration. If NULL, the default configuration is used.
  58. * @param[in] events_handler Handler function.
  59. * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid.
  60. * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized.
  61. */
  62. ret_code_t nrf_drv_lpcomp_init(const nrf_drv_lpcomp_config_t * p_config,
  63. lpcomp_events_handler_t events_handler);
  64. /**
  65. * @brief Function for uninitializing the LCOMP driver.
  66. *
  67. * This function uninitializes the LPCOMP driver. The LPCOMP peripheral and
  68. * its interrupts are disabled, and local variables are cleaned. After this call, you must
  69. * initialize the driver again by calling nrf_drv_lpcomp_init() if you want to use it.
  70. *
  71. * @sa nrf_drv_lpcomp_disable()
  72. * @sa nrf_drv_lpcomp_init()
  73. */
  74. void nrf_drv_lpcomp_uninit(void);
  75. /**@brief Function for enabling the LPCOMP peripheral and interrupts.
  76. *
  77. * Before calling this function, the driver must be initialized. This function
  78. * enables the LPCOMP peripheral and its interrupts.
  79. *
  80. * @sa nrf_drv_lpcomp_disable()
  81. */
  82. void nrf_drv_lpcomp_enable(void);
  83. /**@brief Function for disabling the LPCOMP peripheral.
  84. *
  85. * Before calling this function, the driver must be initialized. This function disables the LPCOMP
  86. * peripheral and its interrupts.
  87. *
  88. * @sa nrf_drv_lpcomp_enable()
  89. */
  90. void nrf_drv_lpcomp_disable(void);
  91. /**
  92. *@}
  93. **/
  94. #endif /* NRF_DRV_LPCOMP_H__ */