nrfx 3.3
Data Structures | Macros | Typedefs | Enumerations | Functions
LPCOMP HAL

Hardware access layer for managing the Low Power Comparator (LPCOMP) peripheral. More...

Data Structures

struct  nrf_lpcomp_config_t
 LPCOMP configuration. More...
 

Macros

#define NRF_LPCOMP_HAS_AIN_AS_PIN   1
 Symbol indicating whether the configuration of analog input using pin number is present.
 
#define NRF_LPCOMP_HAS_HYST   1
 Symbol indicating whether the hysteresis is present.
 

Typedefs

typedef uint32_t nrf_lpcomp_ext_ref_t
 LPCOMP external reference selection.
 
typedef uint32_t nrf_lpcomp_input_t
 LPCOMP input selection.
 

Enumerations

enum  nrf_lpcomp_task_t {
  NRF_LPCOMP_TASK_START = offsetof(NRF_LPCOMP_Type, TASKS_START) ,
  NRF_LPCOMP_TASK_STOP = offsetof(NRF_LPCOMP_Type, TASKS_STOP) ,
  NRF_LPCOMP_TASK_SAMPLE = offsetof(NRF_LPCOMP_Type, TASKS_SAMPLE)
}
 LPCOMP tasks. More...
 
enum  nrf_lpcomp_event_t {
  NRF_LPCOMP_EVENT_READY = offsetof(NRF_LPCOMP_Type, EVENTS_READY) ,
  NRF_LPCOMP_EVENT_DOWN = offsetof(NRF_LPCOMP_Type, EVENTS_DOWN) ,
  NRF_LPCOMP_EVENT_UP = offsetof(NRF_LPCOMP_Type, EVENTS_UP) ,
  NRF_LPCOMP_EVENT_CROSS = offsetof(NRF_LPCOMP_Type, EVENTS_CROSS)
}
 LPCOMP events. More...
 
enum  nrf_lpcomp_int_mask_t {
  NRF_LPCOMP_INT_READY_MASK = LPCOMP_INTENSET_READY_Msk ,
  NRF_LPCOMP_INT_DOWN_MASK = LPCOMP_INTENSET_DOWN_Msk ,
  NRF_LPCOMP_INT_UP_MASK = LPCOMP_INTENSET_UP_Msk ,
  NRF_LPCOMP_INT_CROSS_MASK = LPCOMP_INTENSET_CROSS_Msk
}
 LPCOMP interrupts. More...
 
enum  nrf_lpcomp_short_mask_t {
  NRF_LPCOMP_SHORT_CROSS_STOP_MASK = LPCOMP_SHORTS_CROSS_STOP_Msk ,
  NRF_LPCOMP_SHORT_UP_STOP_MASK = LPCOMP_SHORTS_UP_STOP_Msk ,
  NRF_LPCOMP_SHORT_DOWN_STOP_MASK = LPCOMP_SHORTS_DOWN_STOP_Msk ,
  NRF_LPCOMP_SHORT_READY_STOP_MASK = LPCOMP_SHORTS_READY_STOP_Msk ,
  NRF_LPCOMP_SHORT_READY_SAMPLE_MASK = LPCOMP_SHORTS_READY_SAMPLE_Msk
}
 LPCOMP shortcut masks. More...
 
enum  nrf_lpcomp_ref_t {
  NRF_LPCOMP_REF_SUPPLY_1_8 = LPCOMP_REFSEL_REFSEL_SupplyOneEighthPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_2_8 = LPCOMP_REFSEL_REFSEL_SupplyTwoEighthsPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_3_8 = LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_4_8 = LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_5_8 = LPCOMP_REFSEL_REFSEL_SupplyFiveEighthsPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_6_8 = LPCOMP_REFSEL_REFSEL_SupplySixEighthsPrescaling ,
  NRF_LPCOMP_REF_SUPPLY_7_8 = LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling ,
  NRF_LPCOMP_REF_EXT_REF = LPCOMP_REFSEL_REFSEL_ARef
}
 LPCOMP reference selection. More...
 
