Comparator (COMP) peripheral driver.
More...
Comparator (COMP) peripheral driver.
◆ NRFX_COMP_CONFIG_TH
| #define NRFX_COMP_CONFIG_TH |
Value:{ \
}
#define NRFX_COMP_VOLTAGE_THRESHOLD_TO_INT(vol, ref)
Macro for converting the threshold voltage to an integer value (needed by the COMP_TH register).
Definition nrfx_comp.h:60
COMP threshold default configuration.
◆ NRFX_COMP_DEFAULT_CONFIG
| #define NRFX_COMP_DEFAULT_CONFIG |
( |
| _input | ) |
|
Value:{ \
.interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
#define NRF_COMP_HAS_ISOURCE
Symbol indicating whether COMP has ISOURCE register.
Definition nrf_comp.h:52
@ NRF_COMP_REF_INT_1V2
Definition nrf_comp.h:175
@ NRF_COMP_ISOURCE_OFF
Definition nrf_comp.h:259
@ NRF_COMP_MAIN_MODE_SE
Definition nrf_comp.h:226
@ NRF_COMP_HYST_NO_HYST
Definition nrf_comp.h:243
@ NRF_COMP_SP_MODE_HIGH
Definition nrf_comp.h:237
nrfx_analog_input_t
Generic analog input types.
Definition nrfx_analog_common.h:64
#define NRFX_COMP_CONFIG_TH
COMP threshold default configuration.
Definition nrfx_comp.h:87
COMP driver default configuration.
This configuration sets up COMP with the following options:
- single-ended mode
- reference voltage: internal 1.2 V
- lower threshold: 0.5 V
- upper threshold: 1.0 V
- high speed mode
- hysteresis disabled
- current source disabled
- Parameters
-
◆ NRFX_COMP_VOLTAGE_THRESHOLD_TO_INT
| #define NRFX_COMP_VOLTAGE_THRESHOLD_TO_INT |
( |
| vol, |
|
|
| ref ) |
Value: (uint8_t)(((vol) > ((ref) / 64)) ? (
NRFX_ROUNDED_DIV((vol) * 64,(ref)) - 1) : 0)
#define NRFX_ROUNDED_DIV(a, b)
Macro for performing rounded integer division (as opposed to truncating the result).
Definition nrfx_utils.h:483
Macro for converting the threshold voltage to an integer value (needed by the COMP_TH register).
- Parameters
-
| [in] | vol | Voltage to be changed to COMP_TH register value. This value must not be smaller than reference voltage divided by 64. |
| [in] | ref | Reference voltage. |
◆ nrfx_comp_event_handler_t
COMP event handler function type.
- Parameters
-
◆ nrfx_comp_event_address_get()
| NRFX_STATIC_INLINE uint32_t nrfx_comp_event_address_get |
( |
nrf_comp_event_t | event | ) |
|
Function for getting the address of a COMP event.
- Parameters
-
- Returns
- Address of the given COMP event.
◆ nrfx_comp_init()
Function for initializing the COMP driver.
This function initializes the COMP driver, but does not enable the peripheral or any interrupts. To start the driver, call the function nrfx_comp_start() after initialization.
- Parameters
-
| [in] | p_config | Pointer to the structure with the initial configuration. |
| [in] | event_handler | Event handler provided by the user. Must not be NULL. |
- Return values
-
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -EBUSY | The LPCOMP peripheral is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled. |
| -EINVAL | The analog input pin or external reference is invalid. |
◆ nrfx_comp_init_check()
| bool nrfx_comp_init_check |
( |
void | | ) |
|
Function for checking if the COMP driver is initialized.
- Return values
-
| true | Driver is already initialized. |
| false | Driver is not initialized. |
◆ nrfx_comp_pin_select()
Function for setting the analog input.
- Parameters
-
| [in] | psel | Generic analog pin selection. |
- Return values
-
| 0 | Setting the pin was successful. |
| -EINVAL | The analog input pin is invalid. |
◆ nrfx_comp_reconfigure()
Function for reconfiguring the COMP driver.
- Parameters
-
| [in] | p_config | Pointer to the structure with the configuration. |
- Return values
-
| 0 | Reconfiguration was successful. |
| -EBUSY | The driver is running and cannot be reconfigured. |
| -EINPROGRESS | The driver is uninitialized. |
| -EINVAL | The analog input pin or external reference is invalid. |
◆ nrfx_comp_sample()
| uint32_t nrfx_comp_sample |
( |
void | | ) |
|
Function for copying the current state of the comparator result to the RESULT register.
- Return values
-
| 0 | The input voltage is below the threshold (VIN+ < VIN-). |
| 1 | The input voltage is above the threshold (VIN+ > VIN-). |
◆ nrfx_comp_start()
| void nrfx_comp_start |
( |
uint32_t | comp_evt_en_mask, |
|
|
uint32_t | comp_shorts_mask ) |
Function for starting the COMP peripheral and interrupts.
Before calling this function, the driver must be initialized. This function enables the COMP peripheral and its interrupts.
- Parameters
-
| [in] | comp_evt_en_mask | Mask of events to be enabled. This parameter is to be built as an OR of elements from nrf_comp_int_mask_t. |
| [in] | comp_shorts_mask | Mask of shortcuts to be enabled. This parameter is to be built as an OR of elements from nrf_comp_short_mask_t. |
- See also
- nrfx_comp_init
◆ nrfx_comp_stop()
| void nrfx_comp_stop |
( |
void | | ) |
|
Function for stopping the COMP peripheral.
Before calling this function, the driver must be enabled. This function disables the COMP peripheral and its interrupts.
- See also
- nrfx_comp_uninit
◆ nrfx_comp_task_address_get()
| NRFX_STATIC_INLINE uint32_t nrfx_comp_task_address_get |
( |
nrf_comp_task_t | task | ) |
|
Function for getting the address of a COMP task.
- Parameters
-
- Returns
- Address of the given COMP task.
◆ nrfx_comp_uninit()
| void nrfx_comp_uninit |
( |
void | | ) |
|
Function for uninitializing the COMP driver.
This function uninitializes the COMP driver. The COMP peripheral and its interrupts are disabled, and local variables are cleaned. After this call, you must initialize the driver again by calling nrfx_comp_init() if you want to use it.
- See also
- nrfx_comp_stop