COMP HAL¶
-
group
nrf_comp_hal
Hardware access layer (HAL) for managing the Comparator (COMP) peripheral.
Enums
-
enum
nrf_comp_input_t
¶ COMP analog pin selection.
Values:
-
enumerator
NRF_COMP_INPUT_0
¶ AIN0 selected as analog input.
-
enumerator
NRF_COMP_INPUT_1
¶ AIN1 selected as analog input.
-
enumerator
NRF_COMP_INPUT_2
¶ AIN2 selected as analog input.
-
enumerator
NRF_COMP_INPUT_3
¶ AIN3 selected as analog input.
-
enumerator
NRF_COMP_INPUT_4
¶ AIN4 selected as analog input.
-
enumerator
NRF_COMP_INPUT_5
¶ AIN5 selected as analog input.
-
enumerator
NRF_COMP_INPUT_6
¶ AIN6 selected as analog input.
-
enumerator
NRF_COMP_INPUT_7
¶ AIN7 selected as analog input.
-
enumerator
NRF_COMP_VDD_DIV2
¶ VDD/2 selected as analog input.
-
enumerator
NRF_COMP_VDDH_DIV5
¶ VDDH/5 selected as analog input.
-
enumerator
-
enum
nrf_comp_ref_t
¶ COMP reference selection.
Values:
-
enumerator
NRF_COMP_REF_Int1V2
¶ VREF = internal 1.2 V reference (VDD >= 1.7 V).
-
enumerator
NRF_COMP_REF_Int1V8
¶ VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V).
-
enumerator
NRF_COMP_REF_Int2V4
¶ VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V).
-
enumerator
NRF_COMP_REF_VDD
¶ VREF = VDD.
-
enumerator
NRF_COMP_REF_ARef
¶ VREF = AREF (VDD >= VREF >= AREFMIN).
-
enumerator
-
enum
nrf_comp_ext_ref_t
¶ COMP external analog reference selection.
Values:
-
enumerator
NRF_COMP_EXT_REF_0
¶ Use AIN0 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_1
¶ Use AIN1 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_2
¶ Use AIN2 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_3
¶ Use AIN3 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_4
¶ Use AIN4 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_5
¶ Use AIN5 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_6
¶ Use AIN6 as external analog reference.
-
enumerator
NRF_COMP_EXT_REF_7
¶ Use AIN7 as external analog reference.
-
enumerator
-
enum
nrf_comp_main_mode_t
¶ COMP main operation mode.
Values:
-
enumerator
NRF_COMP_MAIN_MODE_SE
¶ Single-ended mode.
-
enumerator
NRF_COMP_MAIN_MODE_Diff
¶ Differential mode.
-
enumerator
-
enum
nrf_comp_sp_mode_t
¶ COMP speed and power mode.
Values:
-
enumerator
NRF_COMP_SP_MODE_Low
¶ Low power mode.
-
enumerator
NRF_COMP_SP_MODE_Normal
¶ Normal mode.
-
enumerator
NRF_COMP_SP_MODE_High
¶ High-speed mode.
-
enumerator
-
enum
nrf_comp_hyst_t
¶ COMP comparator hysteresis.
Values:
-
enumerator
NRF_COMP_HYST_NoHyst
¶ Comparator hysteresis disabled.
-
enumerator
NRF_COMP_HYST_50mV
¶ Comparator hysteresis enabled.
-
enumerator
-
enum
nrf_isource_t
¶ COMP current source selection on analog input.
Values:
-
enumerator
NRF_COMP_ISOURCE_Off
¶ Current source disabled.
-
enumerator
NRF_COMP_ISOURCE_Ien2uA5
¶ Current source enabled (+/- 2.5 uA).
-
enumerator
NRF_COMP_ISOURCE_Ien5uA
¶ Current source enabled (+/- 5 uA).
-
enumerator
NRF_COMP_ISOURCE_Ien10uA
¶ Current source enabled (+/- 10 uA).
-
enumerator
-
enum
nrf_comp_task_t
¶ COMP tasks.
Values:
-
enumerator
NRF_COMP_TASK_START
¶ COMP start sampling task.
-
enumerator
NRF_COMP_TASK_STOP
¶ COMP stop sampling task.
-
enumerator
NRF_COMP_TASK_SAMPLE
¶ Sample comparator value.
-
enumerator
-
enum
nrf_comp_event_t
¶ COMP events.
Values:
-
enumerator
NRF_COMP_EVENT_READY
¶ COMP is ready and output is valid.
-
enumerator
NRF_COMP_EVENT_DOWN
¶ Input voltage crossed the threshold going down.
-
enumerator
NRF_COMP_EVENT_UP
¶ Input voltage crossed the threshold going up.
-
enumerator
NRF_COMP_EVENT_CROSS
¶ Input voltage crossed the threshold in any direction.
-
enumerator
Functions
-
NRF_STATIC_INLINE void
nrf_comp_enable
(NRF_COMP_Type *p_reg)¶ Function for enabling the COMP peripheral.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE void
nrf_comp_disable
(NRF_COMP_Type *p_reg)¶ Function for disabling the COMP peripheral.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE bool
nrf_comp_enable_check
(NRF_COMP_Type const *p_reg)¶ Function for checking if the COMP peripheral is enabled.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Returns true
The COMP peripheral is enabled.
- Returns false
The COMP peripheral is not 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.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
reference – [in] COMP reference selection.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
ext_ref – [in] COMP external analog reference selection.
-
NRF_STATIC_INLINE void
nrf_comp_th_set
(NRF_COMP_Type *p_reg, nrf_comp_th_t threshold)¶ Function for setting threshold voltages.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
threshold – [in] COMP VDOWN and VUP thresholds.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
main_mode – [in] COMP main operation 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.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
speed_mode – [in] COMP speed and power mode.
-
NRF_STATIC_INLINE void
nrf_comp_hysteresis_set
(NRF_COMP_Type *p_reg, nrf_comp_hyst_t hyst)¶ Function for setting the hysteresis.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
hyst – [in] COMP comparator 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.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
isource – [in] COMP current source selection on 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.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
input – [in] Input to be selected.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Returns
The last compare result. If 0, then VIN+ < VIN-. If 1, then VIN+ > VIN-.
-
NRF_STATIC_INLINE void
nrf_comp_int_enable
(NRF_COMP_Type *p_reg, uint32_t mask)¶ Function for enabling interrupts from COMP.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be enabled.
-
NRF_STATIC_INLINE void
nrf_comp_int_disable
(NRF_COMP_Type *p_reg, uint32_t mask)¶ Function for disabling interrupts from COMP.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be disabled.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be checked.
- Returns
Mask of enabled interrupts.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] COMP task.
- Returns
Address of the specified COMP task.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] COMP event.
- Returns
Address of the specified COMP event.
-
NRF_STATIC_INLINE void
nrf_comp_shorts_enable
(NRF_COMP_Type *p_reg, uint32_t mask)¶ Function for setting COMP shortcuts.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of shortcuts.
-
NRF_STATIC_INLINE void
nrf_comp_shorts_disable
(NRF_COMP_Type *p_reg, uint32_t mask)¶ Function for clearing COMP shortcuts by mask.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of shortcuts.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task to be activated.
-
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
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] COMP event to be cleared.
-
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 UARTE event.
- Parameters
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event to be checked.
- Returns true
The event has been generated.
- Returns false
The event has not been generated.
-
struct
nrf_comp_th_t
¶ - #include <nrf_comp.h>
COMP THDOWN and THUP values that are used to calculate the threshold voltages VDOWN and VUP.
-
struct
nrf_comp_ref_conf_t
¶ - #include <nrf_comp.h>
COMP reference configuration.
Public Members
-
nrf_comp_ref_t
reference
¶ COMP reference selection.
-
nrf_comp_ext_ref_t
external
¶ COMP external analog reference selection.
-
nrf_comp_ref_t
-
enum