SAADC HALY

group nrfy_saadc

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

Functions

NRFY_STATIC_INLINE void nrfy_saadc_periph_configure(NRF_SAADC_Type *p_reg, nrfy_saadc_config_t const *p_config)

Function for configuring the SAADC.

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_saadc_int_init(NRF_SAADC_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified SAADC 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_saadc_int_uninit(NRF_SAADC_Type *p_reg)

Function for uninitializing the SAADC interrupts.

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

NRFY_STATIC_INLINE uint32_t nrfy_saadc_events_process(NRF_SAADC_Type *p_reg, uint32_t mask, nrfy_saadc_buffer_t const *p_desc)

Function for processing the specified SAADC 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().

  • p_desc[in] Pointer to the structure containing buffer associated with the last sampling. Can be NULL.

Returns:

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

NRFY_STATIC_INLINE void nrfy_saadc_channel_configure(NRF_SAADC_Type *p_reg, uint8_t channel, nrf_saadc_channel_config_t const *p_config, nrfy_saadc_channel_input_t const *p_input)

Function for configuring the specified SAADC channel.

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

  • channel[in] Channel number.

  • p_config[in] Pointer to the channel configuration structure. NULL if configuration is to be omitted.

  • p_input[in] Pointer to the channel input configuration structure. NULL if configuration is to be omitted.

NRFY_STATIC_INLINE void nrfy_saadc_buffer_set(NRF_SAADC_Type *p_reg, nrfy_saadc_buffer_t const *p_desc, bool latch, bool wait)

Function for setting the SAADC sampling buffer.

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

  • p_desc[in] Pointer to the structure containing sampling buffer description.

  • latch[in] True if buffer is to be latched, false otherwise.

  • wait[in] True if latching is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_saadc_buffer_latch(NRF_SAADC_Type *p_reg, bool wait)

Function for latching the SAADC sampling buffer.

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

  • wait[in] True if latching is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_saadc_sample_start(NRF_SAADC_Type *p_reg, nrfy_saadc_buffer_t const *p_desc)

Function for starting the SAADC sampling.

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

  • p_desc[in] Pointer to the structure containing sampling buffer if the sampling is to be blocking. NULL for non-blocking operation.

NRFY_STATIC_INLINE void nrfy_saadc_abort(NRF_SAADC_Type *p_reg, nrfy_saadc_buffer_t const *p_desc)

Function for aborting the ongoing SAADC sampling.

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

  • p_desc[in] Pointer to the structure containing sampling buffer if the abort is to be blocking. NULL for non-blocking operation.

NRFY_STATIC_INLINE void nrfy_saadc_stop(NRF_SAADC_Type *p_reg, bool wait)

Function for stopping the SAADC.

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

  • wait[in] True if stopping is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_saadc_calibrate(NRF_SAADC_Type *p_reg, bool wait)

Function for calibrating the SAADC.

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

  • wait[in] True if calibration is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_saadc_task_trigger(NRF_SAADC_Type *p_reg, nrf_saadc_task_t task)

See also

nrf_saadc_task_trigger Function for triggering the specified SAADC task.

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

  • task[in] SAADC task.

NRFY_STATIC_INLINE uint32_t nrfy_saadc_task_address_get(NRF_SAADC_Type const *p_reg, nrf_saadc_task_t task)

See also

nrf_saadc_task_address_get Function for getting the address of the specified SAADC task register.

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

  • task[in] SAADC task.

Returns:

Address of the specified SAADC task.

NRFY_STATIC_INLINE bool nrfy_saadc_event_check(NRF_SAADC_Type const *p_reg, nrf_saadc_event_t event)

See also

nrf_saadc_event_check Function for retrieving the state of the SAADC 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.

NRFY_STATIC_INLINE void nrfy_saadc_event_clear(NRF_SAADC_Type *p_reg, nrf_saadc_event_t event)

See also

nrf_saadc_event_clear Function for clearing the specific SAADC event.

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

  • event[in] SAADC event.

NRFY_STATIC_INLINE uint32_t nrfy_saadc_event_address_get(NRF_SAADC_Type const *p_reg, nrf_saadc_event_t event)

See also

nrf_saadc_event_address_get Function for getting the address of the specified SAADC event register.

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

  • event[in] SAADC event.

Returns:

Address of the specified SAADC event.

NRFY_STATIC_INLINE void nrfy_saadc_subscribe_set(NRF_SAADC_Type *p_reg, nrf_saadc_task_t task, uint8_t channel)

See also

nrf_saadc_subscribe_set Function for setting the subscribe configuration for a given SAADC task.

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

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRFY_STATIC_INLINE void nrfy_saadc_subscribe_clear(NRF_SAADC_Type *p_reg, nrf_saadc_task_t task)

See also

nrf_saadc_subscribe_clear Function for clearing the subscribe configuration for a given SAADC task.

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

  • task[in] Task for which to clear the configuration.

NRFY_STATIC_INLINE void nrfy_saadc_publish_set(NRF_SAADC_Type *p_reg, nrf_saadc_event_t event, uint8_t channel)

See also

nrf_saadc_publish_set Function for setting the publish configuration for a given SAADC event.

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

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRFY_STATIC_INLINE void nrfy_saadc_publish_clear(NRF_SAADC_Type *p_reg, nrf_saadc_event_t event)

See also

nrf_saadc_publish_clear Function for clearing the publish configuration for a given SAADC event.

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

  • event[in] Event for which to clear the configuration.

NRFY_STATIC_INLINE nrf_saadc_event_t nrfy_saadc_limit_event_get(uint8_t channel, nrf_saadc_limit_t limit_type)

See also

nrf_saadc_limit_event_get Function for getting the SAADC channel monitoring limit events.

Parameters:
  • channel[in] Channel number.

  • limit_type[in] Low limit or high limit.

Returns:

The SAADC channel monitoring limit event.

NRFY_STATIC_INLINE void nrfy_saadc_channel_input_set(NRF_SAADC_Type *p_reg, uint8_t channel, nrf_saadc_input_t pselp, nrf_saadc_input_t pseln)

See also

nrf_saadc_channel_input_set Function for configuring the input pins for the specified SAADC channel.

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

  • channel[in] Channel number.

  • pselp[in] Positive input.

  • pseln[in] Negative input. Set to NRF_SAADC_INPUT_DISABLED in single ended mode.

NRFY_STATIC_INLINE void nrfy_saadc_channel_pos_input_set(NRF_SAADC_Type *p_reg, uint8_t channel, nrf_saadc_input_t pselp)

See also

nrf_saadc_channel_pos_input_set Function for configuring the positive input pin for the specified SAADC channel.

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

  • channel[in] Channel number.

  • pselp[in] Positive input.

NRFY_STATIC_INLINE void nrfy_saadc_channel_limits_set(NRF_SAADC_Type *p_reg, uint8_t channel, int16_t low, int16_t high)

See also

nrf_saadc_channel_limits_set Function for setting the SAADC channel monitoring limits.

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

  • channel[in] Channel number.

  • low[in] Low limit.

  • high[in] High limit.

NRFY_STATIC_INLINE void nrfy_saadc_int_set(NRF_SAADC_Type *p_reg, uint32_t mask)

See also

nrf_saadc_int_set Function for setting the configuration of SAADC interrupts.

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

  • mask[in] Interrupts configuration to be set. Use nrf_saadc_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_saadc_int_enable(NRF_SAADC_Type *p_reg, uint32_t mask)

See also

nrf_saadc_int_enable Function for enabling specified SAADC interrupts.

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

  • mask[in] Mask of interrupts to be enabled. Use nrf_saadc_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_saadc_int_enable_check(NRF_SAADC_Type const *p_reg, uint32_t mask)

See also

nrf_saadc_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_saadc_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE void nrfy_saadc_int_disable(NRF_SAADC_Type *p_reg, uint32_t mask)

See also

nrf_saadc_int_disable Function for disabling specified interrupts.

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

  • mask[in] Mask of interrupts to be disabled. Use nrf_saadc_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_saadc_limit_int_get(uint8_t channel, nrf_saadc_limit_t limit_type)

See also

nrf_saadc_limit_int_get Function for generating masks for SAADC channel limit interrupts.

Parameters:
  • channel[in] SAADC channel number.

  • limit_type[in] Limit type.

Returns:

Interrupt mask.

NRFY_STATIC_INLINE bool nrfy_saadc_busy_check(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_busy_check Function for checking whether the SAADC is busy.

This function checks whether the analog-to-digital converter is busy with a conversion.

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

Return values:
  • true – The SAADC is busy.

  • false – The SAADC is not busy.

NRFY_STATIC_INLINE void nrfy_saadc_enable(NRF_SAADC_Type *p_reg)

See also

nrf_saadc_enable Function for enabling the SAADC.

The analog-to-digital converter must be enabled before use.

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

NRFY_STATIC_INLINE void nrfy_saadc_disable(NRF_SAADC_Type *p_reg)

See also

nrf_saadc_disable Function for disabling the SAADC.

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

NRFY_STATIC_INLINE bool nrfy_saadc_enable_check(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_enable_check Function for checking if the SAADC is enabled.

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

Return values:
  • true – The SAADC is enabled.

  • false – The SAADC is not enabled.

NRFY_STATIC_INLINE void nrfy_saadc_buffer_init(NRF_SAADC_Type *p_reg, nrf_saadc_value_t *p_buffer, uint32_t size)

See also

nrf_saadc_buffer_init Function for initializing the SAADC result buffer.

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

  • p_buffer[in] Pointer to the result buffer.

  • size[in] Size of the buffer (in 8-bit or 16-bit samples).

NRFY_STATIC_INLINE void nrfy_saadc_buffer_pointer_set(NRF_SAADC_Type *p_reg, nrf_saadc_value_t *p_buffer)

See also

nrf_saadc_buffer_pointer_set Function for setting the SAADC result buffer pointer.

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

  • p_buffer[in] Pointer to the result buffer.

NRFY_STATIC_INLINE nrf_saadc_value_t *nrfy_saadc_buffer_pointer_get(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_buffer_pointer_get Function for getting the SAADC result buffer pointer.

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

Returns:

Pointer to the result buffer.

NRFY_STATIC_INLINE uint16_t nrfy_saadc_amount_get(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_amount_get Function for getting the number of samples written to the result buffer since the previous START task.

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

Returns:

Number of 8-bit or 16-bit samples written to the buffer.

NRFY_STATIC_INLINE void nrfy_saadc_resolution_set(NRF_SAADC_Type *p_reg, nrf_saadc_resolution_t resolution)

See also

nrf_saadc_resolution_set Function for setting the SAADC sample resolution.

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

  • resolution[in] Bit resolution.

NRFY_STATIC_INLINE nrf_saadc_resolution_t nrfy_saadc_resolution_get(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_resolution_get Function for getting the SAADC sample resolution.

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

Returns:

Sample resolution.

NRFY_STATIC_INLINE void nrfy_saadc_oversample_set(NRF_SAADC_Type *p_reg, nrf_saadc_oversample_t oversample)

See also

nrf_saadc_oversample_set Function for configuring the oversampling feature.

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

  • oversample[in] Oversampling mode.

NRFY_STATIC_INLINE nrf_saadc_oversample_t nrfy_saadc_oversample_get(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_oversample_get Function for getting the oversampling feature configuration.

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

Returns:

Oversampling configuration.

NRFY_STATIC_INLINE uint32_t nrfy_saadc_oversample_sample_count_get(nrf_saadc_oversample_t oversample)

See also

nrf_saadc_oversample_sample_count_get Function for getting the sample count needed for one averaged result for a given oversampling configuration.

Parameters:
  • oversample[in] Oversampling configuration.

Returns:

Sample count.

NRFY_STATIC_INLINE void nrfy_saadc_continuous_mode_enable(NRF_SAADC_Type *p_reg, uint16_t cc)

See also

nrf_saadc_continuous_mode_enable Function for enabling the continuous sampling.

This function configures the SAADC internal timer to automatically take new samples at a fixed sample rate. Trigger the START task to begin continuous sampling. To stop the sampling, trigger the STOP task.

Note

The internal timer can only be used when a single input channel is enabled.

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

  • cc[in] Capture and compare value. Sample rate is 16 MHz/cc. Valid CC range is from 80 to 2047.

NRFY_STATIC_INLINE bool nrfy_saadc_continuous_mode_enable_check(NRF_SAADC_Type const *p_reg)

See also

nrf_saadc_continuous_mode_enable_check Function for checking if the continuous sampling is enabled.

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

Return values:
  • true – The continuous sampling is enabled.

  • false – The continuous sampling is disabled.

NRFY_STATIC_INLINE void nrfy_saadc_continuous_mode_disable(NRF_SAADC_Type *p_reg)

See also

nrf_saadc_continuous_mode_disable Function for disabling the continuous sampling.

New samples can still be acquired by manually triggering the SAMPLE task or by PPI.

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

NRFY_STATIC_INLINE void nrfy_saadc_channel_init(NRF_SAADC_Type *p_reg, uint8_t channel, nrf_saadc_channel_config_t const *config)

See also

nrf_saadc_channel_init Function for initializing the SAADC channel.

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

  • channel[in] Channel number.

  • config[in] Pointer to the channel configuration structure.

NRFY_STATIC_INLINE void nrfy_saadc_burst_set(NRF_SAADC_Type *p_reg, uint8_t channel, nrf_saadc_burst_t burst)

See also

nrf_saadc_burst_set Function for configuring the burst mode for the specified channel.

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

  • channel[in] Channel number.

  • burst[in] Burst mode setting.

NRFY_STATIC_INLINE int16_t nrfy_saadc_value_min_get(nrf_saadc_resolution_t resolution)

See also

nrf_saadc_value_min_get Function for getting the minimum value of the conversion result.

The minimum value of the conversion result depends on the configured resolution.

Parameters:
  • resolution[in] Bit resolution.

Returns:

Minimum value of the conversion result.

NRFY_STATIC_INLINE int16_t nrfy_saadc_value_max_get(nrf_saadc_resolution_t resolution)

See also

nrf_saadc_value_max_get Function for getting the maximum value of the conversion result.

The maximum value of the conversion result depends on the configured resolution.

Parameters:
  • resolution[in] Bit resolution.

Returns:

Maximum value of the conversion result.

struct nrfy_saadc_buffer_t
#include <nrfy_saadc.h>

Structure describing SAADC sampling buffer.

Public Members

nrf_saadc_value_t *p_buffer

Pointer to the sampling buffer.

size_t length

Sampling buffer length.

struct nrfy_saadc_config_t
#include <nrfy_saadc.h>

SAADC configuration structure.

Public Members

nrf_saadc_resolution_t resolution

Sampling resolution.

nrf_saadc_oversample_t oversampling

Oversampling setting.

struct nrfy_saadc_channel_input_t
#include <nrfy_saadc.h>

SAADC channel input configuration structure.

Public Members

nrf_saadc_input_t input_p

Positive input.

nrf_saadc_input_t input_n

Negative input.