| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Macros | Typedefs | Functions
PDM driver
PDM HAL and driver

nRF52 only: Pulse density modulation (PDM) interface driver. More...

## Modules
| PDM peripheral driver configuration

## Data Structures
struct | nrf_drv_pdm_config_t
| PDM interface driver configuration structure. More...

## Macros
#define | NRF_PDM_MAX_BUFFER_SIZE 32768
#define | NRF_DRV_PDM_DEFAULT_CONFIG(PIN_CLK, PIN_DIN, BUFF_A, BUFF_B, BUFF_LEN)
| Macro for setting nrf_drv_pdm_config_t to default settings in single ended mode. More...

## Typedefs
typedef void(* | nrf_drv_pdm_event_handler_t )(uint32_t *buffer, uint16_t length)
| Handler for PDM interface ready events. More...

## Functions
ret_code_t | nrf_drv_pdm_init (nrf_drv_pdm_config_t const *p_config, nrf_drv_pdm_event_handler_t event_handler)
| Function for initializing the PDM interface. More...
void | nrf_drv_pdm_uninit (void)
| Function for uninitializing the PDM interface. More...
__STATIC_INLINE uint32_t | nrf_drv_pdm_task_address_get (nrf_pdm_task_t task)
| Function for getting the address of a PDM interface task. More...
__STATIC_INLINE bool | nrf_drv_pdm_enable_check ()
| Function for getting the state of the PDM interface. More...
ret_code_t | nrf_drv_pdm_start (void)
| Function for starting PDM sampling. More...
ret_code_t | nrf_drv_pdm_stop (void)
| Function for stopping PDM sampling. More...

## Detailed Description

nRF52 only: Pulse density modulation (PDM) interface driver.

## Macro Definition Documentation

#define NRF_DRV_PDM_DEFAULT_CONFIG | ( |  | PIN_CLK,
|  |  | PIN_DIN,
|  |  | BUFF_A,
|  |  | BUFF_B,
|  |  | BUFF_LEN
| ) |  |

Value:
{ \
.mode = (nrf_pdm_mode_t)PDM_CONFIG_MODE, \
.edge = (nrf_pdm_edge_t)PDM_CONFIG_EDGE, \
.pin_clk = PIN_CLK, \
.pin_din = PIN_DIN, \
.clock_freq = (nrf_pdm_freq_t)PDM_CONFIG_CLOCK_FREQ, \
.gain_l = NRF_PDM_GAIN_DEFAULT, \
.gain_r = NRF_PDM_GAIN_DEFAULT, \
.interrupt_priority = PDM_CONFIG_IRQ_PRIORITY, \
.buffer_length = BUFF_LEN, \
.buffer_a = BUFF_A, \
.buffer_b = BUFF_B \
}

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

Parameters

  PIN_CLK | CLK output pin.
  PIN_DIN | DIN input pin.
  BUFF_A | Sample buffer A (filled first).
  BUFF_B | Sample buffer B (filled after buffer A).
  BUFF_LEN | Length of a single buffer (in 16-bit words).

## Typedef Documentation

typedef void(* nrf_drv_pdm_event_handler_t)(uint32_t *buffer, uint16_t length)

Handler for PDM interface ready events.

This event handler is called when a buffer is full and ready to be processed.

Parameters

  [in] | p_buffer | Sample buffer pointer.
  [in] | length | Buffer length in 16-bit words.

## Function Documentation

__STATIC_INLINE bool nrf_drv_pdm_enable_check | ( |  | ) |

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.

ret_code_t nrf_drv_pdm_init | ( | nrf_drv_pdm_config_t const * | p_config,
|  | nrf_drv_pdm_event_handler_t | event_handler
| ) |  |

Function for initializing the PDM interface.

Parameters

  [in] | p_config | Pointer to a configuration structure. If NULL, the default one is used.
  [in] | event_handler | Event handler provided by the user.

Return values

  NRF_SUCCESS | If initialization was successful.
  NRF_ERROR_INVALID_STATE | If the driver is already initialized.
  NRF_ERROR_INVALID_PARAM | If invalid parameters were specified.

ret_code_t nrf_drv_pdm_start | ( | void |  | ) |

Function for starting PDM sampling.

Return values

  NRF_SUCCESS | If sampling was started successfully or was already in progress.
  NRF_ERROR_BUSY | If a previous start/stop operation is in progress.

ret_code_t nrf_drv_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

  NRF_SUCCESS | If sampling was stopped successfully or was already stopped before.
  NRF_ERROR_BUSY | If a previous start/stop operation is in progress.

__STATIC_INLINE uint32_t nrf_drv_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 nrf_drv_pdm_uninit | ( | void |  | ) |

Function for uninitializing the PDM interface.

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