enum  nrf_lpcomp_detect_t {
  NRF_LPCOMP_DETECT_CROSS = LPCOMP_ANADETECT_ANADETECT_Cross ,
  NRF_LPCOMP_DETECT_UP = LPCOMP_ANADETECT_ANADETECT_Up ,
  NRF_LPCOMP_DETECT_DOWN = LPCOMP_ANADETECT_ANADETECT_Down
}
 LPCOMP detection type selection. More...
 
enum  nrf_lpcomp_hyst_t {
  NRF_LPCOMP_HYST_NOHYST = LPCOMP_HYST_HYST_Disabled ,
  NRF_LPCOMP_HYST_ENABLED = LPCOMP_HYST_HYST_Enabled
}
 LPCOMP hysteresis. More...
 

Functions

NRF_STATIC_INLINE void nrf_lpcomp_task_trigger (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_task_t task)
 Function for setting the specified LPCOMP task.
 
NRF_STATIC_INLINE uint32_t nrf_lpcomp_task_address_get (NRF_LPCOMP_Type const *p_reg, nrf_lpcomp_task_t task)
 Function for getting the address of the specified LPCOMP task register.
 
NRF_STATIC_INLINE bool nrf_lpcomp_event_check (NRF_LPCOMP_Type const *p_reg, nrf_lpcomp_event_t event)
 Function for retrieving the state of the LPCOMP event.
 
NRF_STATIC_INLINE void nrf_lpcomp_event_clear (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_event_t event)
 Function for clearing the specified LPCOMP event.
 
NRF_STATIC_INLINE uint32_t nrf_lpcomp_event_address_get (NRF_LPCOMP_Type const *p_reg, nrf_lpcomp_event_t event)
 Function for getting the address of the specified LPCOMP event register.
 
NRF_STATIC_INLINE void nrf_lpcomp_shorts_enable (NRF_LPCOMP_Type *p_reg, uint32_t mask)
 Function for setting LPCOMP shorts.
 
NRF_STATIC_INLINE void nrf_lpcomp_shorts_disable (NRF_LPCOMP_Type *p_reg, uint32_t mask)
 Function for clearing LPCOMP shorts by mask.
 
NRF_STATIC_INLINE void nrf_lpcomp_shorts_set (NRF_LPCOMP_Type *p_reg, uint32_t mask)
 Function for for setting the specified shortcuts.
 
NRF_STATIC_INLINE void nrf_lpcomp_int_enable (NRF_LPCOMP_Type *p_reg, uint32_t mask)
 Function for enabling interrupts from LPCOMP.
 
NRF_STATIC_INLINE void nrf_lpcomp_int_disable (NRF_LPCOMP_Type *p_reg, uint32_t mask)
 Function for disabling interrupts from LPCOMP.
 
NRF_STATIC_INLINE uint32_t nrf_lpcomp_int_enable_check (NRF_LPCOMP_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled.
 
NRF_STATIC_INLINE void nrf_lpcomp_subscribe_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_task_t task, uint8_t channel)
 Function for setting subscribe configuration for a given LPCOMP task.
 
NRF_STATIC_INLINE void nrf_lpcomp_subscribe_clear (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_task_t task)
 Function for clearing subscribe configuration for a given LPCOMP task.
 
NRF_STATIC_INLINE void nrf_lpcomp_publish_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_event_t event, uint8_t channel)
 Function for setting publish configuration for a given LPCOMP event.
 
NRF_STATIC_INLINE void nrf_lpcomp_publish_clear (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_event_t event)
 Function for clearing publish configuration for a given LPCOMP event.
 
NRF_STATIC_INLINE void nrf_lpcomp_configure (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_config_t const *p_config)
 Function for configuring LPCOMP.
 
NRF_STATIC_INLINE void nrf_lpcomp_ref_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_ref_t reference)
 Function for setting the reference source.
 
NRF_STATIC_INLINE void nrf_lpcomp_ext_ref_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_ext_ref_t ext_ref)
 Function for setting the external analog reference source.
 
