COMP HALY

group nrfy_comp

Hardware access layer with cache and barrier support for managing the COMP peripheral.

Defines

NRFY_COMP_HAS_ISOURCE

See also

NRF_COMP_HAS_ISOURCE Symbol indicating whether COMP has ISOURCE register.

Functions

NRFY_STATIC_INLINE void nrfy_comp_periph_configure(NRF_COMP_Type *p_reg, nrfy_comp_config_t const *p_config)

Function for configuring the COMP.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_config[in] Pointer to the peripheral configuration structure.

NRFY_STATIC_INLINE void nrfy_comp_int_init(NRF_COMP_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified COMP interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be initialized.

  • irq_priority[in] Interrupt priority.

  • enable[in] True if the interrupts are to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_comp_int_uninit(NRF_COMP_Type *p_reg)

Function for uninitializing the COMP interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_comp_events_process(NRF_COMP_Type *p_reg, uint32_t mask)

Function for processing the specified COMP events.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of events to be processed, created by NRFY_EVENT_TO_INT_BITMASK().

Returns:

Mask of events that were generated and processed. To be checked against the result of NRFY_EVENT_TO_INT_BITMASK().

NRFY_STATIC_INLINE uint32_t nrfy_comp_sample(NRF_COMP_Type *p_reg)

Function for reading the current state of the COMP.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • 0 – The input voltage is below the threshold.

  • 1 – The input voltage is above the threshold.

NRFY_STATIC_INLINE void nrfy_comp_enable(NRF_COMP_Type *p_reg)

See also

nrf_comp_enable Function for enabling the COMP peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE void nrfy_comp_disable(NRF_COMP_Type *p_reg)

See also

nrf_comp_disable Function for disabling the COMP peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE bool nrfy_comp_enable_check(NRF_COMP_Type const *p_reg)

See also

nrf_comp_enable_check Function for checking if the COMP peripheral is enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – The COMP peripheral is enabled.

  • false – The COMP peripheral is not enabled.

NRFY_STATIC_INLINE void nrfy_comp_ref_set(NRF_COMP_Type *p_reg, nrf_comp_ref_t reference)

See also

nrf_comp_ref_set Function for setting the reference source.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • reference[in] COMP reference selection.

NRFY_STATIC_INLINE void nrfy_comp_ext_ref_set(NRF_COMP_Type *p_reg, nrf_comp_ext_ref_t ext_ref)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_th_set(NRF_COMP_Type *p_reg, nrf_comp_th_t threshold)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_main_mode_set(NRF_COMP_Type *p_reg, nrf_comp_main_mode_t main_mode)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_speed_mode_set(NRF_COMP_Type *p_reg, nrf_comp_sp_mode_t speed_mode)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_hysteresis_set(NRF_COMP_Type *p_reg, nrf_comp_hyst_t hyst)

See also

nrf_comp_hysteresis_set Function for setting the hysteresis.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • hyst[in] COMP comparator hysteresis.

NRFY_STATIC_INLINE void nrfy_comp_isource_set(NRF_COMP_Type *p_reg, nrf_isource_t isource)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_input_select(NRF_COMP_Type *p_reg, nrf_comp_input_t input)

See also

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

NRFY_STATIC_INLINE uint32_t nrfy_comp_result_get(NRF_COMP_Type const *p_reg)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_int_enable(NRF_COMP_Type *p_reg, uint32_t mask)

See also

nrf_comp_int_enable 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. Use nrf_comp_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_comp_int_disable(NRF_COMP_Type *p_reg, uint32_t mask)

See also

nrf_comp_int_disable 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. Use nrf_comp_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_comp_int_enable_check(NRF_COMP_Type const *p_reg, uint32_t mask)

See also

nrf_comp_int_enable_check 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_comp_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE uint32_t nrfy_comp_task_address_get(NRF_COMP_Type const *p_reg, nrf_comp_task_t task)

See also

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

NRFY_STATIC_INLINE uint32_t nrfy_comp_event_address_get(NRF_COMP_Type const *p_reg, nrf_comp_event_t event)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_shorts_enable(NRF_COMP_Type *p_reg, uint32_t mask)

See also

nrf_comp_shorts_enable Function for setting COMP shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of shortcuts.

NRFY_STATIC_INLINE void nrfy_comp_shorts_disable(NRF_COMP_Type *p_reg, uint32_t mask)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_task_trigger(NRF_COMP_Type *p_reg, nrf_comp_task_t task)

See also

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

NRFY_STATIC_INLINE void nrfy_comp_event_clear(NRF_COMP_Type *p_reg, nrf_comp_event_t event)

See also

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

NRFY_STATIC_INLINE bool nrfy_comp_event_check(NRF_COMP_Type const *p_reg, nrf_comp_event_t event)

See also

nrf_comp_event_check Function for retrieving the state of the COMP 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.

struct nrfy_comp_config_t
#include <nrfy_comp.h>

COMP configuration structure.

Public Members

nrf_comp_ref_t reference

Reference selection.

nrf_comp_ext_ref_t ext_ref

External analog reference selection.

nrf_comp_main_mode_t main_mode

Main operation mode.

nrf_comp_th_t threshold

Structure holding THDOWN and THUP values needed by the COMP_TH register.

nrf_comp_sp_mode_t speed_mode

Speed and power mode.

nrf_comp_hyst_t hyst

Comparator hysteresis.

nrf_isource_t isource

Current source selected on analog input.

nrf_comp_input_t input

Input to be monitored.