nrfx 2.5
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
PDM driver

Pulse Density Modulation (PDM) peripheral driver. More...

Modules

 PDM peripheral driver configuration
 

Data Structures

struct  nrfx_pdm_evt_t
 PDM event structure. More...
 
struct  nrfx_pdm_config_t
 PDM interface driver configuration structure. More...
 

Macros

#define NRFX_PDM_MAX_BUFFER_SIZE   32767
 Maximum supported PDM buffer size.
 
#define NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG   .ratio = NRF_PDM_RATIO_64X,
 PDM additional ratio configuration.
 
#define NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG   .mclksrc = NRF_PDM_MCLKSRC_PCLK32M,
 PDM additional master clock source configuration.
 
#define NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din)
 PDM driver default configuration. More...
 

Typedefs

typedef void(* nrfx_pdm_event_handler_t) (nrfx_pdm_evt_t const *p_evt)
 Handler for the PDM interface ready events. More...
 

Enumerations

enum  nrfx_pdm_error_t {
  NRFX_PDM_NO_ERROR = 0,
  NRFX_PDM_ERROR_OVERFLOW = 1
}
 PDM error type. More...
 

Functions

nrfx_err_t nrfx_pdm_init (nrfx_pdm_config_t const *p_config, nrfx_pdm_event_handler_t event_handler)
 Function for initializing the PDM interface. More...
 
void nrfx_pdm_uninit (void)
 Function for uninitializing the PDM interface. More...
 
NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get (nrf_pdm_task_t task)
 Function for getting the address of a PDM interface task. More...
 
NRFX_STATIC_INLINE bool nrfx_pdm_enable_check (void)
 Function for getting the state of the PDM interface. More...
 
nrfx_err_t nrfx_pdm_start (void)
 Function for starting the PDM sampling. More...
 
nrfx_err_t nrfx_pdm_stop (void)
 Function for stopping the PDM sampling. More...
 
nrfx_err_t nrfx_pdm_buffer_set (int16_t *buffer, uint16_t buffer_length)
 Function for supplying the sample buffer. More...
 

Detailed Description

Pulse Density Modulation (PDM) peripheral driver.

Macro Definition Documentation

◆ NRFX_PDM_DEFAULT_CONFIG

#define NRFX_PDM_DEFAULT_CONFIG (   _pin_clk,
  _pin_din 
)
Value:
{ \
.mode = NRF_PDM_MODE_MONO, \
.pin_clk = _pin_clk, \
.pin_din = _pin_din, \
.clock_freq = NRF_PDM_FREQ_1032K, \
.gain_l = NRF_PDM_GAIN_DEFAULT, \
.gain_r = NRF_PDM_GAIN_DEFAULT, \
.interrupt_priority = NRFX_PDM_DEFAULT_CONFIG_IRQ_PRIORITY, \
NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG \
NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG \
}
PDM_CLK = 1.032 MHz.
Definition: nrf_pdm.h:74
Left (or mono) is sampled on falling edge of PDM_CLK.
Definition: nrf_pdm.h:107
Sample and store two successive Left samples (16 bit each) per RAM word.
Definition: nrf_pdm.h:101
#define NRF_PDM_GAIN_DEFAULT
Default value of PDM gain.
Definition: nrf_pdm.h:39

PDM driver default configuration.

This configuration sets up PDM with the following options:

  • mono mode
  • data sampled on the clock falling edge
  • frequency: 1.032 MHz
  • standard gain
Parameters
[in]_pin_clkCLK output pin.
[in]_pin_dinDIN input pin.

Typedef Documentation

◆ nrfx_pdm_event_handler_t

typedef void(* nrfx_pdm_event_handler_t) (nrfx_pdm_evt_t const *p_evt)

Handler for the PDM interface ready events.

This event handler is called on a buffer request, an error or when a buffer is full and ready to be processed.

Parameters
[in]p_evtPointer to the PDM event structure.

Enumeration Type Documentation

◆ nrfx_pdm_error_t

PDM error type.

Enumerator
NRFX_PDM_NO_ERROR 

No error.

NRFX_PDM_ERROR_OVERFLOW 

Overflow error.

Function Documentation

◆ nrfx_pdm_buffer_set()

nrfx_err_t nrfx_pdm_buffer_set ( int16_t *  buffer,
uint16_t  buffer_length 
)

Function for supplying the sample buffer.

Call this function after every buffer request event.

Parameters
[in]bufferPointer to the receive buffer. Cannot be NULL.
[in]buffer_lengthLength of the receive buffer in 16-bit words.
Return values
NRFX_SUCCESSThe buffer was applied successfully.
NRFX_ERROR_BUSYThe buffer was already supplied or the peripheral is currently being stopped.
NRFX_ERROR_INVALID_STATEThe driver was not initialized.
NRFX_ERROR_INVALID_PARAMInvalid parameters were provided.

◆ nrfx_pdm_enable_check()

NRFX_STATIC_INLINE bool nrfx_pdm_enable_check ( void  )

Function for getting the state of the PDM interface.

Return values
trueThe PDM interface is enabled.
falseThe PDM interface is disabled.

◆ nrfx_pdm_init()

nrfx_err_t nrfx_pdm_init ( nrfx_pdm_config_t const *  p_config,
nrfx_pdm_event_handler_t  event_handler 
)

Function for initializing the PDM interface.

Parameters
[in]p_configPointer to the structure with the initial configuration.
[in]event_handlerEvent handler provided by the user. Cannot be NULL.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_INVALID_STATEThe driver is already initialized.
NRFX_ERROR_INVALID_PARAMInvalid configuration was specified.

◆ nrfx_pdm_start()

nrfx_err_t nrfx_pdm_start ( void  )

Function for starting the PDM sampling.

Return values
NRFX_SUCCESSSampling was started successfully or was already in progress.
NRFX_ERROR_BUSYPrevious start/stop operation is in progress.

◆ nrfx_pdm_stop()

nrfx_err_t nrfx_pdm_stop ( void  )

Function for stopping the PDM sampling.

When this function is called, the PDM interface is stopped after finishing the current frame. The event handler function might be called once more after calling this function.

Return values
NRFX_SUCCESSSampling was stopped successfully or was already stopped before.
NRFX_ERROR_BUSYPrevious start/stop operation is in progress.

◆ nrfx_pdm_task_address_get()

NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get ( nrf_pdm_task_t  task)

Function for getting the address of a PDM interface task.

Parameters
[in]taskTask.
Returns
Task address.

◆ nrfx_pdm_uninit()

void nrfx_pdm_uninit ( void  )

Function for uninitializing the PDM interface.

This function stops PDM sampling, if it is in progress.


Documentation feedback | Developer Zone | Subscribe | Updated