nrfx 2.5
Data Structures | Typedefs | Enumerations | Functions
ADC HAL

Hardware access layer for managing the Analog-to-Digital Converter (ADC) peripheral. More...

Data Structures

struct  nrf_adc_config_t
 Analog-to-digital converter configuration. More...
 

Typedefs

typedef uint16_t nrf_adc_value_t
 Analog-to-digital value type.
 

Enumerations

enum  nrf_adc_int_mask_t { NRF_ADC_INT_END_MASK = ADC_INTENSET_END_Msk }
 ADC interrupts. More...
 
enum  nrf_adc_config_resolution_t {
  NRF_ADC_CONFIG_RES_8BIT = ADC_CONFIG_RES_8bit,
  NRF_ADC_CONFIG_RES_9BIT = ADC_CONFIG_RES_9bit,
  NRF_ADC_CONFIG_RES_10BIT = ADC_CONFIG_RES_10bit
}
 Resolution of the analog-to-digital converter. More...
 
enum  nrf_adc_config_scaling_t {
  NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE = ADC_CONFIG_INPSEL_AnalogInputNoPrescaling,
  NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS = ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling,
  NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling,
  NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS = ADC_CONFIG_INPSEL_SupplyTwoThirdsPrescaling,
  NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD = ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling
}
 Scaling factor of the analog-to-digital conversion. More...
 
enum  nrf_adc_config_extref_t {
  NRF_ADC_CONFIG_EXTREFSEL_NONE = ADC_CONFIG_EXTREFSEL_None,
  NRF_ADC_CONFIG_EXTREFSEL_AREF0 = ADC_CONFIG_EXTREFSEL_AnalogReference0,
  NRF_ADC_CONFIG_EXTREFSEL_AREF1 = ADC_CONFIG_EXTREFSEL_AnalogReference1
}
 External reference selection of the analog-to-digital converter. More...
 
enum  nrf_adc_config_reference_t {
  NRF_ADC_CONFIG_REF_VBG = ADC_CONFIG_REFSEL_VBG,
  NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF = ADC_CONFIG_REFSEL_SupplyOneHalfPrescaling,
  NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling,
  NRF_ADC_CONFIG_REF_EXT = ADC_CONFIG_REFSEL_External
}
 Reference selection of the analog-to-digital converter. More...
 
enum  nrf_adc_config_input_t {
  NRF_ADC_CONFIG_INPUT_DISABLED = ADC_CONFIG_PSEL_Disabled,
  NRF_ADC_CONFIG_INPUT_0 = ADC_CONFIG_PSEL_AnalogInput0,
  NRF_ADC_CONFIG_INPUT_1 = ADC_CONFIG_PSEL_AnalogInput1,
  NRF_ADC_CONFIG_INPUT_2 = ADC_CONFIG_PSEL_AnalogInput2,
  NRF_ADC_CONFIG_INPUT_3 = ADC_CONFIG_PSEL_AnalogInput3,
  NRF_ADC_CONFIG_INPUT_4 = ADC_CONFIG_PSEL_AnalogInput4,
  NRF_ADC_CONFIG_INPUT_5 = ADC_CONFIG_PSEL_AnalogInput5,
  NRF_ADC_CONFIG_INPUT_6 = ADC_CONFIG_PSEL_AnalogInput6,
  NRF_ADC_CONFIG_INPUT_7 = ADC_CONFIG_PSEL_AnalogInput7
}
 Input selection of the analog-to-digital converter. More...
 
enum  nrf_adc_task_t {
  NRF_ADC_TASK_START = offsetof(NRF_ADC_Type, TASKS_START),
  NRF_ADC_TASK_STOP = offsetof(NRF_ADC_Type, TASKS_STOP)
}
 Analog-to-digital converter tasks. More...
 
