PDM HALY

group nrfy_pdm

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

Functions

NRFY_STATIC_INLINE void nrfy_pdm_periph_configure(NRF_PDM_Type *p_reg, nrfy_pdm_config_t const *p_config)

Function for configuring the PDM.

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

Function for initializing the specified PDM 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_pdm_int_uninit(NRF_PDM_Type *p_reg)

Function for uninitializing the PDM interrupts.

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

NRFY_STATIC_INLINE uint32_t nrfy_pdm_events_process(NRF_PDM_Type *p_reg, uint32_t mask, nrfy_pdm_buffer_t *p_buffer)

Function for processing the specified PDM 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_buffer[in] Pointer to the structure containing buffer associated with the last reception. 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_pdm_buffer_set(NRF_PDM_Type *p_reg, nrfy_pdm_buffer_t const *p_buffer)

Function for setting the PDM sampling buffer.

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

  • p_buffer[in] Pointer to the structure containing reception buffer.

NRFY_STATIC_INLINE void nrfy_pdm_start(NRF_PDM_Type *p_reg, nrfy_pdm_buffer_t const *p_buffer)

Function for starting the PDM sampling.

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

  • p_buffer[in] Pointer to the structure containing reception buffer if the reception is to be blocking. NULL for non-blocking receptions.

NRFY_STATIC_INLINE void nrfy_pdm_abort(NRF_PDM_Type *p_reg, nrfy_pdm_buffer_t const *p_buffer)

Function for aborting PDM transaction.

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

  • p_buffer[in] Pointer to the structure containing reception buffer if the reception is to be blocking. NULL for non-blocking receptions.

NRFY_STATIC_INLINE void nrfy_pdm_pins_set(NRF_PDM_Type *p_reg, nrfy_pdm_pins_t *p_pins)

Function for setting the PDM pins configuration.

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

  • p_pins[out] Pointer to the PDM pin configurartion structure.

NRFY_STATIC_INLINE void nrfy_pdm_pins_get(NRF_PDM_Type const *p_reg, nrfy_pdm_pins_t *p_pins)

Function for getting the PDM pins configuration.

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

  • p_pins[out] Pointer to the structure to be filled with PDM pins configuration.

NRFY_STATIC_INLINE void nrfy_pdm_task_trigger(NRF_PDM_Type *p_reg, nrf_pdm_task_t task)

See also

nrf_pdm_task_trigger Function for triggering a PDM task.

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

  • task[in] PDM task.

NRFY_STATIC_INLINE uint32_t nrfy_pdm_task_address_get(NRF_PDM_Type const *p_reg, nrf_pdm_task_t task)

See also

nrf_pdm_task_address_get Function for getting the address of a PDM task register.

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

  • task[in] PDM task.

Returns:

Address of the specified PDM task.

NRFY_STATIC_INLINE bool nrfy_pdm_event_check(NRF_PDM_Type const *p_reg, nrf_pdm_event_t event)

See also

nrf_pdm_event_check Function for retrieving the state of the PDM 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_pdm_event_clear(NRF_PDM_Type *p_reg, nrf_pdm_event_t event)

See also

nrf_pdm_event_clear Function for clearing a PDM event.

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

  • event[in] PDM event.

NRFY_STATIC_INLINE uint32_t nrfy_pdm_event_address_get(NRF_PDM_Type const *p_reg, nrf_pdm_event_t event)

See also

nrf_pdm_event_address_get Function for getting the address of a PDM event register.

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

  • event[in] PDM event.

Returns:

Address of the specified PDM event.

NRFY_STATIC_INLINE void nrfy_pdm_int_enable(NRF_PDM_Type *p_reg, uint32_t mask)

See also

nrf_pdm_int_enable Function for enabling PDM interrupts.

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

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

NRFY_STATIC_INLINE uint32_t nrfy_pdm_int_enable_check(NRF_PDM_Type const *p_reg, uint32_t mask)

See also

nrf_pdm_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_pdm_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE void nrfy_pdm_int_disable(NRF_PDM_Type *p_reg, uint32_t mask)

See also

nrf_pdm_int_disable Function for disabling interrupts.

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

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

NRFY_STATIC_INLINE void nrfy_pdm_subscribe_set(NRF_PDM_Type *p_reg, nrf_pdm_task_t task, uint8_t channel)

See also

nrf_pdm_subscribe_set Function for setting the subscribe configuration for a given PDM 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_pdm_subscribe_clear(NRF_PDM_Type *p_reg, nrf_pdm_task_t task)

See also

nrf_pdm_subscribe_clear Function for clearing the subscribe configuration for a given PDM 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_pdm_publish_set(NRF_PDM_Type *p_reg, nrf_pdm_event_t event, uint8_t channel)

See also

