RAFW Flexible Software Package Documentation  Release v2.0.1

 
DMIC Interface

Detailed Description

Interface for DMIC audio communication.

Summary

The DMIC (Digital Microphone) interface provides APIs and definitions for DMIC audio communication.

Data Structures

struct  dmic_callback_args_t
 
struct  dmic_status_t
 
struct  dmic_cfg_t
 
struct  dmic_api_t
 
struct  dmic_instance_t
 

Typedefs

typedef void dmic_ctrl_t
 

Enumerations

enum  dmic_direction_t
 
enum  dmic_mode_t
 
enum  dmic_delay_t
 
enum  dmic_event_t
 
enum  dmic_mute_t
 
enum  dmic_state_t
 

Data Structure Documentation

◆ dmic_callback_args_t

struct dmic_callback_args_t

Callback function parameter data

Data Fields
void const * p_context

Placeholder for user data. Set in dmic_api_t::open function in dmic_cfg_t.

dmic_event_t event The event can be used to identify what caused the callback (overflow or error).

◆ dmic_status_t

struct dmic_status_t

DMIC status.

Data Fields
dmic_state_t state Current DMIC state.

◆ dmic_cfg_t

struct dmic_cfg_t

User configuration structure, used in open function

Data Fields

uint32_t channel
 
dmic_direction_t direction
 DMIC direction.
 
dmic_mode_t mode
 DMIC operation mode.
 
dmic_delay_t delay
 DMIC internal delay.
 
bool swap_channel
 DMIC L/R channel swap.
 
uint32_t clk_frequency
 DMIC clock.
 
transfer_instance_t const * p_transfer_rx
 
void(* p_callback )(dmic_callback_args_t *p_args)
 
void const * p_context
 
void const * p_extend
 Extension parameter for hardware specific settings.
 
uint8_t rxi_ipl
 Receive interrupt priority.
 
uint8_t idle_err_ipl
 Idle/Error interrupt priority.
 
IRQn_Type rxi_irq
 Receive IRQ number.
 
IRQn_Type int_irq
 Idle/Error IRQ number.
 

Field Documentation

◆ channel

uint32_t dmic_cfg_t::channel

Select a channel corresponding to the channel number of the hardware.

◆ p_transfer_rx

transfer_instance_t const* dmic_cfg_t::p_transfer_rx

To use DMA for receiving link a Transfer instance here. Set to NULL if unused.

◆ p_callback

void(* dmic_cfg_t::p_callback) (dmic_callback_args_t *p_args)

Callback provided when an DMIC ISR occurs. Set to NULL for no CPU interrupt.

◆ p_context

void const* dmic_cfg_t::p_context

Placeholder for user data. Passed to the user callback in dmic_callback_args_t.

◆ dmic_api_t

struct dmic_api_t

DMIC functions implemented at the HAL layer will follow this API.

Data Fields

fsp_err_t(* open )(dmic_ctrl_t *const p_ctrl, dmic_cfg_t const *const p_cfg)
 
fsp_err_t(* stop )(dmic_ctrl_t *const p_ctrl)
 
fsp_err_t(* mute )(dmic_ctrl_t *const p_ctrl, dmic_mute_t const mute_enable)
 
fsp_err_t(* write )(dmic_ctrl_t *const p_ctrl, void const *const p_src, uint32_t const bytes)
 
fsp_err_t(* read )(dmic_ctrl_t *const p_ctrl, void *const p_dest, uint32_t const bytes)
 
fsp_err_t(* writeRead )(dmic_ctrl_t *const p_ctrl, void const *const p_src, void *const p_dest, uint32_t const bytes)
 
fsp_err_t(* statusGet )(dmic_ctrl_t *const p_ctrl, dmic_status_t *const p_status)
 
fsp_err_t(* close )(dmic_ctrl_t *const p_ctrl)
 
fsp_err_t(* callbackSet )(dmic_ctrl_t *const p_ctrl, void(*p_callback)(dmic_callback_args_t *), void const *const p_context, dmic_callback_args_t *const p_callback_memory)
 

Field Documentation

◆ open

fsp_err_t(* dmic_api_t::open) (dmic_ctrl_t *const p_ctrl, dmic_cfg_t const *const p_cfg)

Initial configuration.

Precondition
Peripheral clocks and any required output pins should be configured prior to calling this function.
Note
To reconfigure after calling this function, call dmic_api_t::close first.
Parameters
[in]p_ctrlPointer to control block. Must be declared by user. Elements set here.
[in]p_cfgPointer to configuration structure. All elements of this structure must be set by user.

◆ stop

fsp_err_t(* dmic_api_t::stop) (dmic_ctrl_t *const p_ctrl)

Stop communication. Communication is stopped when callback is called with DMIC_EVENT_IDLE.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.

◆ mute

fsp_err_t(* dmic_api_t::mute) (dmic_ctrl_t *const p_ctrl, dmic_mute_t const mute_enable)

