MTB CAT1 Peripheral driver library

General Description

API Reference

 Low Power Callback
 The driver supports SysPm callback for Deep Sleep transition.
 

Functions

cy_en_pdm_pcm_status_t Cy_PDM_PCM_Init (PDM_Type *base, cy_stc_pdm_pcm_config_t const *config)
 Initialize the PDM-PCM module. More...
 
void Cy_PDM_PCM_DeInit (PDM_Type *base)
 Uninitializes the PDM-PCM module. More...
 
void Cy_PDM_PCM_SetGain (PDM_Type *base, cy_en_pdm_pcm_chan_select_t chan, cy_en_pdm_pcm_gain_t gain)
 Sets the gain factor to the left or right channel. More...
 
cy_en_pdm_pcm_gain_t Cy_PDM_PCM_GetGain (PDM_Type const *base, cy_en_pdm_pcm_chan_select_t chan)
 Retrieves the current gain factor of the left or right channel. More...
 
cy_en_syspm_status_t Cy_PDM_PCM_DeepSleepCallback (cy_stc_syspm_callback_params_t const *callbackParams, cy_en_syspm_callback_mode_t mode)
 This is an example callback function that can be used at the application layer to manage the PDM-PCM operation before entering and after exiting Deep Sleep mode. More...
 
__STATIC_INLINE void Cy_PDM_PCM_Enable (PDM_Type *base)
 Enables the PDM-PCM data conversion. More...
 
__STATIC_INLINE void Cy_PDM_PCM_Disable (PDM_Type *base)
 Disables the PDM-PCM data conversion. More...
 
__STATIC_INLINE void Cy_PDM_PCM_SetInterruptMask (PDM_Type *base, uint32_t interrupt)
 Sets one or more PDM-PCM interrupt factor bits (sets the INTR_MASK register). More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptMask (PDM_Type const *base)
 Returns the PDM-PCM interrupt mask (a content of the INTR_MASK register). More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptStatusMasked (PDM_Type const *base)
 Reports the status of enabled (masked) PDM-PCM interrupt sources. More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptStatus (PDM_Type const *base)
 Reports the status of PDM-PCM interrupt sources (an INTR register). More...
 
