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

Hardware access layer (HAL) for managing the Comparator (COMP) peripheral. More...

Data Structures

struct  nrf_comp_th_t
 COMP THDOWN and THUP values that are used to calculate the threshold voltages VDOWN and VUP. More...
 
struct  nrf_comp_ref_conf_t
 COMP reference configuration. More...
 

Macros

#define NRF_COMP_HAS_ISOURCE   1
 Symbol indicating whether COMP has ISOURCE register.
 
#define NRF_COMP_HAS_AIN_AS_PIN   1
 Symbol indicating whether the configuration of analog input using pin number is present.
 

Typedefs

typedef uint32_t nrf_comp_input_t
 COMP analog pin selection.
 
typedef uint32_t nrf_comp_ext_ref_t
 COMP external analog reference selection.
 

Enumerations

enum  nrf_comp_ref_t {
  NRF_COMP_REF_INT_1V2 = COMP_REFSEL_REFSEL_Int1V2 ,
  NRF_COMP_REF_INT_1V8 = COMP_REFSEL_REFSEL_Int1V8 ,
  NRF_COMP_REF_INT_2V4 = COMP_REFSEL_REFSEL_Int2V4 ,
  NRF_COMP_REF_AVDDAO1V8 = COMP_REFSEL_REFSEL_AVDDAO1V8 ,
  NRF_COMP_REF_VDD = COMP_REFSEL_REFSEL_VDD ,
  NRF_COMP_REF_AREF = COMP_REFSEL_REFSEL_ARef
}
 COMP reference selection. More...
 
enum  nrf_comp_main_mode_t {
  NRF_COMP_MAIN_MODE_SE = COMP_MODE_MAIN_SE ,
  NRF_COMP_MAIN_MODE_DIFF = COMP_MODE_MAIN_Diff
}
 COMP main operation mode. More...
 
enum  nrf_comp_sp_mode_t {
  NRF_COMP_SP_MODE_LOW = COMP_MODE_SP_Low ,
  NRF_COMP_SP_MODE_NORMAL = COMP_MODE_SP_Normal ,
  NRF_COMP_SP_MODE_HIGH = COMP_MODE_SP_High
}
 COMP speed and power mode. More...
 
enum  nrf_comp_hyst_t {
  NRF_COMP_HYST_NO_HYST = COMP_HYST_HYST_NoHyst ,
  NRF_COMP_HYST_40MV = COMP_HYST_HYST_Hyst40mV ,
  NRF_COMP_HYST_50MV = COMP_HYST_HYST_Hyst50mV
}
 COMP comparator hysteresis. More...
 
enum  nrf_isource_t {
  NRF_COMP_ISOURCE_OFF = COMP_ISOURCE_ISOURCE_Off ,
  NRF_COMP_ISOURCE_IEN_2UA5 = COMP_ISOURCE_ISOURCE_Ien2uA5 ,
  NRF_COMP_ISOURCE_IEN_5UA = COMP_ISOURCE_ISOURCE_Ien5uA ,
  NRF_COMP_ISOURCE_IEN_10UA = COMP_ISOURCE_ISOURCE_Ien10uA
}
 COMP current source selection on analog input. More...
 
enum  nrf_comp_task_t {
  NRF_COMP_TASK_START = offsetof(NRF_COMP_Type, TASKS_START) ,
  NRF_COMP_TASK_STOP = offsetof(NRF_COMP_Type, TASKS_STOP) ,
  NRF_COMP_TASK_SAMPLE = offsetof(NRF_COMP_Type, TASKS_SAMPLE)
}
 COMP tasks. More...
 
enum  nrf_comp_event_t {
  NRF_COMP_EVENT_READY = offsetof(NRF_COMP_Type, EVENTS_READY) ,
  NRF_COMP_EVENT_DOWN = offsetof(NRF_COMP_Type, EVENTS_DOWN) ,
  NRF_COMP_EVENT_UP = offsetof(NRF_COMP_Type, EVENTS_UP) ,
  NRF_COMP_EVENT_CROSS = offsetof(NRF_COMP_Type, EVENTS_CROSS)
}
 COMP events. More...
 
enum  nrf_comp_int_mask_t {
  NRF_COMP_INT_READY_MASK = COMP_INTENSET_READY_Msk ,
  NRF_COMP_INT_DOWN_MASK = COMP_INTENSET_DOWN_Msk ,
  NRF_COMP_INT_UP_MASK = COMP_INTENSET_UP_Msk ,
  NRF_COMP_INT_CROSS_MASK = COMP_INTENSET_CROSS_Msk
}
 COMP interrupts. More...
 
