Functions

API Reference

group group_pdm_pcm_functions

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.

Precondition

If the PDM-PCM module is initialized previously, the Cy_PDM_PCM_DeInit() must be called before calling this function.

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
};
Return

error / status code. See cy_en_pdm_pcm_status_t.

Parameters
  • base: The pointer to the PDM-PCM instance address

  • config: The pointer to a configuration structure.

void Cy_PDM_PCM_DeInit(PDM_Type *base)

Uninitializes the PDM-PCM module.

Parameters
  • base: The pointer to the PDM-PCM instance address.

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

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.

Return

Gain of the selected channel cy_en_pdm_pcm_gain_t.

Parameters

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.

Return

syspm return status, see cy_en_syspm_status_t

Parameters

__STATIC_INLINE void Cy_PDM_PCM_Enable (PDM_Type *base)

Enables the PDM-PCM data conversion.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_Disable (PDM_Type *base)

Disables the PDM-PCM data conversion.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__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
  • base: The pointer to the PDM-PCM instance address

  • interrupt: Interrupt bit mask Interrupt Masks.

__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).

Return

The interrupt bit mask Interrupt Masks.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__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).

Return

The interrupt bit mask Interrupt Masks.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetInterruptStatus (PDM_Type const *base)

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

Return

The interrupt bit mask Interrupt Masks.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__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
  • base: The pointer to the PDM-PCM instance address

  • interrupt: The interrupt bit mask Interrupt Masks.

__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
  • base: The pointer to the PDM-PCM instance address.

  • interrupt: The interrupt bit mask Interrupt Masks.

__STATIC_INLINE uint8_t Cy_PDM_PCM_GetNumInFifo (PDM_Type const *base)

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

Return

The current number of used FIFO words (range is 0 - 254).

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_ClearFifo (PDM_Type *base)

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

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifo (PDM_Type const *base)

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

Return

The data word.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_EnableSoftMute (PDM_Type *base)

Enables soft mute.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_DisableSoftMute (PDM_Type *base)

Disables soft mute.

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_FreezeFifo (PDM_Type *base)

Freezes the RX FIFO (Debug purpose).

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE void Cy_PDM_PCM_UnfreezeFifo (PDM_Type *base)

Unfreezes the RX FIFO (Debug purpose).

Parameters
  • base: The pointer to the PDM-PCM instance address.

__STATIC_INLINE uint32_t Cy_PDM_PCM_ReadFifoSilent (PDM_Type const *base)

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

Return

FIFO value.

Parameters
  • base: Pointer to PDM-PCM instance address.

__STATIC_INLINE uint32_t Cy_PDM_PCM_GetCurrentState (PDM_Type const *base)

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

Return

The current state (CMD register).

Parameters
  • base: The pointer to the PDM-PCM instance address.