| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Enumerations | Functions
LPCOMP HAL
LPCOMP HAL and driver

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

## Data Structures
struct | nrf_lpcomp_config_t
| LPCOMP configuration. More...

## Macros
#define | NRF_LPCOMP_CONFIG_DEFAULT { NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT, NRF_LPCOMP_DETECT_DOWN }

## Enumerations
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_REF0, NRF_LPCOMP_CONFIG_REF_EXT_REF1 }
| LPCOMP reference selection. More...
enum | nrf_lpcomp_input_t { NRF_LPCOMP_INPUT_0 = LPCOMP_PSEL_PSEL_AnalogInput0, NRF_LPCOMP_INPUT_1 = LPCOMP_PSEL_PSEL_AnalogInput1, NRF_LPCOMP_INPUT_2 = LPCOMP_PSEL_PSEL_AnalogInput2, NRF_LPCOMP_INPUT_3 = LPCOMP_PSEL_PSEL_AnalogInput3, NRF_LPCOMP_INPUT_4 = LPCOMP_PSEL_PSEL_AnalogInput4, NRF_LPCOMP_INPUT_5 = LPCOMP_PSEL_PSEL_AnalogInput5, NRF_LPCOMP_INPUT_6 = LPCOMP_PSEL_PSEL_AnalogInput6, NRF_LPCOMP_INPUT_7 = LPCOMP_PSEL_PSEL_AnalogInput7 }
| LPCOMP input 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_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_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 shorts masks. More...

## Functions
__STATIC_INLINE void | nrf_lpcomp_configure (const nrf_lpcomp_config_t *p_config)
| Function for configuring LPCOMP. More...
__STATIC_INLINE void | nrf_lpcomp_input_select (nrf_lpcomp_input_t input)
| Function for selecting the LPCOMP input. More...
__STATIC_INLINE void | nrf_lpcomp_enable (void)
| Function for enabling the Low Power Comparator. More...
__STATIC_INLINE void | nrf_lpcomp_disable (void)
| Function for disabling the Low Power Comparator. More...
__STATIC_INLINE uint32_t | nrf_lpcomp_result_get (void)
| Function for getting the last LPCOMP compare result. More...
__STATIC_INLINE void | nrf_lpcomp_int_enable (uint32_t lpcomp_int_mask)
| Function for enabling interrupts from LPCOMP. More...
__STATIC_INLINE void | nrf_lpcomp_int_disable (uint32_t lpcomp_int_mask)
| Function for disabling interrupts from LPCOMP. More...
__STATIC_INLINE bool | nrf_lpcomp_int_enable_check (uint32_t lpcomp_int_mask)
| Function for getting the enabled interrupts of LPCOMP. More...
__STATIC_INLINE uint32_t * | nrf_lpcomp_task_address_get (nrf_lpcomp_task_t lpcomp_task)
| Function for getting the address of a specific LPCOMP task register. More...
__STATIC_INLINE uint32_t * | nrf_lpcomp_event_address_get (nrf_lpcomp_event_t lpcomp_event)
| Function for getting the address of a specific LPCOMP event register. More...
__STATIC_INLINE void | nrf_lpcomp_shorts_enable (uint32_t lpcomp_short_mask)
| Function for setting LPCOMP shorts. More...
__STATIC_INLINE void | nrf_lpcomp_shorts_disable (uint32_t lpcomp_short_mask)
| Function for clearing LPCOMP shorts by mask. More...
__STATIC_INLINE void | nrf_lpcomp_task_trigger (nrf_lpcomp_task_t lpcomp_task)
| Function for setting a specific LPCOMP task. More...
__STATIC_INLINE void | nrf_lpcomp_event_clear (nrf_lpcomp_event_t lpcomp_event)
| Function for clearing a specific LPCOMP event. More...
__STATIC_INLINE bool | nrf_lpcomp_event_check (nrf_lpcomp_event_t lpcomp_event)
| Function for getting the state of a specific LPCOMP event. More...

## Detailed Description

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

## Macro Definition Documentation

#define NRF_LPCOMP_CONFIG_DEFAULT { NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT, NRF_LPCOMP_DETECT_DOWN }

Default LPCOMP configuration.

## Enumeration Type Documentation

enum 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.

enum 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.

enum nrf_lpcomp_input_t

LPCOMP input selection.

Enumerator
NRF_LPCOMP_INPUT_0 | Input 0.
NRF_LPCOMP_INPUT_1 | Input 1.
NRF_LPCOMP_INPUT_2 | Input 2.
NRF_LPCOMP_INPUT_3 | Input 3.
NRF_LPCOMP_INPUT_4 | Input 4.
NRF_LPCOMP_INPUT_5 | Input 5.
NRF_LPCOMP_INPUT_6 | Input 6.
NRF_LPCOMP_INPUT_7 | Input 7.