enum  nrf_comp_short_mask_t {
  NRF_COMP_SHORT_STOP_CROSS_MASK = COMP_SHORTS_CROSS_STOP_Msk ,
  NRF_COMP_SHORT_STOP_UP_MASK = COMP_SHORTS_UP_STOP_Msk ,
  NRF_COMP_SHORT_STOP_DOWN_MASK = COMP_SHORTS_DOWN_STOP_Msk
}
 COMP shortcut masks. More...
 

Functions

NRF_STATIC_INLINE void nrf_comp_enable (NRF_COMP_Type *p_reg)
 Function for enabling the COMP peripheral.
 
NRF_STATIC_INLINE void nrf_comp_disable (NRF_COMP_Type *p_reg)
 Function for disabling the COMP peripheral.
 
NRF_STATIC_INLINE bool nrf_comp_enable_check (NRF_COMP_Type const *p_reg)
 Function for checking if the COMP peripheral is enabled.
 
NRF_STATIC_INLINE void nrf_comp_ref_set (NRF_COMP_Type *p_reg, nrf_comp_ref_t reference)
 Function for setting the reference source.
 
NRF_STATIC_INLINE void nrf_comp_ext_ref_set (NRF_COMP_Type *p_reg, nrf_comp_ext_ref_t ext_ref)
 Function for setting the external analog reference source.
 
NRF_STATIC_INLINE void nrf_comp_th_set (NRF_COMP_Type *p_reg, nrf_comp_th_t threshold)
 Function for setting threshold voltages.
 
NRF_STATIC_INLINE void nrf_comp_main_mode_set (NRF_COMP_Type *p_reg, nrf_comp_main_mode_t main_mode)
 Function for setting the main mode.
 
NRF_STATIC_INLINE void nrf_comp_speed_mode_set (NRF_COMP_Type *p_reg, nrf_comp_sp_mode_t speed_mode)
 Function for setting the speed mode.
 
NRF_STATIC_INLINE void nrf_comp_hysteresis_set (NRF_COMP_Type *p_reg, nrf_comp_hyst_t hyst)
 Function for setting the hysteresis.
 
NRF_STATIC_INLINE void nrf_comp_isource_set (NRF_COMP_Type *p_reg, nrf_isource_t isource)
 Function for setting the current source on the analog input.
 
NRF_STATIC_INLINE void nrf_comp_input_select (NRF_COMP_Type *p_reg, nrf_comp_input_t input)
 Function for selecting the active input of the COMP.
 
NRF_STATIC_INLINE uint32_t nrf_comp_result_get (NRF_COMP_Type const *p_reg)
 Function for getting the last COMP compare result.
 
NRF_STATIC_INLINE void nrf_comp_int_enable (NRF_COMP_Type *p_reg, uint32_t mask)
 Function for enabling interrupts from COMP.
 
NRF_STATIC_INLINE void nrf_comp_int_disable (NRF_COMP_Type *p_reg, uint32_t mask)
 Function for disabling interrupts from COMP.
 
