LPCOMP HAL
- group nrf_lpcomp_hal
Hardware access layer for managing the Low Power Comparator (LPCOMP) peripheral.
Defines
-
NRF_LPCOMP_HAS_AIN_AS_PIN
Symbol indicating whether the configuration of analog input using pin number is present.
-
NRF_LPCOMP_HAS_HYST
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.
Enums
-
enum nrf_lpcomp_task_t
LPCOMP tasks.
Values:
-
enumerator NRF_LPCOMP_TASK_START
LPCOMP start sampling task.
-
enumerator NRF_LPCOMP_TASK_STOP
LPCOMP stop sampling task.
-
enumerator NRF_LPCOMP_TASK_SAMPLE
Sample comparator value.
-
enumerator NRF_LPCOMP_TASK_START
-
enum nrf_lpcomp_event_t
LPCOMP events.
Values:
-
enumerator NRF_LPCOMP_EVENT_READY
LPCOMP is ready and output is valid.
-
enumerator NRF_LPCOMP_EVENT_DOWN
Input voltage crossed the threshold going down.
-
enumerator NRF_LPCOMP_EVENT_UP
Input voltage crossed the threshold going up.
-
enumerator NRF_LPCOMP_EVENT_CROSS
Input voltage crossed the threshold in any direction.
-
enumerator NRF_LPCOMP_EVENT_READY
-
enum nrf_lpcomp_int_mask_t
LPCOMP interrupts.
Values:
-
enumerator NRF_LPCOMP_INT_READY_MASK
Interrupt on READY event.
-
enumerator NRF_LPCOMP_INT_DOWN_MASK
Interrupt on DOWN event.
-
enumerator NRF_LPCOMP_INT_UP_MASK
Interrupt on UP event.
-
enumerator NRF_LPCOMP_INT_CROSS_MASK
Interrupt on CROSS event.
-
enumerator NRF_LPCOMP_INT_READY_MASK
-
enum nrf_lpcomp_short_mask_t
LPCOMP shortcut masks.
Values:
-
enumerator NRF_LPCOMP_SHORT_CROSS_STOP_MASK
Shortcut between CROSS event and STOP task.
-
enumerator NRF_LPCOMP_SHORT_UP_STOP_MASK
Shortcut between UP event and STOP task.
-
enumerator NRF_LPCOMP_SHORT_DOWN_STOP_MASK
Shortcut between DOWN event and STOP task.
-
enumerator NRF_LPCOMP_SHORT_READY_STOP_MASK
Shortcut between READY event and STOP task.
-
enumerator NRF_LPCOMP_SHORT_READY_SAMPLE_MASK
Shortcut between READY event and SAMPLE task.
-
enumerator NRF_LPCOMP_SHORT_CROSS_STOP_MASK
-
enum nrf_lpcomp_ref_t
LPCOMP reference selection.
Values:
-
enumerator NRF_LPCOMP_REF_SUPPLY_1_8
Use supply with a 1/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_2_8
Use supply with a 2/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_3_8
Use supply with a 3/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_4_8
Use supply with a 4/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_5_8
Use supply with a 5/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_6_8
Use supply with a 6/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_7_8
Use supply with a 7/8 prescaler as reference.
-
enumerator NRF_LPCOMP_REF_EXT_REF
Use external analog reference.
-
enumerator NRF_LPCOMP_REF_SUPPLY_1_8
-
enum nrf_lpcomp_detect_t
LPCOMP detection type selection.
Values:
-
enumerator NRF_LPCOMP_DETECT_CROSS
Generate ANADETEC on crossing, both upwards and downwards crossing.
-
enumerator NRF_LPCOMP_DETECT_UP
Generate ANADETEC on upwards crossing only.
-
enumerator NRF_LPCOMP_DETECT_DOWN
Generate ANADETEC on downwards crossing only.
-
enumerator NRF_LPCOMP_DETECT_CROSS
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.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] LPCOMP task to be set.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] LPCOMP task.
- Returns:
The address of the specified LPCOMP task.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event to be checked.
- Return values:
true – The event has been generated.
false – The event has not been generated.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] LPCOMP event to be cleared.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] LPCOMP event.
- Returns:
The address of the specified LPCOMP event.
-
NRF_STATIC_INLINE void nrf_lpcomp_shorts_enable(NRF_LPCOMP_Type *p_reg, uint32_t mask)
Function for setting LPCOMP shorts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of shortcuts.
-
NRF_STATIC_INLINE void nrf_lpcomp_shorts_disable(NRF_LPCOMP_Type *p_reg, uint32_t mask)
Function for clearing LPCOMP shorts 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_lpcomp_shorts_set(NRF_LPCOMP_Type *p_reg, uint32_t mask)
Function for for setting the specified shortcuts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of shortcuts.
-
NRF_STATIC_INLINE void nrf_lpcomp_int_enable(NRF_LPCOMP_Type *p_reg, uint32_t mask)
Function for enabling interrupts from LPCOMP.
See also
See also
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be enabled. Use nrf_lpcomp_int_mask_t values for bit masking.
-
NRF_STATIC_INLINE void nrf_lpcomp_int_disable(NRF_LPCOMP_Type *p_reg, uint32_t mask)
Function for disabling interrupts from LPCOMP.
See also
See also
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be disabled. Use nrf_lpcomp_int_mask_t values for bit masking.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be checked. Use nrf_lpcomp_int_mask_t values for bit masking.
- Returns:
Mask of enabled interrupts.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task for which the configuration is set.
channel – [in] Channel through which events are subscribed.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task for which the configuration is cleared.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event for which the configuration is set.
channel – [in] Channel through which the event is published.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event for which the configuration is cleared.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
p_config – [in] Configuration.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
reference – [in] LPCOMP reference selection.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
ext_ref – [in] LPCOMP external analog reference selection.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
input – [in] Input to be selected.
-
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:
p_reg – [in] Pointer to the structure of registers of the peripheral.
detection – [in] LPCOMP 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.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
hyst – [in] LPCOMP comparator hysteresis.
-
NRF_STATIC_INLINE void nrf_lpcomp_enable(NRF_LPCOMP_Type *p_reg)
Function for enabling the LPCOMP.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE void nrf_lpcomp_disable(NRF_LPCOMP_Type *p_reg)
Function for disabling the LPCOMP.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE bool nrf_lpcomp_enable_check(NRF_LPCOMP_Type *p_reg)
Function for checking if the LPCOMP peripheral is enabled.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Return values:
true – The LPCOMP peripheral is enabled.
false – The LPCOMP peripheral is not enabled.
-
NRF_STATIC_INLINE uint32_t nrf_lpcomp_result_get(NRF_LPCOMP_Type const *p_reg)
Function for getting the last LPCOMP compare 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+.
-
struct nrf_lpcomp_config_t
- #include <nrf_lpcomp.h>
LPCOMP configuration.
Public Members
-
nrf_lpcomp_ref_t reference
LPCOMP reference.
-
nrf_lpcomp_detect_t detection
LPCOMP detection type.
-
nrf_lpcomp_hyst_t hyst
LPCOMP hysteresis.
-
nrf_lpcomp_ref_t reference
-
NRF_LPCOMP_HAS_AIN_AS_PIN