NRF_STATIC_INLINE void nrf_lpcomp_input_select (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_input_t input)
 Function for selecting an active LPCOMP input.
 
NRF_STATIC_INLINE void nrf_lpcomp_detection_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_detect_t detection)
 Function for setting the detection type.
 
NRF_STATIC_INLINE void nrf_lpcomp_hysteresis_set (NRF_LPCOMP_Type *p_reg, nrf_lpcomp_hyst_t hyst)
 Function for setting the hysteresis.
 
NRF_STATIC_INLINE void nrf_lpcomp_enable (NRF_LPCOMP_Type *p_reg)
 Function for enabling the LPCOMP.
 
NRF_STATIC_INLINE void nrf_lpcomp_disable (NRF_LPCOMP_Type *p_reg)
 Function for disabling the LPCOMP.
 
NRF_STATIC_INLINE bool nrf_lpcomp_enable_check (NRF_LPCOMP_Type *p_reg)
 Function for checking if the LPCOMP peripheral is enabled.
 
NRF_STATIC_INLINE uint32_t nrf_lpcomp_result_get (NRF_LPCOMP_Type const *p_reg)
 Function for getting the last LPCOMP compare result.
 

Detailed Description

Hardware access layer for managing the Low Power Comparator (LPCOMP) peripheral.

Enumeration Type Documentation

◆ nrf_lpcomp_detect_t

LPCOMP detection type selection.

Enumerator
NRF_LPCOMP_DETECT_CROSS 

Generate ANADETEC on crossing, both upwards and downwards crossing.

NRF_LPCOMP_DETECT_UP 

Generate ANADETEC on upwards crossing only.

NRF_LPCOMP_DETECT_DOWN 

Generate ANADETEC on downwards crossing only.

◆ nrf_lpcomp_event_t

LPCOMP events.

Enumerator
NRF_LPCOMP_EVENT_READY 

LPCOMP is ready and output is valid.

NRF_LPCOMP_EVENT_DOWN 

Input voltage crossed the threshold going down.

NRF_LPCOMP_EVENT_UP 

Input voltage crossed the threshold going up.

NRF_LPCOMP_EVENT_CROSS 

Input voltage crossed the threshold in any direction.

◆ nrf_lpcomp_hyst_t

LPCOMP hysteresis.

Enumerator
NRF_LPCOMP_HYST_NOHYST 

Comparator hysteresis disabled.

NRF_LPCOMP_HYST_ENABLED 

Comparator hysteresis enabled (typically 50 mV).

◆ nrf_lpcomp_int_mask_t

LPCOMP interrupts.

Enumerator
NRF_LPCOMP_INT_READY_MASK 

Interrupt on READY event.

NRF_LPCOMP_INT_DOWN_MASK 

Interrupt on DOWN event.

NRF_LPCOMP_INT_UP_MASK 

Interrupt on UP event.

NRF_LPCOMP_INT_CROSS_MASK 

Interrupt on CROSS event.

◆ nrf_lpcomp_ref_t

LPCOMP reference selection.

Enumerator
NRF_LPCOMP_REF_SUPPLY_1_8 

Use supply with a 1/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_2_8 

Use supply with a 2/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_3_8 

Use supply with a 3/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_4_8 

Use supply with a 4/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_5_8 

Use supply with a 5/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_6_8 

Use supply with a 6/8 prescaler as reference.

NRF_LPCOMP_REF_SUPPLY_7_8 

Use supply with a 7/8 prescaler as reference.

NRF_LPCOMP_REF_EXT_REF 

Use external analog reference.

◆ nrf_lpcomp_short_mask_t

LPCOMP shortcut masks.

Enumerator
NRF_LPCOMP_SHORT_CROSS_STOP_MASK 

Shortcut between CROSS event and STOP task.

NRF_LPCOMP_SHORT_UP_STOP_MASK 

Shortcut between UP event and STOP task.

NRF_LPCOMP_SHORT_DOWN_STOP_MASK 