Enable or disable mute.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.
[in]mute_enableWhether to enable or disable mute.

◆ write

fsp_err_t(* dmic_api_t::write) (dmic_ctrl_t *const p_ctrl, void const *const p_src, uint32_t const bytes)

Write DMIC data. All transmit data is queued when callback is called with DMIC_EVENT_TX_EMPTY. Transmission is complete when callback is called with DMIC_EVENT_IDLE.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.
[in]p_srcBuffer of PCM samples. Must be 4 byte aligned.
[in]bytesNumber of bytes in the buffer. Recommended requesting a multiple of 8 bytes. If not a multiple of 8, padding 0s will be added to transmission to make it a multiple of 8.

◆ read

fsp_err_t(* dmic_api_t::read) (dmic_ctrl_t *const p_ctrl, void *const p_dest, uint32_t const bytes)

Read DMIC data. Reception is complete when callback is called with DMIC_EVENT_RX_EMPTY.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.
[in]p_destBuffer to store PCM samples. Must be 4 byte aligned.
[in]bytesNumber of bytes in the buffer. Recommended requesting a multiple of 8 bytes. If not a multiple of 8, receive will stop at the multiple of 8 below requested bytes.

◆ writeRead

fsp_err_t(* dmic_api_t::writeRead) (dmic_ctrl_t *const p_ctrl, void const *const p_src, void *const p_dest, uint32_t const bytes)

Simultaneously write and read DMIC data. Transmission and reception are complete when callback is called with DMIC_EVENT_IDLE.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.
[in]p_srcBuffer of PCM samples. Must be 4 byte aligned.
[in]p_destBuffer to store PCM samples. Must be 4 byte aligned.
[in]bytesNumber of bytes in the buffers. Recommended requesting a multiple of 8 bytes. If not a multiple of 8, padding 0s will be added to transmission to make it a multiple of 8, and receive will stop at the multiple of 8 below requested bytes.

◆ statusGet

fsp_err_t(* dmic_api_t::statusGet) (dmic_ctrl_t *const p_ctrl, dmic_status_t *const p_status)

Get current status and store it in provided pointer p_status.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.
[out]p_statusCurrent status of the driver.

◆ close

fsp_err_t(* dmic_api_t::close) (dmic_ctrl_t *const p_ctrl)

Allows driver to be reconfigured and may reduce power consumption.

Parameters
[in]p_ctrlControl block set in dmic_api_t::open call for this instance.

◆ callbackSet

fsp_err_t(* dmic_api_t::callbackSet) (dmic_ctrl_t *const p_ctrl, void(*p_callback)(dmic_callback_args_t *), void const *const p_context, dmic_callback_args_t *const p_callback_memory)

Specify callback function and optional context pointer and working memory pointer.

Parameters
[in]p_ctrlPointer to the DMIC control block.
[in]p_callbackCallback function
[in]p_contextPointer to send to callback function
[in]p_working_memoryPointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback.

◆ dmic_instance_t

struct dmic_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
dmic_ctrl_t * p_ctrl Pointer to the control structure for this instance.
dmic_cfg_t const * p_cfg Pointer to the configuration structure for this instance.
dmic_api_t const * p_api Pointer to the API structure for this instance.

Typedef Documentation

◆ dmic_ctrl_t

typedef void dmic_ctrl_t

DMIC control block. Allocate an instance specific control block to pass into the DMIC API calls.

Enumeration Type Documentation

◆ dmic_direction_t

DMIC Direction

Enumerator
DMIC_DIRECTION_INPUT 

DMIC input.

DMIC_DIRECTION_OUTPUT 

DMIC output.

◆ dmic_mode_t

DMIC operation mode

Enumerator
DMIC_MODE_SLAVE 

DMIC interface in slave mode.

DMIC_MODE_MASTER 

DMIC interface in master mode.

◆ dmic_delay_t

DMIC set input delay

Enumerator
DMIC_DI_NO_DELAY 

DMIC no input delay.

DMIC_DI_6NS_DELAY 

DMIC 6ns input delay.

DMIC_DI_12NS_DELAY 

DMIC 12ns input delay.

DMIC_DI_18NS_DELAY 

DMIC 18ns input delay.

◆ dmic_event_t

Events that can trigger a callback function

Enumerator
DMIC_EVENT_IDLE 

Communication is idle.

DMIC_EVENT_TX_EMPTY 

Transmit buffer is below FIFO trigger level.

DMIC_EVENT_RX_FULL 

Receive buffer is above FIFO trigger level.

◆ dmic_mute_t

Mute audio samples.

Enumerator
DMIC_MUTE_OFF 

Disable mute.

DMIC_MUTE_ON 

Enable mute.

◆ dmic_state_t

Possible status values returned by dmic_api_t::statusGet.

Enumerator
DMIC_STATE_IN_USE 

DMIC is in use.

DMIC_STATE_STOPPED 

DMIC is stopped.