NRF_STATIC_INLINE uint32_t nrf_comp_int_enable_check (NRF_COMP_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled.
 
NRF_STATIC_INLINE uint32_t nrf_comp_task_address_get (NRF_COMP_Type const *p_reg, nrf_comp_task_t task)
 Function for getting the address of the specified COMP task register.
 
NRF_STATIC_INLINE uint32_t nrf_comp_event_address_get (NRF_COMP_Type const *p_reg, nrf_comp_event_t event)
 Function for getting the address of the specified COMP event register.
 
NRF_STATIC_INLINE void nrf_comp_shorts_enable (NRF_COMP_Type *p_reg, uint32_t mask)
 Function for setting COMP shortcuts.
 
NRF_STATIC_INLINE void nrf_comp_shorts_disable (NRF_COMP_Type *p_reg, uint32_t mask)
 Function for clearing COMP shortcuts by mask.
 
NRF_STATIC_INLINE void nrf_comp_task_trigger (NRF_COMP_Type *p_reg, nrf_comp_task_t task)
 Function for setting the specified COMP task.
 
NRF_STATIC_INLINE void nrf_comp_event_clear (NRF_COMP_Type *p_reg, nrf_comp_event_t event)
 Function for clearing the specified COMP event.
 
NRF_STATIC_INLINE bool nrf_comp_event_check (NRF_COMP_Type const *p_reg, nrf_comp_event_t event)
 Function for retrieving the state of the COMP event.
 

Detailed Description

Hardware access layer (HAL) for managing the Comparator (COMP) peripheral.

Enumeration Type Documentation

◆ nrf_comp_event_t

COMP events.

Enumerator
NRF_COMP_EVENT_READY 

COMP is ready and output is valid.

NRF_COMP_EVENT_DOWN 

Input voltage crossed the threshold going down.

NRF_COMP_EVENT_UP 

Input voltage crossed the threshold going up.

NRF_COMP_EVENT_CROSS 

Input voltage crossed the threshold in any direction.

◆ nrf_comp_hyst_t

COMP comparator hysteresis.

Enumerator
NRF_COMP_HYST_NO_HYST 

Comparator hysteresis disabled.

NRF_COMP_HYST_40MV 

Comparator hysteresis enabled at 40 mV level.

NRF_COMP_HYST_50MV 

Comparator hysteresis enabled at 50 mV level.

◆ nrf_comp_int_mask_t

COMP interrupts.

Enumerator
NRF_COMP_INT_READY_MASK 

Interrupt on READY event.

NRF_COMP_INT_DOWN_MASK 

Interrupt on DOWN event.

NRF_COMP_INT_UP_MASK 

Interrupt on UP event.

NRF_COMP_INT_CROSS_MASK 

Interrupt on CROSS event.

◆ nrf_comp_main_mode_t

COMP main operation mode.

Enumerator
NRF_COMP_MAIN_MODE_SE 

Single-ended mode.

NRF_COMP_MAIN_MODE_DIFF 

Differential mode.

◆ nrf_comp_ref_t

COMP reference selection.

Enumerator
NRF_COMP_REF_INT_1V2 

VREF = internal 1.2 V reference (VDD >= 1.7 V).

NRF_COMP_REF_INT_1V8 

VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V).

NRF_COMP_REF_INT_2V4 

VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V).

NRF_COMP_REF_AVDDAO1V8 

VREF = AVDD_AO_1V8.

NRF_COMP_REF_VDD 

VREF = VDD.

NRF_COMP_REF_AREF 

VREF = AREF (VDD >= VREF >= AREFMIN).

◆ nrf_comp_short_mask_t

COMP shortcut masks.

Enumerator
NRF_COMP_SHORT_STOP_CROSS_MASK 

Shortcut between the CROSS event and the STOP task.

NRF_COMP_SHORT_STOP_UP_MASK 

Shortcut between the UP event and the STOP task.

NRF_COMP_SHORT_STOP_DOWN_MASK 

Shortcut between the DOWN event and the STOP task.

◆ nrf_comp_sp_mode_t

COMP speed and power mode.

Enumerator
NRF_COMP_SP_MODE_LOW 

Low power mode.

NRF_COMP_SP_MODE_NORMAL 

Normal mode.

NRF_COMP_SP_MODE_HIGH 

High-speed mode.

◆ nrf_comp_task_t

COMP tasks.

Enumerator
NRF_COMP_TASK_START 

COMP start sampling task.

NRF_COMP_TASK_STOP 

COMP stop sampling task.

NRF_COMP_TASK_SAMPLE 

Sample comparator value.

◆ nrf_isource_t

COMP current source selection on analog input.

Enumerator
NRF_COMP_ISOURCE_OFF 

Current source disabled.

NRF_COMP_ISOURCE_IEN_2UA5 

Current source enabled (+/- 2.5 uA).

NRF_COMP_ISOURCE_IEN_5UA 

Current source enabled (+/- 5 uA).

NRF_COMP_ISOURCE_IEN_10UA 

Current source enabled (+/- 10 uA).

Function Documentation

◆ nrf_comp_disable()

NRF_STATIC_INLINE void nrf_comp_disable ( NRF_COMP_Type *  p_reg)

Function for disabling the COMP peripheral.

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

◆ nrf_comp_enable()

NRF_STATIC_INLINE void nrf_comp_enable ( NRF_COMP_Type *  p_reg)

Function for enabling the COMP peripheral.

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

◆ nrf_comp_enable_check()

NRF_STATIC_INLINE bool nrf_comp_enable_check ( NRF_COMP_Type const *  p_reg)

Function for checking if the COMP peripheral is enabled.

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

◆ nrf_comp_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_comp_event_address_get ( NRF_COMP_Type const *  p_reg,
nrf_comp_event_t  event 
)

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

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventCOMP event.
Returns
Address of the specified COMP event.

◆ nrf_comp_event_check()

