PDM driver¶
-
group
nrfx_pdm
Pulse Density Modulation (PDM) peripheral driver.
Defines
-
NRFX_PDM_MAX_BUFFER_SIZE
¶ Maximum supported PDM buffer size.
-
NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG
¶ PDM additional ratio configuration.
-
NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG
¶ PDM additional master clock source configuration.
-
NRFX_PDM_DEFAULT_CONFIG
(_pin_clk, _pin_din)¶ 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
_pin_clk – [in] CLK output pin.
_pin_din – [in] DIN input pin.
Typedefs
-
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
p_evt – [in] Pointer to the PDM event structure.
Enums
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.
- Parameters
p_config – [in] Pointer to the structure with the initial configuration.
event_handler – [in] Event handler provided by the user. Cannot be NULL.
- Returns NRFX_SUCCESS
Initialization was successful.
- Returns NRFX_ERROR_INVALID_STATE
The driver is already initialized.
- Returns NRFX_ERROR_INVALID_PARAM
Invalid configuration was specified.
-
void
nrfx_pdm_uninit
(void)¶ Function for uninitializing the PDM interface.
This function stops PDM sampling, if it is in progress.
-
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
task – [in] Task.
- Returns
Task address.
-
NRFX_STATIC_INLINE bool
nrfx_pdm_enable_check
(void)¶ Function for getting the state of the PDM interface.
- Returns true
The PDM interface is enabled.
- Returns false
The PDM interface is disabled.
-
nrfx_err_t
nrfx_pdm_start
(void)¶ Function for starting the PDM sampling.
- Returns NRFX_SUCCESS
Sampling was started successfully or was already in progress.
- Returns NRFX_ERROR_BUSY
Previous start/stop operation is in progress.
-
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.
- Returns NRFX_SUCCESS
Sampling was stopped successfully or was already stopped before.
- Returns NRFX_ERROR_BUSY
Previous start/stop operation is in progress.
-
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
buffer – [in] Pointer to the receive buffer. Cannot be NULL.
buffer_length – [in] Length of the receive buffer in 16-bit words.
- Returns NRFX_SUCCESS
The buffer was applied successfully.
- Returns NRFX_ERROR_BUSY
The buffer was already supplied or the peripheral is currently being stopped.
- Returns NRFX_ERROR_INVALID_STATE
The driver was not initialized.
- Returns NRFX_ERROR_INVALID_PARAM
Invalid parameters were provided.
-
struct
nrfx_pdm_evt_t
¶ - #include <nrfx_pdm.h>
PDM event structure.
Public Members
-
bool
buffer_requested
¶ Buffer request flag.
-
int16_t *
buffer_released
¶ Pointer to the released buffer. Can be NULL.
-
nrfx_pdm_error_t
error
¶ Error type.
-
bool
-
struct
nrfx_pdm_config_t
¶ - #include <nrfx_pdm.h>
PDM interface driver configuration structure.
Public Members
-
nrf_pdm_mode_t
mode
¶ Interface operation mode.
-
nrf_pdm_edge_t
edge
¶ Sampling mode.
-
uint8_t
pin_clk
¶ CLK pin.
-
uint8_t
pin_din
¶ DIN pin.
-
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.
-
uint8_t
interrupt_priority
¶ Interrupt priority.
-
nrf_pdm_mode_t
-