cy_pdm_pcm_8h

The header file of the PDM_PCM driver.

Version

2.30

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Copyright

Copyright 2016-2020 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines

CY_PDM_PCM_DRV_VERSION_MAJOR

The driver major version.

CY_PDM_PCM_DRV_VERSION_MINOR

The driver minor version.

CY_PDM_PCM_ID

The PDM-PCM driver identifier.

CY_PDM_PCM_INTR_RX_TRIGGER

Bit 16: More entries in the RX FIFO than specified by Trigger Level.

CY_PDM_PCM_INTR_RX_NOT_EMPTY

Bit 18: RX FIFO is not empty.

CY_PDM_PCM_INTR_RX_OVERFLOW

Bit 21: Attempt to write to a full RX FIFO.

CY_PDM_PCM_INTR_RX_UNDERFLOW

Bit 22: Attempt to read from an empty RX FIFO.

Enums

enum cy_en_pdm_pcm_word_len_t

cy_en_pdm_pcm_word_len_t: PDM Word Length.

Values:

enumerator CY_PDM_PCM_WLEN_16_BIT

Word length: 16 bit.

enumerator CY_PDM_PCM_WLEN_18_BIT

Word length: 18 bit.

enumerator CY_PDM_PCM_WLEN_20_BIT

Word length: 20 bit.

enumerator CY_PDM_PCM_WLEN_24_BIT

Word length: 24 bit.

enum cy_en_pdm_pcm_clk_div_t

cy_en_pdm_pcm_clk_div_t: PDM Clock Divider.

Values:

enumerator CY_PDM_PCM_CLK_DIV_BYPASS

Clock 1/1.

enumerator CY_PDM_PCM_CLK_DIV_1_2

Clock 1/2 (no 50% duty cycle).

enumerator CY_PDM_PCM_CLK_DIV_1_3

Clock 1/3 (no 50% duty cycle).

enumerator CY_PDM_PCM_CLK_DIV_1_4

Clock 1/4 (no 50% duty cycle).

enum cy_en_pdm_pcm_out_t

cy_en_pdm_pcm_out_t: PDM Output Mode.

Values:

enumerator CY_PDM_PCM_OUT_CHAN_LEFT

Channel mono left.

enumerator CY_PDM_PCM_OUT_CHAN_RIGHT

Channel mono right.

enumerator CY_PDM_PCM_OUT_STEREO

Channel stereo.

enum cy_en_pdm_pcm_chan_select_t

cy_en_pdm_pcm_chan_select_t: PDM Channel selector.

Values:

enumerator CY_PDM_PCM_CHAN_LEFT

Channel left.

enumerator CY_PDM_PCM_CHAN_RIGHT

Channel right.

enum cy_en_pdm_pcm_gain_t

cy_en_pdm_pcm_gain_t: PDM Gain.

Values:

enumerator CY_PDM_PCM_ATTN_12_DB

-12 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_10_5_DB

-10.5 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_9_DB

-9 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_7_5_DB

-7.5 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_6_DB

-6 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_4_5_DB

-4.5 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_3_DB

-3 dB (attenuation).

enumerator CY_PDM_PCM_ATTN_1_5_DB

-1.5 dB (attenuation).

enumerator CY_PDM_PCM_BYPASS

0 dB (bypass).

enumerator CY_PDM_PCM_GAIN_1_5_DB

+1.5 dB (amplification).

enumerator CY_PDM_PCM_GAIN_3_DB

+3 dB (amplification).

enumerator CY_PDM_PCM_GAIN_4_5_DB

+4.5 dB (amplification).

enumerator CY_PDM_PCM_GAIN_6_DB

+6 dB (amplification).

enumerator CY_PDM_PCM_GAIN_7_5_DB

+7.5 dB (amplification).

enumerator CY_PDM_PCM_GAIN_9_DB

+9 dB (amplification).

enumerator CY_PDM_PCM_GAIN_10_5_DB

+10.5 dB (amplification).

enum cy_en_pdm_pcm_s_cycles_t

cy_en_pdm_pcm_s_cycles_t: The time step for gain change during PGA or soft mute operation in number of 1/a sampling rate.

Values:

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_64

64 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_96

96 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_128

128 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_160

160 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_192

192 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_256

256 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_384

384 steps.

enumerator CY_PDM_PCM_SOFT_MUTE_CYCLES_512

512 steps.

enum cy_en_pdm_pcm_status_t

cy_en_pdm_pcm_status_t: The PDM-PCM status codes.

Values:

enumerator CY_PDM_PCM_SUCCESS

Success status code.

enumerator CY_PDM_PCM_BAD_PARAM

Bad parameter status code.

Functions

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.

struct cy_stc_pdm_pcm_config_t
#include <cy_pdm_pcm.h>

PDM-PCM initialization configuration.

Public Members

cy_en_pdm_pcm_clk_div_t clkDiv

PDM Clock Divider (1st divider), see cy_en_pdm_pcm_clk_div_t This configures a frequency of PDM CLK.

The configured frequency is used to operate PDM core. I.e. the frequency is input to MCLKQ_CLOCK_DIV register.

cy_en_pdm_pcm_clk_div_t mclkDiv

MCLKQ divider (2nd divider), see cy_en_pdm_pcm_clk_div_t.

uint8_t ckoDiv

PDM CKO (FPDM_CKO) clock divider (3rd divider):

  • if CKO_CLOCK_DIV >= 1 - *F(PDM_CKO) = F(PDM_CLK / (mclkDiv + 1))

  • if CKO_CLOCK_DIV = 0 - *F(PDM_CKO) = MCLKQ / 2

uint8_t ckoDelay

Extra PDM_CKO delay to internal sampler:

  • 0: Three extra PDM_CLK period advance

  • 1: Two extra PDM_CLK period advance

  • 2: One extra PDM_CLK period advance

  • 3: No delay

  • 4: One extra PDM_CLK period delay

  • 5: Two extra PDM_CLK period delay

  • 6: Three extra PDM_CLK period delay

  • 7: Four extra PDM_CLK clock delay

uint8_t sincDecRate

F(MCLK_L_R) = Fs * 2 * sincDecRate * mclkDiv, Fs is a sampling frequency, 8 kHz - 48 kHz.

cy_en_pdm_pcm_out_t chanSelect

see cy_en_pdm_pcm_out_t

bool chanSwapEnable

Audio channels swapping.

uint8_t highPassFilterGain

High pass filter gain: H(Z) = (1 - Z^-1) / (1 - (1 - 2^highPassFilterGain) * Z^-1)

bool highPassDisable

High pass filter disable.

cy_en_pdm_pcm_s_cycles_t softMuteCycles

The time step for gain change during PGA or soft mute operation in number of 1/a sampling rate, see cy_en_pdm_pcm_s_cycles_t.

uint32_t softMuteFineGain

Soft mute fine gain: 0 = 0.13dB, 1 = 0.26dB.

bool softMuteEnable

Soft mute enable.

cy_en_pdm_pcm_word_len_t wordLen

see cy_en_pdm_pcm_word_len_t

bool signExtension

Word extension type:

  • 0: extension by zero

  • 1: extension by sign bits

cy_en_pdm_pcm_gain_t gainLeft

Gain for left channel, see cy_en_pdm_pcm_gain_t.

cy_en_pdm_pcm_gain_t gainRight

Gain for right channel, see cy_en_pdm_pcm_gain_t.

uint8_t rxFifoTriggerLevel

Fifo interrupt trigger level (in words), range: 0 - 253 for stereo and 0 - 254 for mono mode.

bool dmaTriggerEnable

DMA trigger enable.

uint32_t interruptMask

Interrupts enable mask.