nrfx 4.5.0
Loading...
Searching...
No Matches
LPCOMP driver

Low Power Comparator (LPCOMP) peripheral driver. More...

Topics

 LPCOMP peripheral driver configuration
 

Data Structures

struct  nrfx_lpcomp_config_t
 LPCOMP configuration. More...
 

Macros

#define NRFX_LPCOMP_DEFAULT_CONFIG(_input)
 LPCOMP driver default configuration.
 

Typedefs

typedef void(* nrfx_lpcomp_event_handler_t) (nrf_lpcomp_event_t event)
 LPCOMP event handler function type.
 

Functions

int nrfx_lpcomp_init (nrfx_lpcomp_config_t const *p_config, nrfx_lpcomp_event_handler_t event_handler)
 Function for initializing the LPCOMP driver.
 
int nrfx_lpcomp_reconfigure (nrfx_lpcomp_config_t const *p_config)
 Function for reconfiguring the LPCOMP driver.
 
void nrfx_lpcomp_uninit (void)
 Function for uninitializing the LPCOMP driver.
 
bool nrfx_lpcomp_init_check (void)
 Function for checking if the LPCOMP driver is initialized.
 
void nrfx_lpcomp_start (uint32_t lpcomp_evt_en_mask, uint32_t lpcomp_shorts_mask)
 Function for starting the LPCOMP peripheral and interrupts.
 
void nrfx_lpcomp_stop (void)
 Function for stopping the LPCOMP peripheral.
 
uint32_t nrfx_lpcomp_sample (void)
 Function for copying the current state of the low power comparator result to the RESULT register.
 

Detailed Description

Low Power Comparator (LPCOMP) peripheral driver.

Macro Definition Documentation

◆ NRFX_LPCOMP_DEFAULT_CONFIG

#define NRFX_LPCOMP_DEFAULT_CONFIG ( _input)
Value:
{ \
.reference = NRF_LPCOMP_REF_SUPPLY_4_8, \
.detection = NRF_LPCOMP_DETECT_CROSS, \
NRFX_COND_CODE_1(LPCOMP_FEATURE_HYST_PRESENT, (.hyst = NRF_LPCOMP_HYST_NOHYST,), ()) \
.input = (nrfx_analog_input_t)_input, \
.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]_inputComparator input pin.

Typedef Documentation

◆ nrfx_lpcomp_event_handler_t

typedef void(* nrfx_lpcomp_event_handler_t) (nrf_lpcomp_event_t event)

LPCOMP event handler function type.

Parameters
[in]eventLPCOMP event.

Function Documentation

◆ nrfx_lpcomp_init()

int nrfx_lpcomp_init ( nrfx_lpcomp_config_t const * p_config,
nrfx_lpcomp_event_handler_t event_handler )

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_configPointer to the structure with the initial configuration.
[in]event_handlerEvent handler provided by the user. Must not be NULL.
Return values
0Initialization was successful.
-EALREADYThe driver is already initialized.
-EBUSYThe COMP peripheral is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled.
-EINVALThe 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
trueDriver is already initialized.
falseDriver is not initialized.

◆ nrfx_lpcomp_reconfigure()

int nrfx_lpcomp_reconfigure ( nrfx_lpcomp_config_t const * p_config)

Function for reconfiguring the LPCOMP driver.

Parameters
[in]p_configPointer to the structure with the configuration.
Return values
0Reconfiguration was successful.
-EBUSYThe driver is running and cannot be reconfigured.
-EINPROGRESSThe driver is uninitialized.
-EINVALThe 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
0The input voltage is below the threshold (VIN+ < VIN-).
1The 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_maskMask 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_maskMask 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