Pulse Density Modulation (PDM) peripheral driver.
More...
|
|
#define | NRFX_PDM_MAX_BUFFER_SIZE 32767 |
| | Maximum supported PDM buffer size.
|
| |
| #define | NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din) |
| | PDM driver default configuration.
|
| |
| #define | NRFX_PDM_INSTANCE(reg) |
| | Macro for creating an instance of the PDM driver.
|
| |
Pulse Density Modulation (PDM) peripheral driver.
◆ NRFX_PDM_DEFAULT_CONFIG
| #define NRFX_PDM_DEFAULT_CONFIG |
( |
| _pin_clk, |
|
|
| _pin_din ) |
Value:{ \
.clk_pin = _pin_clk, \
.din_pin = _pin_din, \
.interrupt_priority = NRFX_PDM_DEFAULT_CONFIG_IRQ_PRIORITY, \
.prescalers = \
{ \
(.prescaler = 4,), ()) \
(.custom_ratio = { \
.ratio = 64, \
.compensation_gain = 0, \
.minor_compensation_gain = false, \
}), ()) \
}, \
}
#define NRF_PDM_HAS_SELECTABLE_CLOCK
Symbol indicating whether PDM has selectable clock source.
Definition nrf_pdm.h:198
#define NRF_PDM_HAS_PDMCLKCTRL
Symbol indicating whether PDM clock control register is available.
Definition nrf_pdm.h:86
#define NRF_PDM_HAS_PRESCALER
Symbol indicating whether PDM prescaler register is available.
Definition nrf_pdm.h:114
#define NRF_PDM_HAS_CUSTOM_RATIO
Symbol indicating whether PDM custom ratio configuration is available.
Definition nrf_pdm.h:191
#define NRF_PDM_HAS_RATIO_CONFIG
Symbol indicating whether ratio configuration is available.
Definition nrf_pdm.h:71
#define NRF_PDM_GAIN_DEFAULT
Default value of PDM gain.
Definition nrf_pdm.h:206
@ NRF_PDM_MCLKSRC_PCLK32M
32MHz peripheral clock.
Definition nrf_pdm.h:330
@ NRF_PDM_FREQ_1032K
PDM_CLK = 1.032 MHz.
Definition nrf_pdm.h:261
@ NRF_PDM_RATIO_64X
Ratio of 64.
Definition nrf_pdm.h:288
@ NRF_PDM_FILTER_CIC_MSB_RANGE_5
OSR range low - 56 bits, OSR range high - 64 bits.
Definition nrf_pdm.h:357
@ NRF_PDM_EDGE_LEFTFALLING
Left (or mono) is sampled on falling edge of PDM_CLK.
Definition nrf_pdm.h:321
@ NRF_PDM_MODE_MONO
Sample and store two successive Left samples (16 bit each) per RAM word.
Definition nrf_pdm.h:315
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_clk | CLK output pin. |
| [in] | _pin_din | DIN input pin. |
◆ NRFX_PDM_INSTANCE
| #define NRFX_PDM_INSTANCE |
( |
| reg | ) |
|
Value:{ \
.p_reg = (NRF_PDM_Type *)reg, \
.cb = {0} \
}
Macro for creating an instance of the PDM driver.
◆ 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_evt | Pointer to the PDM event structure. |
◆ nrfx_pdm_error_t
PDM error type.
| Enumerator |
|---|
| NRFX_PDM_NO_ERROR | No error.
|
| NRFX_PDM_ERROR_OVERFLOW | Overflow error.
|
◆ nrfx_pdm_buffer_set()
| int nrfx_pdm_buffer_set |
( |
nrfx_pdm_t * | p_instance, |
|
|
int16_t * | buffer, |
|
|
uint16_t | buffer_length ) |
Function for supplying the sample buffer.
Call this function after every buffer request event.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | buffer | Pointer to the receive buffer. Cannot be NULL. |
| [in] | buffer_length | Length of the receive buffer in 16-bit words. |
- Return values
-
| 0 | The buffer was applied successfully. |
| -EBUSY | The buffer was already supplied or the peripheral is currently being stopped. |
| -EINPROGRESS | The driver was not initialized. |
| -EINVAL | Invalid parameters were provided. |
◆ nrfx_pdm_enable_check()
| NRFX_STATIC_INLINE bool nrfx_pdm_enable_check |
( |
nrfx_pdm_t const * | p_instance | ) |
|
Function for getting the state of the PDM drivers instance.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
| true | The PDM interface is enabled. |
| false | The PDM interface is disabled. |
◆ nrfx_pdm_init()
Function for initializing the PDM driver instance.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the initial configuration. |
| [in] | event_handler | Event handler provided by the user. Cannot be NULL. |
- Return values
-
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -EINVAL | Invalid configuration was specified. |
◆ nrfx_pdm_init_check()
| bool nrfx_pdm_init_check |
( |
nrfx_pdm_t const * | p_instance | ) |
|
Function for checking if the PDM driver instance is initialized.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
| true | Interface is already initialized. |
| false | Interface is not initialized. |
◆ nrfx_pdm_irq_handler()
| void nrfx_pdm_irq_handler |
( |
nrfx_pdm_t * | p_instance | ) |
|
Driver interrupt handler.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
◆ nrfx_pdm_prescalers_calc()
Function for calculating PDM clock prescaler values.
Call this function to find suitable value for prescalers in nrfx_pdm_config_t structure.
- Note
- This function does not provide custom ratio configuration, even if the device supports it. Custom ratio configuration has to be provided the by the user.
- Parameters
-
| [in] | output_config | Expected output frequencies. |
| [out] | prescalers | Prescaler structure pointer to be filled with prescaler values. |
- Return values
-
| 0 | Suitable prescaler values were found. |
| -EINVAL | No suitable prescaler values were found. |
◆ nrfx_pdm_reconfigure()
Function for reconfiguring the PDM driver instance.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the configuration. |
- Return values
-
| 0 | Reconfiguration was successful. |
| -EBUSY | There is ongoing sampling and driver cannot be reconfigured. |
| -EINPROGRESS | The driver is not initialized. |
| -EINVAL | Invalid configuration was specified. |
◆ nrfx_pdm_start()
Function for starting the PDM sampling.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
| 0 | Sampling was started successfully or was already in progress. |
| -EBUSY | Previous start/stop operation is in progress. |
◆ nrfx_pdm_stop()
Function for stopping the PDM sampling.
When this function is called, the PDM driver instance is stopped after finishing the current frame. The event handler function might be called once more after calling this function.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
| 0 | Sampling was stopped successfully or was already stopped before. |
| -EBUSY | Previous start/stop operation is in progress. |
◆ nrfx_pdm_task_address_get()
Function for getting the address of a PDM driver instance task.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | task | Task. |
- Returns
- Task address.
◆ nrfx_pdm_uninit()
Function for uninitializing the PDM driver instance.
- Parameters
-
| [in] | p_instance | Pointer to the driver instance structure. |
This function stops PDM sampling, if it is in progress.