__STATIC_INLINE void Cy_PDM_PCM_ClearInterrupt (PDM_Type *base, uint32_t interrupt)
 Clears one or more PDM-PCM interrupt statuses (sets an INTR register's bits). More...
 
__STATIC_INLINE void Cy_PDM_PCM_SetInterrupt (PDM_Type *base, uint32_t interrupt)
 Sets one or more interrupt source statuses (sets an INTR_SET register). More...
 
__STATIC_INLINE uint8_t Cy_PDM_PCM_GetNumInFifo (PDM_Type const *base)
 Reports the current number of used words in the output data FIFO. More...
 
__STATIC_INLINE void Cy_PDM_PCM_ClearFifo (PDM_Type *base)
 Resets the output data FIFO, removing all data words from the FIFO. More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifo (PDM_Type const *base)
 Reads ("pops") one word from the output data FIFO. More...
 
__STATIC_INLINE void Cy_PDM_PCM_EnableSoftMute (PDM_Type *base)
 Enables soft mute. More...
 
__STATIC_INLINE void Cy_PDM_PCM_DisableSoftMute (PDM_Type *base)
 Disables soft mute. More...
 
__STATIC_INLINE void Cy_PDM_PCM_FreezeFifo (PDM_Type *base)
 Freezes the RX FIFO (Debug purpose). More...
 
__STATIC_INLINE void Cy_PDM_PCM_UnfreezeFifo (PDM_Type *base)
 Unfreezes the RX FIFO (Debug purpose). More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifoSilent (PDM_Type const *base)
 Reads the RX FIFO silent (without touching the FIFO function). More...
 
__STATIC_INLINE uint32_t Cy_PDM_PCM_GetCurrentState (PDM_Type const *base)
 Returns the current PDM-PCM state (running/stopped). More...
 

Function Documentation

◆ Cy_PDM_PCM_Init()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_Init ( PDM_Type base,
cy_stc_pdm_pcm_config_t const *  config 
)

Initialize the PDM-PCM module.

Precondition
If the PDM-PCM module is initialized previously, the Cy_PDM_PCM_DeInit() must be called before calling this function.
Parameters
baseThe pointer to the PDM-PCM instance address
configThe pointer to a configuration structure.
Returns
error / status code. See cy_en_pdm_pcm_status_t.

An example of a configuration structure:

const cy_stc_pdm_pcm_config_t PDM_PCM_config =
{
/* .clkDiv = */CY_PDM_PCM_CLK_DIV_BYPASS,
/* .mclkDiv = */CY_PDM_PCM_CLK_DIV_1_2,
/* .ckoDiv = */3U,
/* .ckoDelay = */0U,
/* .sincDecRate = */0x20U,
/* .chanSelect = */CY_PDM_PCM_OUT_STEREO,
/* .chanSwapEnable = */false,
/* .highPassFilterGain = */8U,
/* .highPassDisable = */false,
/* .softMuteCycles = */CY_PDM_PCM_SOFT_MUTE_CYCLES_96,
/* .softMuteFineGain = */false,
/* .softMuteEnable = */false,
/* .wordLen = */CY_PDM_PCM_WLEN_16_BIT,
/* .signExtension = */false,
/* .gainLeft = */CY_PDM_PCM_BYPASS,
/* .gainRight = */CY_PDM_PCM_BYPASS,
/* .rxFifoTriggerLevel = */32U,
/* .dmaTriggerEnable = */false,
/* .interruptMask = */CY_PDM_PCM_INTR_RX_TRIGGER
};

◆ Cy_PDM_PCM_DeInit()

void Cy_PDM_PCM_DeInit ( PDM_Type base)

Uninitializes the PDM-PCM module.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_SetGain()

void Cy_PDM_PCM_SetGain ( PDM_Type base,
cy_en_pdm_pcm_chan_select_t  chan,
cy_en_pdm_pcm_gain_t  gain 
)

Sets the gain factor to the left or right channel.

Parameters
baseThe pointer to the PDM-PCM instance address.
chanThe channel selector for gain setting cy_en_pdm_pcm_chan_select_t.
gainGain for the selected channel cy_en_pdm_pcm_gain_t.

◆ Cy_PDM_PCM_GetGain()

cy_en_pdm_pcm_gain_t Cy_PDM_PCM_GetGain ( PDM_Type const *  base,
cy_en_pdm_pcm_chan_select_t  chan 
)

Retrieves the current gain factor of the left or right channel.

Parameters
baseThe pointer to the PDM-PCM instance address.
chanThe channel selector for gain setting cy_en_pdm_pcm_chan_select_t.
Returns
Gain of the selected channel cy_en_pdm_pcm_gain_t.

◆ Cy_PDM_PCM_DeepSleepCallback()

cy_en_syspm_status_t Cy_PDM_PCM_DeepSleepCallback ( cy_stc_syspm_callback_params_t const *  callbackParams,
cy_en_syspm_callback_mode_t  mode 
)

This is an example callback function that can be used at the application layer to manage the PDM-PCM operation before entering and after exiting Deep Sleep mode.

Parameters
callbackParamsThe structure with the syspm callback parameters, see cy_stc_syspm_callback_params_t.
modeCallback mode, see cy_en_syspm_callback_mode_t
Returns
syspm return status, see cy_en_syspm_status_t

◆ Cy_PDM_PCM_Enable()

__STATIC_INLINE void Cy_PDM_PCM_Enable ( PDM_Type base)

Enables the PDM-PCM data conversion.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_Disable()

__STATIC_INLINE void Cy_PDM_PCM_Disable ( PDM_Type base)

Disables the PDM-PCM data conversion.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_SetInterruptMask()

__STATIC_INLINE void Cy_PDM_PCM_SetInterruptMask ( PDM_Type base,
uint32_t  interrupt 
)

Sets one or more PDM-PCM interrupt factor bits (sets the INTR_MASK register).

Parameters
baseThe pointer to the PDM-PCM instance address
interruptInterrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptMask ( PDM_Type const *  base)

Returns the PDM-PCM interrupt mask (a content of the INTR_MASK register).

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The interrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptStatusMasked ( PDM_Type const *  base)

Reports the status of enabled (masked) PDM-PCM interrupt sources.

(an INTR_MASKED register).

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The interrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptStatus ( PDM_Type const *  base)

Reports the status of PDM-PCM interrupt sources (an INTR register).

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The interrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_ClearInterrupt()

__STATIC_INLINE void Cy_PDM_PCM_ClearInterrupt ( PDM_Type base,
uint32_t  interrupt 
)

Clears one or more PDM-PCM interrupt statuses (sets an INTR register's bits).

Parameters
baseThe pointer to the PDM-PCM instance address
interruptThe interrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_SetInterrupt()

__STATIC_INLINE void Cy_PDM_PCM_SetInterrupt ( PDM_Type base,
uint32_t  interrupt 
)

Sets one or more interrupt source statuses (sets an INTR_SET register).

Parameters
baseThe pointer to the PDM-PCM instance address.
interruptThe interrupt bit mask Interrupt Masks.

◆ Cy_PDM_PCM_GetNumInFifo()

__STATIC_INLINE uint8_t Cy_PDM_PCM_GetNumInFifo ( PDM_Type const *  base)

Reports the current number of used words in the output data FIFO.

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The current number of used FIFO words (range is 0 - 254).

◆ Cy_PDM_PCM_ClearFifo()

__STATIC_INLINE void Cy_PDM_PCM_ClearFifo ( PDM_Type base)

Resets the output data FIFO, removing all data words from the FIFO.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_ReadFifo()

__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifo ( PDM_Type const *  base)

Reads ("pops") one word from the output data FIFO.

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The data word.

◆ Cy_PDM_PCM_EnableSoftMute()

__STATIC_INLINE void Cy_PDM_PCM_EnableSoftMute ( PDM_Type base)

Enables soft mute.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_DisableSoftMute()

__STATIC_INLINE void Cy_PDM_PCM_DisableSoftMute ( PDM_Type base)

Disables soft mute.

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_FreezeFifo()

__STATIC_INLINE void Cy_PDM_PCM_FreezeFifo ( PDM_Type base)

Freezes the RX FIFO (Debug purpose).

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_UnfreezeFifo()

__STATIC_INLINE void Cy_PDM_PCM_UnfreezeFifo ( PDM_Type base)

Unfreezes the RX FIFO (Debug purpose).

Parameters
baseThe pointer to the PDM-PCM instance address.

◆ Cy_PDM_PCM_ReadFifoSilent()

__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifoSilent ( PDM_Type const *  base)

Reads the RX FIFO silent (without touching the FIFO function).

Parameters
basePointer to PDM-PCM instance address.
Returns
FIFO value.

◆ Cy_PDM_PCM_GetCurrentState()

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetCurrentState ( PDM_Type const *  base)

Returns the current PDM-PCM state (running/stopped).

Parameters
baseThe pointer to the PDM-PCM instance address.
Returns
The current state (CMD register).