ADC HAL
- group nrf_adc_hal
Hardware access layer for managing the Analog-to-Digital Converter (ADC) peripheral.
Typedefs
-
typedef uint16_t nrf_adc_value_t
Analog-to-digital value type.
Enums
-
enum nrf_adc_int_mask_t
ADC interrupts.
Values:
-
enumerator NRF_ADC_INT_END_MASK
ADC interrupt on END event.
-
enumerator NRF_ADC_INT_END_MASK
-
enum nrf_adc_config_resolution_t
Resolution of the analog-to-digital converter.
Values:
-
enumerator NRF_ADC_CONFIG_RES_8BIT
8-bit resolution.
-
enumerator NRF_ADC_CONFIG_RES_9BIT
9-bit resolution.
-
enumerator NRF_ADC_CONFIG_RES_10BIT
10-bit resolution.
-
enumerator NRF_ADC_CONFIG_RES_8BIT
-
enum nrf_adc_config_scaling_t
Scaling factor of the analog-to-digital conversion.
Values:
-
enumerator NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE
Full scale input.
-
enumerator NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS
2/3 scale input.
-
enumerator NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD
1/3 scale input.
-
enumerator NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS
2/3 of supply.
-
enumerator NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD
1/3 of supply.
-
enumerator NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE
-
enum nrf_adc_config_extref_t
External reference selection of the analog-to-digital converter.
Values:
-
enumerator NRF_ADC_CONFIG_EXTREFSEL_NONE
Analog reference inputs disabled.
-
enumerator NRF_ADC_CONFIG_EXTREFSEL_AREF0
AREF0 as analog reference.
-
enumerator NRF_ADC_CONFIG_EXTREFSEL_AREF1
AREF1 as analog reference.
-
enumerator NRF_ADC_CONFIG_EXTREFSEL_NONE
-
enum nrf_adc_config_reference_t
Reference selection of the analog-to-digital converter.
Values:
-
enumerator NRF_ADC_CONFIG_REF_VBG
1.2 V reference.
-
enumerator NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF
1/2 of power supply.
-
enumerator NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD
1/3 of power supply.
-
enumerator NRF_ADC_CONFIG_REF_EXT
External reference. See nrf_adc_config_extref_t for further configuration.
-
enumerator NRF_ADC_CONFIG_REF_VBG
-
enum nrf_adc_config_input_t
Input selection of the analog-to-digital converter.
Values:
-
enumerator NRF_ADC_CONFIG_INPUT_DISABLED
No input selected.
-
enumerator NRF_ADC_CONFIG_INPUT_0
Input 0.
-
enumerator NRF_ADC_CONFIG_INPUT_1
Input 1.
-
enumerator NRF_ADC_CONFIG_INPUT_2
Input 2.
-
enumerator NRF_ADC_CONFIG_INPUT_3
Input 3.
-
enumerator NRF_ADC_CONFIG_INPUT_4
Input 4.
-
enumerator NRF_ADC_CONFIG_INPUT_5
Input 5.
-
enumerator NRF_ADC_CONFIG_INPUT_6
Input 6.
-
enumerator NRF_ADC_CONFIG_INPUT_7
Input 7.
-
enumerator NRF_ADC_CONFIG_INPUT_DISABLED
Functions
-
NRF_STATIC_INLINE void nrf_adc_task_trigger(NRF_ADC_Type *p_reg, nrf_adc_task_t task)
Function for activating the specified ADC task.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task to be activated.
-
NRF_STATIC_INLINE uint32_t nrf_adc_task_address_get(NRF_ADC_Type const *p_reg, nrf_adc_task_t task)
Function for getting the address of an ADC task register.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] ADC task.
- Returns:
Address of the specified ADC task.
-
NRF_STATIC_INLINE bool nrf_adc_event_check(NRF_ADC_Type const *p_reg, nrf_adc_event_t event)
Function for retrieving the state of an ADC 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_adc_event_clear(NRF_ADC_Type *p_reg, nrf_adc_event_t event)
Function for clearing an ADC event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event to clear.
-
NRF_STATIC_INLINE uint32_t nrf_adc_event_address_get(NRF_ADC_Type const *p_reg, nrf_adc_event_t event)
Function for getting the address of the specified ADC event register.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] ADC event.
- Returns:
Address of the specified ADC event.
-
NRF_STATIC_INLINE void nrf_adc_int_enable(NRF_ADC_Type *p_reg, uint32_t mask)
Function for enabling the specified interrupts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be enabled.
-
NRF_STATIC_INLINE void nrf_adc_int_disable(NRF_ADC_Type *p_reg, uint32_t mask)
Function for disabling the specified interrupts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be disabled.
-
NRF_STATIC_INLINE uint32_t nrf_adc_int_enable_check(NRF_ADC_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.
- Returns:
Mask of enabled interrupts.
-
NRF_STATIC_INLINE bool nrf_adc_busy_check(NRF_ADC_Type const *p_reg)
Function for checking whether the ADC is busy.
This function checks whether the ADC converter is busy with a conversion.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Return values:
true – The ADC is busy.
false – The ADC is not busy.
-
NRF_STATIC_INLINE void nrf_adc_enable(NRF_ADC_Type *p_reg)
Function for enabling the ADC.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE void nrf_adc_disable(NRF_ADC_Type *p_reg)
Function for disabling the ADC.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
-
NRF_STATIC_INLINE bool nrf_adc_enable_check(NRF_ADC_Type const *p_reg)
Function for checking if the ADC is enabled.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Return values:
true – The ADC is enabled.
false – The ADC is not enabled.
-
NRF_STATIC_INLINE nrf_adc_value_t nrf_adc_result_get(NRF_ADC_Type const *p_reg)
Function for retrieving the ADC conversion result.
This function retrieves and returns the last analog-to-digital conversion result.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Returns:
Last conversion result.
-
NRF_STATIC_INLINE void nrf_adc_init(NRF_ADC_Type *p_reg, nrf_adc_config_t const *p_config)
Function for initializing the ADC.
This function writes data to ADC’s CONFIG register. After the configuration, the ADC is in DISABLE state and must be enabled before using it.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
p_config – [in] Configuration parameters.
-
struct nrf_adc_config_t
- #include <nrf_adc.h>
Analog-to-digital converter configuration.
Public Members
-
nrf_adc_config_resolution_t resolution
ADC resolution.
-
nrf_adc_config_scaling_t scaling
ADC scaling factor.
-
nrf_adc_config_reference_t reference
ADC reference.
-
nrf_adc_config_input_t input
ADC input selection.
-
nrf_adc_config_extref_t extref
ADC external reference selection.
-
nrf_adc_config_resolution_t resolution
-
typedef uint16_t nrf_adc_value_t