PDM driver

nRF5 SDK v15.0.0

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

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
#define NRFX_PDM_DEFAULT_CONFIG (_pin_clk, _pin_din)
Macro for setting nrfx_pdm_config_t to default settings in single ended mode. More...

Typedefs

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

Enumerations

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

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...
__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...
__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 PDM sampling. More...
nrfx_err_t nrfx_pdm_stop (void)
Function for stopping PDM sampling. More...
nrfx_err_t nrfx_pdm_buffer_set (int16_t *buffer, uint16_t buffer_length)
Function for supplying the sample buffer. More...
void nrfx_pdm_irq_handler (void)

Detailed Description

Pulse Density Modulation (PDM) peripheral driver.

Macro Definition Documentation

#define NRFX_PDM_DEFAULT_CONFIG ( _pin_clk,
_pin_din
)
Value:
{ \
.pin_clk = _pin_clk, \
.pin_din = _pin_din, \
.gain_l = NRF_PDM_GAIN_DEFAULT, \
.gain_r = NRF_PDM_GAIN_DEFAULT, \
.interrupt_priority = NRFX_PDM_CONFIG_IRQ_PRIORITY \
}

Macro for setting nrfx_pdm_config_t to default settings in single ended mode.

Parameters
_pin_clk CLK output pin.
_pin_din DIN input pin.

Typedef Documentation

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

Handler for 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_evt Pointer to the PDM event structure.

Function Documentation

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] buffer Pointer to the receive buffer. Cannot be NULL.
[in] buffer_length Length of the receive buffer in 16-bit words.
Return values
NRFX_SUCCESS If the buffer was applied successfully.
NRFX_ERROR_BUSY If the buffer was already supplied or the peripheral is currently being stopped.
NRFX_ERROR_INVALID_STATE If the driver was not initialized.
NRFX_ERROR_INVALID_PARAM If invalid parameters were provided.
__STATIC_INLINE bool nrfx_pdm_enable_check ( void )

Function for getting the state of the PDM interface.

Return values
true If the PDM interface is enabled.
false If the PDM interface is disabled.
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_config Pointer to the structure with initial configuration.
[in] event_handler Event handler provided by the user. Cannot be NULL.
Return values
NRFX_SUCCESS If initialization was successful.
NRFX_ERROR_INVALID_STATE If the driver is already initialized.
NRFX_ERROR_INVALID_PARAM If invalid configuration was specified.
nrfx_err_t nrfx_pdm_start ( void )

Function for starting PDM sampling.

Return values
NRFX_SUCCESS If sampling was started successfully or was already in progress.
NRFX_ERROR_BUSY If a previous start/stop operation is in progress.
nrfx_err_t nrfx_pdm_stop ( void )

Function for stopping 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_SUCCESS If sampling was stopped successfully or was already stopped before.
NRFX_ERROR_BUSY If a previous start/stop operation is in progress.
__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] task Task.
Returns
Task address.
void nrfx_pdm_uninit ( void )

Function for uninitializing the PDM interface.

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