NRF_STATIC_INLINE bool nrf_comp_event_check ( NRF_COMP_Type const *  p_reg,
nrf_comp_event_t  event 
)

Function for retrieving the state of the COMP 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_comp_event_clear()

NRF_STATIC_INLINE void nrf_comp_event_clear ( NRF_COMP_Type *  p_reg,
nrf_comp_event_t  event 
)

Function for clearing the specified COMP event.

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

◆ nrf_comp_ext_ref_set()

NRF_STATIC_INLINE void nrf_comp_ext_ref_set ( NRF_COMP_Type *  p_reg,
nrf_comp_ext_ref_t  ext_ref 
)

Function for setting the external analog reference source.

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

◆ nrf_comp_hysteresis_set()

NRF_STATIC_INLINE void nrf_comp_hysteresis_set ( NRF_COMP_Type *  p_reg,
nrf_comp_hyst_t  hyst 
)

Function for setting the hysteresis.

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

◆ nrf_comp_input_select()

NRF_STATIC_INLINE void nrf_comp_input_select ( NRF_COMP_Type *  p_reg,
nrf_comp_input_t  input 
)

Function for selecting the active input of the COMP.

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

◆ nrf_comp_int_disable()

NRF_STATIC_INLINE void nrf_comp_int_disable ( NRF_COMP_Type *  p_reg,
uint32_t  mask 
)

Function for disabling interrupts from COMP.

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

◆ nrf_comp_int_enable()

NRF_STATIC_INLINE void nrf_comp_int_enable ( NRF_COMP_Type *  p_reg,
uint32_t  mask 
)

Function for enabling interrupts from COMP.

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

◆ nrf_comp_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_comp_int_enable_check ( NRF_COMP_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_comp_int_mask_t values for bit masking.
Returns
Mask of enabled interrupts.

◆ nrf_comp_isource_set()

NRF_STATIC_INLINE void nrf_comp_isource_set ( NRF_COMP_Type *  p_reg,
nrf_isource_t  isource 
)

Function for setting the current source on the analog input.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]isourceCOMP current source selection on analog input.

◆ nrf_comp_main_mode_set()

NRF_STATIC_INLINE void nrf_comp_main_mode_set ( NRF_COMP_Type *  p_reg,
nrf_comp_main_mode_t  main_mode 
)

Function for setting the main mode.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]main_modeCOMP main operation mode.

◆ nrf_comp_ref_set()

NRF_STATIC_INLINE void nrf_comp_ref_set ( NRF_COMP_Type *  p_reg,
nrf_comp_ref_t  reference 
)

Function for setting the reference source.

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

◆ nrf_comp_result_get()

NRF_STATIC_INLINE uint32_t nrf_comp_result_get ( NRF_COMP_Type const *  p_reg)

Function for getting the last COMP compare result.

Note
If VIN+ == VIN-, the return value depends on the previous 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_comp_shorts_disable()

NRF_STATIC_INLINE void nrf_comp_shorts_disable ( NRF_COMP_Type *  p_reg,
uint32_t  mask 
)

Function for clearing COMP shortcuts by mask.

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

◆ nrf_comp_shorts_enable()

NRF_STATIC_INLINE void nrf_comp_shorts_enable ( NRF_COMP_Type *  p_reg,
uint32_t  mask 
)

Function for setting COMP shortcuts.

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

◆ nrf_comp_speed_mode_set()

NRF_STATIC_INLINE void nrf_comp_speed_mode_set ( NRF_COMP_Type *  p_reg,
nrf_comp_sp_mode_t  speed_mode 
)

Function for setting the speed mode.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]speed_modeCOMP speed and power mode.

◆ nrf_comp_task_address_get()

NRF_STATIC_INLINE uint32_t nrf_comp_task_address_get ( NRF_COMP_Type const *  p_reg,
nrf_comp_task_t  task 
)

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

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskCOMP task.
Returns
Address of the specified COMP task.

◆ nrf_comp_task_trigger()

NRF_STATIC_INLINE void nrf_comp_task_trigger ( NRF_COMP_Type *  p_reg,
nrf_comp_task_t  task 
)

Function for setting the specified COMP task.

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

◆ nrf_comp_th_set()

NRF_STATIC_INLINE void nrf_comp_th_set ( NRF_COMP_Type *  p_reg,
nrf_comp_th_t  threshold 
)

Function for setting threshold voltages.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]thresholdCOMP VDOWN and VUP thresholds.

Documentation feedback | Developer Zone | Subscribe | Updated