Shortcut between DOWN event and STOP task.

NRF_LPCOMP_SHORT_READY_STOP_MASK 

Shortcut between READY event and STOP task.

NRF_LPCOMP_SHORT_READY_SAMPLE_MASK 

Shortcut between READY event and SAMPLE task.

◆ nrf_lpcomp_task_t

LPCOMP tasks.

Enumerator
NRF_LPCOMP_TASK_START 

LPCOMP start sampling task.

NRF_LPCOMP_TASK_STOP 

LPCOMP stop sampling task.

NRF_LPCOMP_TASK_SAMPLE 

Sample comparator value.

Function Documentation

◆ nrf_lpcomp_configure()

NRF_STATIC_INLINE void nrf_lpcomp_configure ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_config_t const *  p_config 
)

Function for configuring LPCOMP.

This function powers on LPCOMP and configures it. LPCOMP is in DISABLE state after configuration, so it must be enabled before using it. All shorts are inactive, events are cleared, and LPCOMP is stopped.

Deprecated:
Use the dedicated functions instead.
Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_configConfiguration.

◆ nrf_lpcomp_detection_set()

NRF_STATIC_INLINE void nrf_lpcomp_detection_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_detect_t  detection 
)

Function for setting the detection type.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]detectionLPCOMP detection type.

◆ nrf_lpcomp_disable()

NRF_STATIC_INLINE void nrf_lpcomp_disable ( NRF_LPCOMP_Type *  p_reg)

Function for disabling the LPCOMP.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_lpcomp_enable()

NRF_STATIC_INLINE void nrf_lpcomp_enable ( NRF_LPCOMP_Type *  p_reg)

Function for enabling the LPCOMP.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_lpcomp_enable_check()

NRF_STATIC_INLINE bool nrf_lpcomp_enable_check ( NRF_LPCOMP_Type *  p_reg)

Function for checking if the LPCOMP peripheral is enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Return values
trueThe LPCOMP peripheral is enabled.
falseThe LPCOMP peripheral is not enabled.

◆ nrf_lpcomp_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_lpcomp_event_address_get ( NRF_LPCOMP_Type const *  p_reg,
nrf_lpcomp_event_t  event 
)

Function for getting the address of the specified LPCOMP event register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventLPCOMP event.
Returns
The address of the specified LPCOMP event.

◆ nrf_lpcomp_event_check()

NRF_STATIC_INLINE bool nrf_lpcomp_event_check ( NRF_LPCOMP_Type const *  p_reg,
nrf_lpcomp_event_t  event 
)

Function for retrieving the state of the LPCOMP event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_lpcomp_event_clear()

NRF_STATIC_INLINE void nrf_lpcomp_event_clear ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_event_t  event 
)

Function for clearing the specified LPCOMP event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventLPCOMP event to be cleared.

◆ nrf_lpcomp_ext_ref_set()

NRF_STATIC_INLINE void nrf_lpcomp_ext_ref_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_ext_ref_t  ext_ref 
)

Function for setting the external analog reference source.

To use external reference first call nrf_lpcomp_ref_set with NRF_LPCOMP_REF_EXT_REF argument.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]ext_refLPCOMP external analog reference selection.

◆ nrf_lpcomp_hysteresis_set()

NRF_STATIC_INLINE void nrf_lpcomp_hysteresis_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_hyst_t  hyst 
)

Function for setting the hysteresis.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]hystLPCOMP comparator hysteresis.

◆ nrf_lpcomp_input_select()

NRF_STATIC_INLINE void nrf_lpcomp_input_select ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_input_t  input 
)

Function for selecting an active LPCOMP input.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]inputInput to be selected.

◆ nrf_lpcomp_int_disable()

NRF_STATIC_INLINE void nrf_lpcomp_int_disable ( NRF_LPCOMP_Type *  p_reg,
uint32_t  mask 
)

Function for disabling interrupts from LPCOMP.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled. Use nrf_lpcomp_int_mask_t values for bit masking.
See also
nrf_lpcomp_int_enable
nrf_lpcomp_int_enable_check

