Zephyr API 3.6.99
Loading...
Searching...
No Matches
Digital Microphone Interface

Abstraction for digital microphones. More...

Data Structures

struct  pdm_io_cfg
 PDM Input/Output signal configuration. More...
 
struct  pcm_stream_cfg
 Configuration of the PCM streams to be output by the PDM hardware. More...
 
struct  pdm_chan_cfg
 Mapping/ordering of the PDM channels to logical PCM output channel. More...
 
struct  dmic_cfg
 Input configuration structure for the DMIC configuration API. More...
 

Enumerations

enum  dmic_state {
  DMIC_STATE_UNINIT , DMIC_STATE_INITIALIZED , DMIC_STATE_CONFIGURED , DMIC_STATE_ACTIVE ,
  DMIC_STATE_PAUSED , DMIC_STATE_ERROR
}
 DMIC driver states. More...
 
enum  dmic_trigger {
  DMIC_TRIGGER_STOP , DMIC_TRIGGER_START , DMIC_TRIGGER_PAUSE , DMIC_TRIGGER_RELEASE ,
  DMIC_TRIGGER_RESET
}
 DMIC driver trigger commands. More...
 
enum  pdm_lr { PDM_CHAN_LEFT , PDM_CHAN_RIGHT }
 PDM Channels LEFT / RIGHT. More...
 

Functions

static uint32_t dmic_build_channel_map (uint8_t channel, uint8_t pdm, enum pdm_lr lr)
 Build the channel map to populate struct pdm_chan_cfg.
 
static void dmic_parse_channel_map (uint32_t channel_map_lo, uint32_t channel_map_hi, uint8_t channel, uint8_t *pdm, enum pdm_lr *lr)
 Helper function to parse the channel map in pdm_chan_cfg.
 
static uint32_t dmic_build_clk_skew_map (uint8_t pdm, uint8_t skew)
 Build a bit map of clock skew values for each PDM channel.
 
static int dmic_configure (const struct device *dev, struct dmic_cfg *cfg)
 Configure the DMIC driver and controller(s)
 
static int dmic_trigger (const struct device *dev, enum dmic_trigger cmd)
 Send a command to the DMIC driver.
 
static int dmic_read (const struct device *dev, uint8_t stream, void **buffer, size_t *size, int32_t timeout)
 Read received decimated PCM data stream.
 

Detailed Description

Abstraction for digital microphones.

Since
1.13
Version
0.1.0

Enumeration Type Documentation

◆ dmic_state

enum dmic_state

#include <zephyr/audio/dmic.h>

DMIC driver states.

Enumerator
DMIC_STATE_UNINIT 

Uninitialized.

DMIC_STATE_INITIALIZED 

Initialized.

DMIC_STATE_CONFIGURED 

Configured.

DMIC_STATE_ACTIVE 

Active.

DMIC_STATE_PAUSED 

Paused.

DMIC_STATE_ERROR 

Error.

◆ dmic_trigger

#include <zephyr/audio/dmic.h>

DMIC driver trigger commands.

Enumerator
DMIC_TRIGGER_STOP 

Stop stream.

DMIC_TRIGGER_START 

Start stream.

DMIC_TRIGGER_PAUSE 

Pause stream.

DMIC_TRIGGER_RELEASE 

Release paused stream.

DMIC_TRIGGER_RESET 

Reset stream.

◆ pdm_lr

enum pdm_lr

#include <zephyr/audio/dmic.h>

PDM Channels LEFT / RIGHT.

Enumerator
PDM_CHAN_LEFT 

Left channel.

PDM_CHAN_RIGHT 

Right channel.

Function Documentation

◆ dmic_build_channel_map()

static uint32_t dmic_build_channel_map ( uint8_t channel,
uint8_t pdm,
enum pdm_lr lr )
inlinestatic

#include <zephyr/audio/dmic.h>

Build the channel map to populate struct pdm_chan_cfg.

Returns the map of PDM controller and LEFT/RIGHT channel shifted to the bit position corresponding to the input logical channel value

Parameters
channelThe logical channel number
pdmThe PDM hardware controller number
lrLEFT/RIGHT channel within the chosen PDM hardware controller
Returns
Bit-map containing the PDM and L/R channel information

◆ dmic_build_clk_skew_map()

static uint32_t dmic_build_clk_skew_map ( uint8_t pdm,
uint8_t skew )
inlinestatic

#include <zephyr/audio/dmic.h>

Build a bit map of clock skew values for each PDM channel.

Returns the bit-map of clock skew value shifted to the bit position corresponding to the input PDM controller value

Parameters
pdmThe PDM hardware controller number
skewThe skew to apply for the clock output from the PDM controller
Returns
Bit-map containing the clock skew information

◆ dmic_configure()

static int dmic_configure ( const struct device * dev,
struct dmic_cfg * cfg )
inlinestatic

#include <zephyr/audio/dmic.h>

Configure the DMIC driver and controller(s)

Configures the DMIC driver device according to the number of channels, channel mapping, PDM I/O configuration, PCM stream configuration, etc.

Parameters
devPointer to the device structure for DMIC driver instance
cfgPointer to the structure containing the DMIC configuration
Returns
0 on success, a negative error code on failure

◆ dmic_parse_channel_map()

static void dmic_parse_channel_map ( uint32_t channel_map_lo,
uint32_t channel_map_hi,
uint8_t channel,
uint8_t * pdm,
enum pdm_lr * lr )
inlinestatic

#include <zephyr/audio/dmic.h>

Helper function to parse the channel map in pdm_chan_cfg.

Returns the PDM controller and LEFT/RIGHT channel corresponding to the channel map and the logical channel provided as input

Parameters
channel_map_loLower order/significant bits of the channel map
channel_map_hiHigher order/significant bits of the channel map
channelThe logical channel number
pdmPointer to the PDM hardware controller number
lrPointer to the LEFT/RIGHT channel within the PDM controller

◆ dmic_read()

static int dmic_read ( const struct device * dev,
uint8_t stream,
void ** buffer,
size_t * size,
int32_t timeout )
inlinestatic

#include <zephyr/audio/dmic.h>

Read received decimated PCM data stream.

Optionally waits for audio to be received and provides the received audio buffer from the requested stream

Parameters
devPointer to the device structure for DMIC driver instance
streamStream identifier
bufferPointer to the received buffer address
sizePointer to the received buffer size
timeoutTimeout in milliseconds to wait in case audio is not yet received, or SYS_FOREVER_MS
Returns
0 on success, a negative error code on failure

◆ dmic_trigger()

static int dmic_trigger ( const struct device * dev,
enum dmic_trigger cmd )
inlinestatic

#include <zephyr/audio/dmic.h>

Send a command to the DMIC driver.

Sends a command to the driver to perform a specific action

Parameters
devPointer to the device structure for DMIC driver instance
cmdThe command to be sent to the driver instance
Returns
0 on success, a negative error code on failure