enum 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_REF0 | External reference 0.
NRF_LPCOMP_CONFIG_REF_EXT_REF1 | External reference 1.

enum nrf_lpcomp_short_mask_t

LPCOMP shorts masks.

Enumerator
NRF_LPCOMP_SHORT_CROSS_STOP_MASK | Short between CROSS event and STOP task.
NRF_LPCOMP_SHORT_UP_STOP_MASK | Short between UP event and STOP task.
NRF_LPCOMP_SHORT_DOWN_STOP_MASK | Short between DOWN event and STOP task.
NRF_LPCOMP_SHORT_READY_STOP_MASK | Short between READY event and STOP task.
NRF_LPCOMP_SHORT_READY_SAMPLE_MASK | Short between READY event and SAMPLE task.

enum 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

__STATIC_INLINE void nrf_lpcomp_configure | ( | const nrf_lpcomp_config_t * | 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.

Parameters

  [in] | p_config | Configuration.

__STATIC_INLINE void nrf_lpcomp_disable | ( | void |  | ) |

Function for disabling the Low Power Comparator.

This function disables LPCOMP.

__STATIC_INLINE void nrf_lpcomp_enable | ( | void |  | ) |

Function for enabling the Low Power Comparator.

This function enables LPCOMP.

__STATIC_INLINE uint32_t* nrf_lpcomp_event_address_get | ( | nrf_lpcomp_event_t | lpcomp_event | ) |

Function for getting the address of a specific LPCOMP event register.

Parameters

  [in] | lpcomp_event | LPCOMP event.

Returns
  The address of the specified LPCOMP event.

__STATIC_INLINE bool nrf_lpcomp_event_check | ( | nrf_lpcomp_event_t | lpcomp_event | ) |

Function for getting the state of a specific LPCOMP event.

Return values

  true | If the specified LPCOMP event is active.

__STATIC_INLINE void nrf_lpcomp_event_clear | ( | nrf_lpcomp_event_t | lpcomp_event | ) |

Function for clearing a specific LPCOMP event.

Parameters

  [in] | lpcomp_event | LPCOMP event to be cleared.

__STATIC_INLINE void nrf_lpcomp_input_select | ( | nrf_lpcomp_input_t | input | ) |

Function for selecting the LPCOMP input.

This function selects the active input of LPCOMP.

Parameters

  [in] | input | Input to be selected.

__STATIC_INLINE void nrf_lpcomp_int_disable | ( | uint32_t | lpcomp_int_mask | ) |

Function for disabling interrupts from LPCOMP.

Parameters

  [in] | lpcomp_int_mask | Mask of interrupts to be disabled.

See Also
  nrf_lpcomp_int_enable()
  nrf_lpcomp_int_enable_check()

__STATIC_INLINE void nrf_lpcomp_int_enable | ( | uint32_t | lpcomp_int_mask | ) |

Function for enabling interrupts from LPCOMP.

Parameters

  [in] | lpcomp_int_mask | Mask of interrupts to be enabled.

See Also
  nrf_lpcomp_int_disable()
  nrf_lpcomp_int_enable_check()

__STATIC_INLINE bool nrf_lpcomp_int_enable_check | ( | uint32_t | lpcomp_int_mask | ) |

Function for getting the enabled interrupts of LPCOMP.

Parameters

  [in] | lpcomp_int_mask | Mask of interrupts to be checked.

Return values

  true | If any of interrupts of the specified mask are enabled.

See Also
  nrf_lpcomp_int_enable()
  nrf_lpcomp_int_disable()

__STATIC_INLINE uint32_t nrf_lpcomp_result_get | ( | void |  | ) |

Function for getting the last LPCOMP compare result.

Returns
  The last compare result. If 0 then VIN+ < VIN-, if 1 then the opposite.

__STATIC_INLINE void nrf_lpcomp_shorts_disable | ( | uint32_t | lpcomp_short_mask | ) |

Function for clearing LPCOMP shorts by mask.

Parameters

  [in] | lpcomp_short_mask | LPCOMP shorts to be cleared.

__STATIC_INLINE void nrf_lpcomp_shorts_enable | ( | uint32_t | lpcomp_short_mask | ) |

Function for setting LPCOMP shorts.

Parameters

  [in] | lpcomp_short_mask | LPCOMP shorts by mask.

__STATIC_INLINE uint32_t* nrf_lpcomp_task_address_get | ( | nrf_lpcomp_task_t | lpcomp_task | ) |

Function for getting the address of a specific LPCOMP task register.

Parameters

  [in] | lpcomp_task | LPCOMP task.

Returns
  The address of the specified LPCOMP task.

__STATIC_INLINE void nrf_lpcomp_task_trigger | ( | nrf_lpcomp_task_t | lpcomp_task | ) |

Function for setting a specific LPCOMP task.

Parameters

  [in] | lpcomp_task | LPCOMP task to be set.