◆ nrf_lpcomp_int_enable()

NRF_STATIC_INLINE void nrf_lpcomp_int_enable ( NRF_LPCOMP_Type *  p_reg,
uint32_t  mask 
)

Function for enabling interrupts from LPCOMP.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled. Use nrf_lpcomp_int_mask_t values for bit masking.
See also
nrf_lpcomp_int_disable
nrf_lpcomp_int_enable_check

◆ nrf_lpcomp_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_lpcomp_int_enable_check ( NRF_LPCOMP_Type const *  p_reg,
uint32_t  mask 
)

Function for checking if the specified interrupts are enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked. Use nrf_lpcomp_int_mask_t values for bit masking.
Returns
Mask of enabled interrupts.

◆ nrf_lpcomp_publish_clear()

NRF_STATIC_INLINE void nrf_lpcomp_publish_clear ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_event_t  event 
)

Function for clearing publish configuration for a given LPCOMP event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which the configuration is cleared.

◆ nrf_lpcomp_publish_set()

NRF_STATIC_INLINE void nrf_lpcomp_publish_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_event_t  event,
uint8_t  channel 
)

Function for setting publish configuration for a given LPCOMP event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which the configuration is set.
[in]channelChannel through which the event is published.

◆ nrf_lpcomp_ref_set()

NRF_STATIC_INLINE void nrf_lpcomp_ref_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_ref_t  reference 
)

Function for setting the reference source.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]referenceLPCOMP reference selection.

◆ nrf_lpcomp_result_get()

NRF_STATIC_INLINE uint32_t nrf_lpcomp_result_get ( NRF_LPCOMP_Type const *  p_reg)

Function for getting the last LPCOMP compare result.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
The last compare result. If 0, then VIN+ < VIN-. If 1, then VIN- < VIN+.

◆ nrf_lpcomp_shorts_disable()

NRF_STATIC_INLINE void nrf_lpcomp_shorts_disable ( NRF_LPCOMP_Type *  p_reg,
uint32_t  mask 
)

Function for clearing LPCOMP shorts by mask.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of shortcuts.

◆ nrf_lpcomp_shorts_enable()

NRF_STATIC_INLINE void nrf_lpcomp_shorts_enable ( NRF_LPCOMP_Type *  p_reg,
uint32_t  mask 
)

Function for setting LPCOMP shorts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of shortcuts.

◆ nrf_lpcomp_shorts_set()

NRF_STATIC_INLINE void nrf_lpcomp_shorts_set ( NRF_LPCOMP_Type *  p_reg,
uint32_t  mask 
)

Function for for setting the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of shortcuts.

◆ nrf_lpcomp_subscribe_clear()

NRF_STATIC_INLINE void nrf_lpcomp_subscribe_clear ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_task_t  task 
)

Function for clearing subscribe configuration for a given LPCOMP task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which the configuration is cleared.

◆ nrf_lpcomp_subscribe_set()

NRF_STATIC_INLINE void nrf_lpcomp_subscribe_set ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_task_t  task,
uint8_t  channel 
)

Function for setting subscribe configuration for a given LPCOMP task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which the configuration is set.
[in]channelChannel through which events are subscribed.

◆ nrf_lpcomp_task_address_get()

NRF_STATIC_INLINE uint32_t nrf_lpcomp_task_address_get ( NRF_LPCOMP_Type const *  p_reg,
nrf_lpcomp_task_t  task 
)

Function for getting the address of the specified LPCOMP task register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskLPCOMP task.
Returns
The address of the specified LPCOMP task.

◆ nrf_lpcomp_task_trigger()

NRF_STATIC_INLINE void nrf_lpcomp_task_trigger ( NRF_LPCOMP_Type *  p_reg,
nrf_lpcomp_task_t  task 
)

Function for setting the specified LPCOMP task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskLPCOMP task to be set.

Documentation feedback | Developer Zone | Subscribe | Updated