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:28
COMP threshold default configuration.
◆ NRFX_COMP_DEFAULT_CONFIG
#define NRFX_COMP_DEFAULT_CONFIG |
( |
|
_input | ) |
|
Value:{ \
.interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
uint32_t nrf_comp_input_t
COMP analog pin selection.
Definition: nrf_comp.h:35
#define NRF_COMP_HAS_ISOURCE
Symbol indicating whether COMP has ISOURCE register.
Definition: nrf_comp.h:21
@ NRF_COMP_REF_INT_1V2
Definition: nrf_comp.h:67
@ NRF_COMP_MAIN_MODE_SE
Definition: nrf_comp.h:118
@ NRF_COMP_HYST_NO_HYST
Definition: nrf_comp.h:135
@ NRF_COMP_SP_MODE_HIGH
Definition: nrf_comp.h:129
@ NRF_COMP_ISOURCE_OFF
Definition: nrf_comp.h:148
#define NRFX_COMP_CONFIG_TH
COMP threshold default configuration.
Definition: nrfx_comp.h:72
COMP driver default configuration.
This configuration sets up COMP with the following options:
- single-ended mode
- reference voltage: internal 1.8 V
- lower threshold: 0.5 V
- upper threshold: 1.5 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 |
|
) |
| (uint8_t)(((vol) > ((ref) / 64)) ? (NRFX_ROUNDED_DIV((vol) * 64,(ref)) - 1) : 0) |
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_evt_en_mask_t
COMP events masks.
Enumerator |
---|
NRFX_COMP_EVT_EN_CROSS_MASK | CROSS event (generated after VIN+ == VIN-).
|
NRFX_COMP_EVT_EN_UP_MASK | UP event (generated when VIN+ crosses VIN- while increasing).
|
NRFX_COMP_EVT_EN_DOWN_MASK | DOWN event (generated when VIN+ crosses VIN- while decreasing).
|
NRFX_COMP_EVT_EN_READY_MASK | READY event (generated when the module is ready).
|
◆ nrfx_comp_short_mask_t
COMP shortcut masks.
Enumerator |
---|
NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT | Shortcut between the CROSS event and the STOP task.
|
NRFX_COMP_SHORT_STOP_AFTER_UP_EVT | Shortcut between the UP event and the STOP task.
|
NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT | Shortcut between the DOWN event and the STOP task.
|
◆ 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
-
NRFX_SUCCESS | Initialization was successful. |
NRFX_ERROR_ALREADY | The driver is already initialized. |
NRFX_ERROR_INVALID_STATE | The driver is already initialized. Deprecated - use NRFX_ERROR_ALREADY instead. |
NRFX_ERROR_BUSY | The LPCOMP peripheral is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled. |
◆ 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 | COMP analog pin selection. |
◆ nrfx_comp_reconfigure()
Function for reconfiguring the COMP driver.
- Parameters
-
[in] | p_config | Pointer to the structure with the configuration. |
- Return values
-
NRFX_SUCCESS | Reconfiguration was successful. |
NRFX_ERROR_BUSY | The driver is running and cannot be reconfigured. |
NRFX_ERROR_INVALID_STATE | The driver is uninitialized. |
◆ 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 nrfx_comp_evt_en_mask_t. |
[in] | comp_shorts_mask | Mask of shortcuts to be enabled. This parameter is to be built as an OR of elements from nrfx_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