Low Power Comparator (LPCOMP) peripheral driver.
More...
Low Power Comparator (LPCOMP) peripheral driver.
◆ NRFX_LPCOMP_DEFAULT_CONFIG
| #define NRFX_LPCOMP_DEFAULT_CONFIG |
( |
| _input | ) |
|
Value:{ \
.interrupt_priority = NRFX_LPCOMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
@ NRF_LPCOMP_REF_SUPPLY_4_8
Use supply with a 4/8 prescaler as reference.
Definition nrf_lpcomp.h:107
@ NRF_LPCOMP_DETECT_CROSS
Generate ANADETEC on crossing, both upwards and downwards crossing.
Definition nrf_lpcomp.h:162
@ NRF_LPCOMP_HYST_NOHYST
Comparator hysteresis disabled.
Definition nrf_lpcomp.h:174
nrfx_analog_input_t
Generic analog input types.
Definition nrfx_analog_common.h:64
LPCOMP driver default configuration.
This configuration sets up LPCOMP with the following options:
- reference voltage: 4/8 of supply voltage
- detection of both up and down crossings
- hysteresis disabled
- Parameters
-
| [in] | _input | Comparator input pin. |
◆ nrfx_lpcomp_event_handler_t
LPCOMP event handler function type.
- Parameters
-
◆ nrfx_lpcomp_init()
Function for initializing the LPCOMP driver.
This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts. To start the driver, call the function nrfx_lpcomp_enable() after initialization.
- Parameters
-
| [in] | p_config | Pointer to the structure with the initial configuration. |
| [in] | event_handler | Event handler provided by the user. Must not be NULL. |
- Return values
-
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -EBUSY | The COMP peripheral is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled. |
| -EINVAL | The analog input pin or external reference is invalid. |
◆ nrfx_lpcomp_init_check()
| bool nrfx_lpcomp_init_check |
( |
void | | ) |
|
Function for checking if the LPCOMP driver is initialized.
- Return values
-
| true | Driver is already initialized. |
| false | Driver is not initialized. |
◆ nrfx_lpcomp_reconfigure()
Function for reconfiguring the LPCOMP driver.
- Parameters
-
| [in] | p_config | Pointer to the structure with the configuration. |
- Return values
-
| 0 | Reconfiguration was successful. |
| -EBUSY | The driver is running and cannot be reconfigured. |
| -EINPROGRESS | The driver is uninitialized. |
| -EINVAL | The analog input pin or external reference is invalid. |
◆ nrfx_lpcomp_sample()
| uint32_t nrfx_lpcomp_sample |
( |
void | | ) |
|
Function for copying the current state of the low power comparator result to the RESULT register.
- Return values
-
| 0 | The input voltage is below the threshold (VIN+ < VIN-). |
| 1 | The input voltage is above the threshold (VIN+ > VIN-). |
◆ nrfx_lpcomp_start()
| void nrfx_lpcomp_start |
( |
uint32_t | lpcomp_evt_en_mask, |
|
|
uint32_t | lpcomp_shorts_mask ) |
Function for starting the LPCOMP peripheral and interrupts.
Before calling this function, the driver must be initialized. This function enables the LPCOMP peripheral and its interrupts.
- Parameters
-
| [in] | lpcomp_evt_en_mask | Mask of events to be enabled. This parameter is to be built as an OR of elements from nrf_lpcomp_int_mask_t. |
| [in] | lpcomp_shorts_mask | Mask of shortcuts to be enabled. This parameter is to be built as an OR of elements from nrf_lpcomp_short_mask_t. |
- See also
- nrfx_lpcomp_init
◆ nrfx_lpcomp_stop()
| void nrfx_lpcomp_stop |
( |
void | | ) |
|
Function for stopping the LPCOMP peripheral.
Before calling this function, the driver must be enabled. This function disables the LPCOMP peripheral and its interrupts.
- See also
- nrfx_lpcomp_uninit
◆ nrfx_lpcomp_uninit()
| void nrfx_lpcomp_uninit |
( |
void | | ) |
|
Function for uninitializing the LPCOMP driver.
This function uninitializes the LPCOMP driver. The LPCOMP peripheral and its interrupts are disabled, and local variables are cleaned. After this call, you must initialize the driver again by calling nrfx_lpcomp_init() if you want to use it.
- See also
- nrfx_lpcomp_disable
-
nrfx_lpcomp_init