nrf_pdm_publish_set Function for setting the publish configuration for a given PDM 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_pdm_publish_clear(NRF_PDM_Type *p_reg, nrf_pdm_event_t event)

See also

nrf_pdm_publish_clear Function for clearing the publish configuration for a given PDM 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 void nrfy_pdm_enable(NRF_PDM_Type *p_reg)

See also

nrf_pdm_enable Function for enabling the PDM peripheral.

The PDM peripheral must be enabled before use.

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

NRFY_STATIC_INLINE void nrfy_pdm_disable(NRF_PDM_Type *p_reg)

See also

nrf_pdm_disable Function for disabling the PDM peripheral.

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

NRFY_STATIC_INLINE bool nrfy_pdm_enable_check(NRF_PDM_Type const *p_reg)

See also

nrf_pdm_enable_check Function for checking if the PDM peripheral is enabled.

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

Return values:
  • true – The PDM peripheral is enabled.

  • false – The PDM peripheral is not enabled.

NRFY_STATIC_INLINE void nrfy_pdm_mode_set(NRF_PDM_Type *p_reg, nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge)

See also

nrf_pdm_mode_set Function for setting the PDM operation mode.

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

  • pdm_mode[in] PDM operation mode.

  • pdm_edge[in] PDM sampling mode.

NRFY_STATIC_INLINE void nrfy_pdm_mode_get(NRF_PDM_Type const *p_reg, nrf_pdm_mode_t *p_pdm_mode, nrf_pdm_edge_t *p_pdm_edge)

See also

nrf_pdm_mode_get Function for getting the PDM operation mode.

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

  • p_pdm_mode[out] PDM operation mode.

  • p_pdm_edge[out] PDM sampling mode.

NRFY_STATIC_INLINE void nrfy_pdm_clock_set(NRF_PDM_Type *p_reg, nrf_pdm_freq_t pdm_freq)

See also

nrf_pdm_clock_set Function for setting the PDM clock frequency.

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

  • pdm_freq[in] PDM clock frequency.

NRFY_STATIC_INLINE nrf_pdm_freq_t nrfy_pdm_clock_get(NRF_PDM_Type const *p_reg)

See also

nrf_pdm_clock_get Function for getting the PDM clock frequency.

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

Returns:

PDM clock frequency.

NRFY_STATIC_INLINE void nrfy_pdm_pin_disconnect(NRF_PDM_Type *p_reg)

See also

nrf_pdm_psel_disconnect Function for disconnecting the PDM pins.

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

NRFY_STATIC_INLINE void nrfy_pdm_gain_set(NRF_PDM_Type *p_reg, nrf_pdm_gain_t gain_l, nrf_pdm_gain_t gain_r)

See also

nrf_pdm_gain_set Function for setting the PDM gain.

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

  • gain_l[in] Left channel gain.

  • gain_r[in] Right channel gain.

NRFY_STATIC_INLINE void nrfy_pdm_gain_get(NRF_PDM_Type const *p_reg, nrf_pdm_gain_t *p_gain_l, nrf_pdm_gain_t *p_gain_r)

See also

nrf_pdm_gain_get Function for getting the PDM gain.

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

  • p_gain_l[out] Left channel gain.

  • p_gain_r[out] Right channel gain.

NRFY_STATIC_INLINE uint32_t *nrfy_pdm_buffer_get(NRF_PDM_Type const *p_reg)

See also

nrf_pdm_buffer_get Function for getting the current PDM sample buffer address.

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

Returns:

Pointer to the current sample buffer.

struct nrfy_pdm_buffer_t
#include <nrfy_pdm.h>

Structure describing reception buffer.

Public Members

int16_t *p_buff

Pointer to the data buffer.

uint16_t length

Data buffer lenght.

struct nrfy_pdm_pins_t
#include <nrfy_pdm.h>

PDM pins configuration structure.

Public Members

uint32_t clk_pin

CLK pin number.

uint32_t din_pin

DIN pin number.

struct nrfy_pdm_config_t
#include <nrfy_pdm.h>

PDM configuration structure.

Public Members

nrf_pdm_mode_t mode

Interface operation mode.

nrf_pdm_edge_t edge

Sampling mode.

nrfy_pdm_pins_t pins

Pin configuration structure.

nrf_pdm_freq_t clock_freq

Clock frequency.

nrf_pdm_gain_t gain_l

Left channel gain.

nrf_pdm_gain_t gain_r

Right channel gain.

bool skip_psel_cfg

Skip pin selection configuration.

When set to true, the driver does not modify pin select registers in the peripheral. Those registers are supposed to be set up externally before the driver is initialized.

Note

When both GPIO configuration and pin selection are to be skipped, the structure fields that specify pins can be omitted, as they are ignored anyway.