Low-level Pulse Density Modulation (PDM) driver.
More...
Low-level Pulse Density Modulation (PDM) driver.
|
| typedef void(* | pdm_data_cb_t) (void *arg, int16_t *buf) |
| | Signature for data received interrupt callback.
|
| |
◆ PDM_BUF_SIZE
| #define PDM_BUF_SIZE (64U) |
Default PDM sample buffer size.
Definition at line 60 of file pdm.h.
◆ PDM_GAIN_MAX
| #define PDM_GAIN_MAX (20) |
Maximum PDM gain (in dB)
Definition at line 53 of file pdm.h.
◆ PDM_GAIN_MIN
| #define PDM_GAIN_MIN (-20) |
Minimum PDM gain (in dB)
Definition at line 46 of file pdm.h.
◆ pdm_data_cb_t
| typedef void(* pdm_data_cb_t) (void *arg, int16_t *buf) |
Signature for data received interrupt callback.
- Parameters
-
| [in] | arg | context passed to the callback (optional) |
| [in] | buf | the buffer containing the current sample frame |
Definition at line 69 of file pdm.h.
◆ pdm_mode_t
PDM operation modes.
| Enumerator |
|---|
| PDM_MODE_MONO | Mono mode.
|
| PDM_MODE_STEREO | Stereo mode.
|
Definition at line 35 of file pdm.h.
◆ pdm_init()
Initialize and enable the PDM peripheral.
The requested rate is approximated to the closest rate the hardware can produce. The actually configured rate is returned so the caller can use it for further processing.
- Parameters
-
| [in] | mode | mode (Mono or Stereo) |
| [in] | rate | sample rate in Hz |
| [in] | gain | gain in dB [PDM_GAIN_MIN...PDM_GAIN_MAX] |
| [in] | cb | data received callback function |
| [in] | arg | context passed to the callback function |
- Return values
-
| >0 | actual configured PDM sample rate in Hz on success |
| -ENOTSUP | mode is not supported |
◆ pdm_start()
Start the PDM peripheral.
- Note
- After calling this function, transients in the audio signal can occur while the PDM peripheral and the microphone start up. Depending on the hardware and configuration used, this start-up phase can last up to a few hundred ms. If the application needs clean audio from the start, it must discard the samples from this start-up phase itself, for example by ignoring the first buffers passed to the data received callback.