enum  nrf_adc_event_t { NRF_ADC_EVENT_END = offsetof(NRF_ADC_Type, EVENTS_END) }
 Analog-to-digital converter events. More...
 

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. More...
 
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. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_adc_event_clear (NRF_ADC_Type *p_reg, nrf_adc_event_t event)
 Function for clearing an ADC event. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_adc_int_enable (NRF_ADC_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupts. More...
 
NRF_STATIC_INLINE void nrf_adc_int_disable (NRF_ADC_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
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. More...
 
NRF_STATIC_INLINE bool nrf_adc_busy_check (NRF_ADC_Type const *p_reg)
 Function for checking whether the ADC is busy. More...
 
NRF_STATIC_INLINE void nrf_adc_enable (NRF_ADC_Type *p_reg)
 Function for enabling the ADC. More...
 
NRF_STATIC_INLINE void nrf_adc_disable (NRF_ADC_Type *p_reg)
 Function for disabling the ADC. More...
 
NRF_STATIC_INLINE bool nrf_adc_enable_check (NRF_ADC_Type const *p_reg)
 Function for checking if the ADC is enabled. More...
 
NRF_STATIC_INLINE nrf_adc_value_t nrf_adc_result_get (NRF_ADC_Type const *p_reg)
 Function for retrieving the ADC conversion result. More...
 
NRF_STATIC_INLINE void nrf_adc_init (NRF_ADC_Type *p_reg, nrf_adc_config_t const *p_config)
 Function for initializing the ADC. More...
 

Detailed Description

Hardware access layer for managing the Analog-to-Digital Converter (ADC) peripheral.

Enumeration Type Documentation

◆ nrf_adc_config_extref_t

External reference selection of the analog-to-digital converter.

Enumerator
NRF_ADC_CONFIG_EXTREFSEL_NONE 

Analog reference inputs disabled.

NRF_ADC_CONFIG_EXTREFSEL_AREF0 

AREF0 as analog reference.

NRF_ADC_CONFIG_EXTREFSEL_AREF1 

AREF1 as analog reference.

◆ nrf_adc_config_input_t

Input selection of the analog-to-digital converter.

Enumerator
NRF_ADC_CONFIG_INPUT_DISABLED 

No input selected.

NRF_ADC_CONFIG_INPUT_0 

Input 0.

NRF_ADC_CONFIG_INPUT_1 

Input 1.

NRF_ADC_CONFIG_INPUT_2 

Input 2.

NRF_ADC_CONFIG_INPUT_3 

Input 3.

NRF_ADC_CONFIG_INPUT_4 

Input 4.

NRF_ADC_CONFIG_INPUT_5 

Input 5.

NRF_ADC_CONFIG_INPUT_6 

Input 6.

NRF_ADC_CONFIG_INPUT_7 

Input 7.

◆ nrf_adc_config_reference_t

Reference selection of the analog-to-digital converter.

Enumerator
NRF_ADC_CONFIG_REF_VBG 

1.2 V reference.

NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF 

1/2 of power supply.

NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD 

1/3 of power supply.

NRF_ADC_CONFIG_REF_EXT 

External reference. See nrf_adc_config_extref_t for further configuration.

◆ nrf_adc_config_resolution_t

Resolution of the analog-to-digital converter.

Enumerator
NRF_ADC_CONFIG_RES_8BIT 

8-bit resolution.

NRF_ADC_CONFIG_RES_9BIT 

9-bit resolution.

NRF_ADC_CONFIG_RES_10BIT 

10-bit resolution.

◆ nrf_adc_config_scaling_t

Scaling factor of the analog-to-digital conversion.

Enumerator
NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE 

Full scale input.

NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS 

2/3 scale input.

NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD 

1/3 scale input.

NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS 

2/3 of supply.

NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD 

1/3 of supply.

◆ nrf_adc_event_t

Analog-to-digital converter events.

Enumerator
NRF_ADC_EVENT_END 

End of a conversion event.

◆ nrf_adc_int_mask_t

ADC interrupts.

Enumerator
NRF_ADC_INT_END_MASK 

ADC interrupt on END event.

◆ nrf_adc_task_t

Analog-to-digital converter tasks.

Enumerator
NRF_ADC_TASK_START 

ADC start sampling task.

NRF_ADC_TASK_STOP 

ADC stop sampling task.

Function Documentation

◆ nrf_adc_busy_check()

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
[in]p_regPointer to the structure of registers of the peripheral.
Return values
trueThe ADC is busy.
falseThe ADC is not busy.

◆ nrf_adc_disable()

NRF_STATIC_INLINE void nrf_adc_disable ( NRF_ADC_Type *  p_reg)

Function for disabling the ADC.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_adc_enable()

NRF_STATIC_INLINE void nrf_adc_enable ( NRF_ADC_Type *  p_reg)

Function for enabling the ADC.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_adc_enable_check()

NRF_STATIC_INLINE bool nrf_adc_enable_check ( NRF_ADC_Type const *  p_reg)

Function for checking if the ADC is enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Return values
trueThe ADC is enabled.
falseThe ADC is not enabled.

◆ nrf_adc_event_address_get()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventADC event.
Returns
Address of the specified ADC event.

◆ nrf_adc_event_check()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_adc_event_clear()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to clear.

◆ nrf_adc_init()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_configConfiguration parameters.

◆ nrf_adc_int_disable()

NRF_STATIC_INLINE void nrf_adc_int_disable ( NRF_ADC_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled.

◆ nrf_adc_int_enable()

NRF_STATIC_INLINE void nrf_adc_int_enable ( NRF_ADC_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled.

◆ nrf_adc_int_enable_check()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked.
Returns
Mask of enabled interrupts.

◆ nrf_adc_result_get()

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
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Last conversion result.

◆ nrf_adc_task_address_get()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskADC task.
Returns
Address of the specified ADC task.

◆ nrf_adc_task_trigger()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask to be activated.

Documentation feedback | Developer Zone | Subscribe | Updated