PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Functions
PDL API Reference » PDM_PCM_v2 (PDM-PCM Converter)

## General Description

## Functions
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_Channel_Init (PDM_Type *base, cy_stc_pdm_pcm_channel_config_t const *channel_config, uint8_t channel_num)
| Initialize the PDM-PCM Channel. More...
void | Cy_PDM_PCM_Channel_DeInit (PDM_Type *base, uint8_t channel_num)
| Uninitializes the PDM-PCM channel. More...
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_Init (PDM_Type *base, cy_stc_pdm_pcm_config_v2_t const *config)
| Initializes the PDM-PCM module. More...
void | Cy_PDM_PCM_DeInit (PDM_Type *base)
| Uninitializes the PDM-PCM module. More...
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_test_Init (PDM_Type *base, cy_stc_pdm_pcm_config_v2_t const *config, cy_stc_test_config_t const *test_config)
| Initializes the PDM-PCM module test mode. More...
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_SetGain (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_gain_sel_t gain)
| Sets the gain factor for the given channel. More...
__STATIC_INLINE void | Cy_PDM_PCM_Activate_Channel (PDM_Type *base, uint8_t channel_num)
| Activates the PDM-PCM channel. More...
__STATIC_INLINE void | Cy_PDM_PCM_DeActivate_Channel (PDM_Type *base, uint8_t channel_num)
| DeActivates the PDM-PCM channel. More...
__STATIC_INLINE void | Cy_PDM_PCM_SetRateSampling (PDM_Type *base, cy_en_pdm_pcm_halve_rate_sel_t rate)
| Sets Halve rate Sampling rate. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Enable (PDM_Type *base, uint8_t channel_num)
| Enables the PDM-PCM data conversion. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Disable (PDM_Type *base, uint8_t channel_num)
| Disables the PDM-PCM data conversion. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Set_Cic_DecimCode (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_cic_decimcode_t decimcode)
| Sets PDM-PCM CIC Filter Decimation code. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Set_Fir0 (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_fir0_decimcode_t decimcode, uint8_t scale)
| Sets PDM-PCM FIR0 Filter Decim code and Scale. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Set_Fir1 (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_fir1_decimcode_t decimcode, uint8_t scale)
| Sets PDM-PCM FIR1 Filter Decimation code and Scale. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_Set_DCblock (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_dcblock_coef_t coef)
| Sets the DC blocker filter with programmable coefficient. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_SetInterruptMask (PDM_Type *base, uint8_t channel_num, 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_Channel_GetInterruptMask (PDM_Type const *base, uint8_t channel_num)
| Returns the PDM-PCM interrupt mask (a content of the INTR_MASK register). More...
__STATIC_INLINE uint32_t | Cy_PDM_PCM_Channel_GetInterruptStatusMasked (PDM_Type const *base, uint8_t channel_num)
| Reports the status of enabled (masked) PDM-PCM interrupt sources. More...
__STATIC_INLINE uint32_t | Cy_PDM_PCM_Channel_GetInterruptStatus (PDM_Type const *base, uint8_t channel_num)
| Reports the status of PDM-PCM interrupt sources (an INTR register). More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_ClearInterrupt (PDM_Type *base, uint8_t channel_num, uint32_t interrupt)
| Clears one or more PDM-PCM interrupt statuses (sets an INTR register's bits). More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_SetInterrupt (PDM_Type *base, uint8_t channel_num, uint32_t interrupt)
| Sets one or more interrupt source statuses (sets an INTR_SET register). More...
__STATIC_INLINE uint8_t | Cy_PDM_PCM_Channel_GetNumInFifo (PDM_Type const *base, uint8_t channel_num)
| Reports the current number of used words in the output data FIFO. More...
__STATIC_INLINE uint32_t | Cy_PDM_PCM_Channel_ReadFifo (PDM_Type const *base, uint8_t channel_num)
| Reads ("pops") one word from the output data FIFO. More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_FreezeFifo (PDM_Type *base, uint8_t channel_num)
| Freezes the RX FIFO (Debug purpose). More...
__STATIC_INLINE void | Cy_PDM_PCM_Channel_UnfreezeFifo (PDM_Type *base, uint8_t channel_num)
| Unfreezes the RX FIFO (Debug purpose). More...
__STATIC_INLINE uint32_t | Cy_PDM_PCM_Channel_ReadFifoSilent (PDM_Type const *base, uint8_t channel_num)
| Reads the RX FIFO silent (without touching the FIFO function). More...
__STATIC_INLINE void | Cy_PDM_PCM_DCBlock_Enable (PDM_Type *base, uint8_t channel_num)
| Enable DC Block Filter for the given channel. More...
__STATIC_INLINE void | Cy_PDM_PCM_DCBlock_Disable (PDM_Type *base, uint8_t channel_num)
| Disable DC Block Filter for the given channel. More...
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_SetFIR0_Scale (PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_gain_sel_t scale)
| Sets the FIR0 Scale factor for the given channel. More...
cy_en_pdm_pcm_status_t | Cy_PDM_PCM_ApplyPCM_Gain (const int32_t *in_sample, int32_t gain_db, cy_en_pdm_pcm_format_t out_format, int32_t *out_sample)
| This function applies gain in software to one 24-bit PCM sample data output PCM format can be 24-bit or 16-bit, gain should be in the range of -40db to 40db. More...
__STATIC_INLINE bool | Cy_PDM_PCM_Channel_GetCurrentState (PDM_Type const *base, uint8_t channel_num)
| Returns the current PDM-PCM state (active/stopped). More...

## Function Documentation

## ◆ Cy_PDM_PCM_Channel_Init()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_Channel_Init | ( | PDM_Type * | base,
|  | cy_stc_pdm_pcm_channel_config_t const * | channel_config,
|  | uint8_t | channel_num
| ) |  |

Initialize the PDM-PCM Channel.

Precondition
  Make sure PDM-PCM is initialized before calling this function. Cy_PDM_PCM_Init

Parameters

  base | The pointer to the PDM-PCM instance address
  channel_config | The pointer to a configuration structure.
  channel_num | The channel number to be initialized.

Returns
  error / status code. See cy_en_pdm_pcm_status_t.

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Channel_Init(PDM0, &channel_0_config, channel_num);
  Cy_PDM_PCM_Channel_Init
  cy_en_pdm_pcm_status_t Cy_PDM_PCM_Channel_Init(PDM_Type *base, cy_stc_pdm_pcm_channel_config_t const *channel_config, uint8_t channel_num)
  Initialize the PDM-PCM Channel.
  Definition: cy_pdm_pcm_v2.c:79

## ◆ Cy_PDM_PCM_Channel_DeInit()

void Cy_PDM_PCM_Channel_DeInit | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Uninitializes the PDM-PCM channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | channel number to be de initialized.

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Channel_DeInit(PDM0, &channel_0_config, channel_num);
  Cy_PDM_PCM_Channel_DeInit
  void Cy_PDM_PCM_Channel_DeInit(PDM_Type *base, uint8_t channel_num)
  Uninitializes the PDM-PCM channel.
  Definition: cy_pdm_pcm_v2.c:294

## ◆ Cy_PDM_PCM_Init()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_Init | ( | PDM_Type * | base,
|  | cy_stc_pdm_pcm_config_v2_t const * | config
| ) |  |

Initializes the PDM-PCM module.

Parameters

  base | The pointer to the PDM-PCM instance address
  config | The pointer to a configuration structure. cy_stc_pdm_pcm_config_v2_t

Returns
  error / status code. See cy_en_pdm_pcm_status_t.

Function Usage
  status = Cy_PDM_PCM_Init(PDM0, &pdm_0_config);
  if(CY_PDM_PCM_SUCCESS != status)
  {
  //handle Error
  }
  CY_PDM_PCM_SUCCESS
  @ CY_PDM_PCM_SUCCESS
  Success status code.
  Definition: cy_pdm_pcm_v2.h:287
  Cy_PDM_PCM_Init
  cy_en_pdm_pcm_status_t Cy_PDM_PCM_Init(PDM_Type *base, cy_stc_pdm_pcm_config_v2_t const *config)
  Initializes the PDM-PCM module.
  Definition: cy_pdm_pcm_v2.c:142

## ◆ Cy_PDM_PCM_DeInit()

void Cy_PDM_PCM_DeInit | ( | PDM_Type * | base | ) |

Uninitializes the PDM-PCM module.

Parameters

  base | The pointer to the PDM-PCM instance address.

Function Usage
  Cy_PDM_PCM_DeInit(PDM0);
  Cy_PDM_PCM_DeInit
  void Cy_PDM_PCM_DeInit(PDM_Type *base)
  Uninitializes the PDM-PCM module.
  Definition: cy_pdm_pcm_v2.c:321

## ◆ Cy_PDM_PCM_test_Init()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_test_Init | ( | PDM_Type * | base,
|  | cy_stc_pdm_pcm_config_v2_t const * | config,
|  | cy_stc_test_config_t const * | test_config
| ) |  |

Initializes the PDM-PCM module test mode.

Parameters

  base | The pointer to the PDM-PCM instance address
  config | The pointer to a configuration structure. cy_stc_pdm_pcm_config_v2_t
  test_config | test Mode configuration. cy_stc_test_config_t

Returns
  error / status code. See cy_en_pdm_pcm_status_t.

## ◆ Cy_PDM_PCM_SetGain()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_SetGain | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_gain_sel_t | gain
| ) |  |

Sets the gain factor for the given channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | The channel number for gain setting.
  gain | Gain value defined as cy_en_pdm_pcm_gain_scale_t

## ◆ Cy_PDM_PCM_Activate_Channel()

__STATIC_INLINE void Cy_PDM_PCM_Activate_Channel | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Activates the PDM-PCM channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number to be activated

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Activate_Channel(PDM0, channel_num);
  Cy_PDM_PCM_Activate_Channel
  __STATIC_INLINE void Cy_PDM_PCM_Activate_Channel(PDM_Type *base, uint8_t channel_num)
  Activates the PDM-PCM channel.
  Definition: cy_pdm_pcm_v2.h:641

## ◆ Cy_PDM_PCM_DeActivate_Channel()

__STATIC_INLINE void Cy_PDM_PCM_DeActivate_Channel | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

DeActivates the PDM-PCM channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number to be deactivated

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_DeActivate_Channel(PDM0, channel_num);
  Cy_PDM_PCM_DeActivate_Channel
  __STATIC_INLINE void Cy_PDM_PCM_DeActivate_Channel(PDM_Type *base, uint8_t channel_num)
  DeActivates the PDM-PCM channel.
  Definition: cy_pdm_pcm_v2.h:659

## ◆ Cy_PDM_PCM_SetRateSampling()

__STATIC_INLINE void Cy_PDM_PCM_SetRateSampling | ( | PDM_Type * | base,
|  | cy_en_pdm_pcm_halve_rate_sel_t | rate
| ) |  |

Sets Halve rate Sampling rate.

Parameters

  base | The pointer to the PDM-PCM instance address.
  rate | Halve rate sampling or Full rate sampling cy_en_pdm_pcm_halve_rate_sel_t.

Function Usage
  Cy_PDM_PCM_SetRateSampling(PDM0, CY_PDM_PCM_RATE_FULL);
  CY_PDM_PCM_RATE_FULL
  @ CY_PDM_PCM_RATE_FULL
  Channel full.
  Definition: cy_pdm_pcm_v2.h:192
  Cy_PDM_PCM_SetRateSampling
  __STATIC_INLINE void Cy_PDM_PCM_SetRateSampling(PDM_Type *base, cy_en_pdm_pcm_halve_rate_sel_t rate)
  Sets Halve rate Sampling rate.
  Definition: cy_pdm_pcm_v2.h:698

## ◆ Cy_PDM_PCM_Channel_Enable()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Enable | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Enables the PDM-PCM data conversion.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number to be enabled

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Channel_Enable(PDM0, channel_num);
  Cy_PDM_PCM_Channel_Enable
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Enable(PDM_Type *base, uint8_t channel_num)
  Enables the PDM-PCM data conversion.
  Definition: cy_pdm_pcm_v2.h:603

## ◆ Cy_PDM_PCM_Channel_Disable()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Disable | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Disables the PDM-PCM data conversion.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number to be disabled

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Channel_Disable(PDM0, channel_num);
  Cy_PDM_PCM_Channel_Disable
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Disable(PDM_Type *base, uint8_t channel_num)
  Disables the PDM-PCM data conversion.
  Definition: cy_pdm_pcm_v2.h:622

## ◆ Cy_PDM_PCM_Channel_Set_Cic_DecimCode()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Cic_DecimCode | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_ch_cic_decimcode_t | decimcode
| ) |  |

Sets PDM-PCM CIC Filter Decimation code.

Parameters

  base | The pointer to the PDM-PCM instance address
  channel_num | Channel number for which the CIC filter Decimation code to be set
  decimcode | decimation code value to be set. cy_en_pdm_pcm_ch_cic_decimcode_t.

Function Usage
  uint8_t channel_num = 0U;
  Cy_PDM_PCM_Channel_Set_Cic_DecimCode(PDM0, channel_num, CY_PDM_PCM_CHAN_CIC_DECIM_8);
  CY_PDM_PCM_CHAN_CIC_DECIM_8
  @ CY_PDM_PCM_CHAN_CIC_DECIM_8
  CIC Filter PCM Frequency is 1/8 * PDM Frequency.
  Definition: cy_pdm_pcm_v2.h:201
  Cy_PDM_PCM_Channel_Set_Cic_DecimCode
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Cic_DecimCode(PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_cic_decimcode_t decimcode)
  Sets PDM-PCM CIC Filter Decimation code.
  Definition: cy_pdm_pcm_v2.h:719

## ◆ Cy_PDM_PCM_Channel_Set_Fir0()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Fir0 | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_ch_fir0_decimcode_t | decimcode,
|  | uint8_t | scale
| ) |  |

Sets PDM-PCM FIR0 Filter Decim code and Scale.

The FIR filter coefficients have no default values: the coefficients MUST be programmed BEFORE the filter is enabled. By Default FIR0 is disabled and is only used for 8Khz and 16 Khz sample frequencies. For other frequencies it is a pass through.

Parameters

  base | The pointer to the PDM-PCM instance address
  channel_num | Channel number for which the FIR0 Decimation code and the filter to be set.
  decimcode | Decimation code value to be set. cy_en_pdm_pcm_ch_fir0_decimcode_t.
  scale | Scale value to be set.

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  uint8_t scale = 22U; // scale should be in the range of 1 to 31
  Cy_PDM_PCM_Channel_Set_Fir0(PDM0, channel_num, CY_PDM_PCM_CHAN_FIR0_DECIM_4, scale);
  CY_PDM_PCM_CHAN_FIR0_DECIM_4
  @ CY_PDM_PCM_CHAN_FIR0_DECIM_4
  FIR0 Filter PCM Frequency is 1/4 * PCM Frequency.
  Definition: cy_pdm_pcm_v2.h:212
  Cy_PDM_PCM_Channel_Set_Fir0
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Fir0(PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_fir0_decimcode_t decimcode, uint8_t scale)
  Sets PDM-PCM FIR0 Filter Decim code and Scale.
  Definition: cy_pdm_pcm_v2.h:744

## ◆ Cy_PDM_PCM_Channel_Set_Fir1()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Fir1 | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_ch_fir1_decimcode_t | decimcode,
|  | uint8_t | scale
| ) |  |

Sets PDM-PCM FIR1 Filter Decimation code and Scale.

Parameters

  base | The pointer to the PDM-PCM instance address
  channel_num | Channel number for which the FIR1 Decimation code and the filter to be set.
  decimcode | Decimation code value to be set. cy_en_pdm_pcm_ch_fir1_decimcode_t.
  scale | Scale value to be set.

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  uint8_t scale = 22U; // scale should be in the range of 1 to 31
  Cy_PDM_PCM_Channel_Set_Fir1(PDM0, channel_num, CY_PDM_PCM_CHAN_FIR1_DECIM_2, scale);
  CY_PDM_PCM_CHAN_FIR1_DECIM_2
  @ CY_PDM_PCM_CHAN_FIR1_DECIM_2
  FIR1 Filter PCM Frequency is 1/2 * PCM Frequency.
  Definition: cy_pdm_pcm_v2.h:220
  Cy_PDM_PCM_Channel_Set_Fir1
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Set_Fir1(PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_fir1_decimcode_t decimcode, uint8_t scale)
  Sets PDM-PCM FIR1 Filter Decimation code and Scale.
  Definition: cy_pdm_pcm_v2.h:767

## ◆ Cy_PDM_PCM_Channel_Set_DCblock()

__STATIC_INLINE void Cy_PDM_PCM_Channel_Set_DCblock | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_ch_dcblock_coef_t | coef
| ) |  |

Sets the DC blocker filter with programmable coefficient.

The filter is used to remove a DC component.

Parameters

  base | The pointer to the PDM-PCM instance address
  channel_num | Channel number for which DC block coef to be set.
  coef | coef value to be set. cy_en_pdm_pcm_ch_dcblock_coef_t.

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  Cy_PDM_PCM_Channel_Set_DCblock(PDM0, channel_num, CY_PDM_PCM_CHAN_DCBLOCK_CODE_8);
  CY_PDM_PCM_CHAN_DCBLOCK_CODE_8
  @ CY_PDM_PCM_CHAN_DCBLOCK_CODE_8
  DCBLOCK Filter alpha = 1 - (1/2^(12-3))
  Definition: cy_pdm_pcm_v2.h:231
  Cy_PDM_PCM_Channel_Set_DCblock
  __STATIC_INLINE void Cy_PDM_PCM_Channel_Set_DCblock(PDM_Type *base, uint8_t channel_num, cy_en_pdm_pcm_ch_dcblock_coef_t coef)
  Sets the DC blocker filter with programmable coefficient.
  Definition: cy_pdm_pcm_v2.h:792

## ◆ Cy_PDM_PCM_Channel_SetInterruptMask()

__STATIC_INLINE void Cy_PDM_PCM_Channel_SetInterruptMask | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | 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
  channel_num | Channel number
  interrupt | Interrupt bit mask Interrupt Masks.

Function Usage
  uint8_t channel_num = 0U;
  /* CY_PDM_PCM_INTR_MASK defines mask for all available interrupt sources.
  CY_PDM_PCM_INTR_RX_TRIGGER
  CY_PDM_PCM_INTR_RX_FIR_OVERFLOW
  CY_PDM_PCM_INTR_RX_OVERFLOW
  CY_PDM_PCM_INTR_RX_IF_OVERFLOW
  CY_PDM_PCM_INTR_RX_UNDERFLOW */
  Cy_PDM_PCM_Channel_SetInterruptMask(PDM0, channel_num, CY_PDM_PCM_INTR_MASK);
  Cy_PDM_PCM_Channel_SetInterruptMask
  __STATIC_INLINE void Cy_PDM_PCM_Channel_SetInterruptMask(PDM_Type *base, uint8_t channel_num, uint32_t interrupt)
  Sets one or more PDM-PCM interrupt factor bits (sets the INTR_MASK register).
  Definition: cy_pdm_pcm_v2.h:813

## ◆ Cy_PDM_PCM_Channel_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_GetInterruptMask | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Returns
  The interrupt bit mask Interrupt Masks.

## ◆ Cy_PDM_PCM_Channel_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_GetInterruptStatusMasked | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

(an INTR_MASKED register).

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Returns
  The interrupt bit mask Interrupt Masks.

Function Usage
  uint8_t channel_num = 0U;
  /* Cy_PDM_PCM_Init, Cy_PDM_PCM_Channel_Init and Cy_PDM_PCM_Channel_Enable are pre-requisites */
  volatile uint32_t int_stat;
  int_stat = Cy_PDM_PCM_Channel_GetInterruptStatusMasked(PDM0, ch);
  if(CY_PDM_PCM_INTR_RX_TRIGGER & int_stat)
  {
  for(i=0; i < RX_FIFO_TRIG_LEVEL; i++)
  {
  int32_t data = (int32_t)Cy_PDM_PCM_Channel_ReadFifo(PDM0, ch);
  // data can be stored and used as pcm data
  }
  }
  Cy_PDM_PCM_Channel_ClearInterrupt(PDM0, channel_num, CY_PDM_PCM_INTR_MASK);
  Cy_PDM_PCM_Channel_ClearInterrupt
  __STATIC_INLINE void Cy_PDM_PCM_Channel_ClearInterrupt(PDM_Type *base, uint8_t channel_num, uint32_t interrupt)
  Clears one or more PDM-PCM interrupt statuses (sets an INTR register's bits).
  Definition: cy_pdm_pcm_v2.h:893
  Cy_PDM_PCM_Channel_ReadFifo
  __STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_ReadFifo(PDM_Type const *base, uint8_t channel_num)
  Reads ("pops") one word from the output data FIFO.
  Definition: cy_pdm_pcm_v2.h:955
  Cy_PDM_PCM_Channel_GetInterruptStatusMasked
  __STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_GetInterruptStatusMasked(PDM_Type const *base, uint8_t channel_num)
  Reports the status of enabled (masked) PDM-PCM interrupt sources.
  Definition: cy_pdm_pcm_v2.h:852
  CY_PDM_PCM_INTR_RX_TRIGGER
  #define CY_PDM_PCM_INTR_RX_TRIGGER
  More entries in the RX FIFO than specified by Trigger Level.
  Definition: cy_pdm_pcm_v2.h:147

## ◆ Cy_PDM_PCM_Channel_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_GetInterruptStatus | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Returns
  The interrupt bit mask Interrupt Masks.

Function Usage
  uint8_t channel_num = 0U;
  /* Cy_PDM_PCM_Init, Cy_PDM_PCM_Channel_Init and Cy_PDM_PCM_Channel_Enable are pre-requisites */
  volatile uint32_t int_stat;
  int_stat = Cy_PDM_PCM_Channel_GetInterruptStatusMasked(PDM0, ch);
  if(CY_PDM_PCM_INTR_RX_TRIGGER & int_stat)
  {
  for(i=0; i < RX_FIFO_TRIG_LEVEL; i++)
  {
  int32_t data = (int32_t)Cy_PDM_PCM_Channel_ReadFifo(PDM0, ch);
  // data can be stored and used as pcm data
  }
  }
  Cy_PDM_PCM_Channel_ClearInterrupt(PDM0, channel_num, CY_PDM_PCM_INTR_MASK);

## ◆ Cy_PDM_PCM_Channel_ClearInterrupt()

__STATIC_INLINE void Cy_PDM_PCM_Channel_ClearInterrupt | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | 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
  channel_num | Channel number
  interrupt | The interrupt bit mask Interrupt Masks.

Function Usage
  uint8_t channel_num = 0U;
  /* CY_PDM_PCM_INTR_MASK defines mask for all available interrupt sources.
  CY_PDM_PCM_INTR_RX_TRIGGER
  CY_PDM_PCM_INTR_RX_FIR_OVERFLOW
  CY_PDM_PCM_INTR_RX_OVERFLOW
  CY_PDM_PCM_INTR_RX_IF_OVERFLOW
  CY_PDM_PCM_INTR_RX_UNDERFLOW */
  Cy_PDM_PCM_Channel_ClearInterrupt(PDM0, channel_num, CY_PDM_PCM_INTR_MASK);

## ◆ Cy_PDM_PCM_Channel_SetInterrupt()

__STATIC_INLINE void Cy_PDM_PCM_Channel_SetInterrupt | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | 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.
  channel_num | Channel number
  interrupt | The interrupt bit mask Interrupt Masks.

## ◆ Cy_PDM_PCM_Channel_GetNumInFifo()

__STATIC_INLINE uint8_t Cy_PDM_PCM_Channel_GetNumInFifo | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

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

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  uint8_t num_in_fifo = Cy_PDM_PCM_Channel_GetNumInFifo(PDM0, channel_num);
  Cy_PDM_PCM_Channel_GetNumInFifo
  __STATIC_INLINE uint8_t Cy_PDM_PCM_Channel_GetNumInFifo(PDM_Type const *base, uint8_t channel_num)
  Reports the current number of used words in the output data FIFO.
  Definition: cy_pdm_pcm_v2.h:935

## ◆ Cy_PDM_PCM_Channel_ReadFifo()

__STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_ReadFifo | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Returns
  The data word read from the FIFO is returned.

Function Usage
  uint8_t channel_num = 0U;
  /* Cy_PDM_PCM_Init, Cy_PDM_PCM_Channel_Init and Cy_PDM_PCM_Channel_Enable are pre-requisites */
  volatile uint32_t int_stat;
  int_stat = Cy_PDM_PCM_Channel_GetInterruptStatusMasked(PDM0, ch);
  if(CY_PDM_PCM_INTR_RX_TRIGGER & int_stat)
  {
  for(i=0; i < RX_FIFO_TRIG_LEVEL; i++)
  {
  int32_t data = (int32_t)Cy_PDM_PCM_Channel_ReadFifo(PDM0, ch);
  // data can be stored and used as pcm data
  }
  }
  Cy_PDM_PCM_Channel_ClearInterrupt(PDM0, channel_num, CY_PDM_PCM_INTR_MASK);

## ◆ Cy_PDM_PCM_Channel_FreezeFifo()

__STATIC_INLINE void Cy_PDM_PCM_Channel_FreezeFifo | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Freezes the RX FIFO (Debug purpose).

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  Cy_PDM_PCM_Channel_FreezeFifo(PDM0, channel_num);
  Cy_PDM_PCM_Channel_FreezeFifo
  __STATIC_INLINE void Cy_PDM_PCM_Channel_FreezeFifo(PDM_Type *base, uint8_t channel_num)
  Freezes the RX FIFO (Debug purpose).
  Definition: cy_pdm_pcm_v2.h:973

## ◆ Cy_PDM_PCM_Channel_UnfreezeFifo()

__STATIC_INLINE void Cy_PDM_PCM_Channel_UnfreezeFifo | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Unfreezes the RX FIFO (Debug purpose).

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  Cy_PDM_PCM_Channel_UnfreezeFifo(PDM0, channel_num);
  Cy_PDM_PCM_Channel_UnfreezeFifo
  __STATIC_INLINE void Cy_PDM_PCM_Channel_UnfreezeFifo(PDM_Type *base, uint8_t channel_num)
  Unfreezes the RX FIFO (Debug purpose).
  Definition: cy_pdm_pcm_v2.h:992

## ◆ Cy_PDM_PCM_Channel_ReadFifoSilent()

__STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_ReadFifoSilent | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | Pointer to PDM-PCM instance address.
  channel_num | Channel number

Returns
  Silent FIFO value is read and returned.

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  Cy_PDM_PCM_Channel_ReadFifoSilent(PDM0, channel_num);
  Cy_PDM_PCM_Channel_ReadFifoSilent
  __STATIC_INLINE uint32_t Cy_PDM_PCM_Channel_ReadFifoSilent(PDM_Type const *base, uint8_t channel_num)
  Reads the RX FIFO silent (without touching the FIFO function).
  Definition: cy_pdm_pcm_v2.h:1012

## ◆ Cy_PDM_PCM_DCBlock_Enable()

__STATIC_INLINE void Cy_PDM_PCM_DCBlock_Enable | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Enable DC Block Filter for the given channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | The channel number.

## ◆ Cy_PDM_PCM_DCBlock_Disable()

__STATIC_INLINE void Cy_PDM_PCM_DCBlock_Disable | ( | PDM_Type * | base,
|  | uint8_t | channel_num
| ) |  |

Disable DC Block Filter for the given channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | The channel number.

## ◆ Cy_PDM_PCM_SetFIR0_Scale()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_SetFIR0_Scale | ( | PDM_Type * | base,
|  | uint8_t | channel_num,
|  | cy_en_pdm_pcm_gain_sel_t | scale
| ) |  |

Sets the FIR0 Scale factor for the given channel.

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | The channel number for gain setting.
  scale | scale value defined as cy_en_pdm_pcm_gain_scale_t

## ◆ Cy_PDM_PCM_ApplyPCM_Gain()

cy_en_pdm_pcm_status_t Cy_PDM_PCM_ApplyPCM_Gain | ( | const int32_t * | in_sample,
|  | int32_t | gain_db,
|  | cy_en_pdm_pcm_format_t | out_format,
|  | int32_t * | out_sample
| ) |  |

This function applies gain in software to one 24-bit PCM sample data output PCM format can be 24-bit or 16-bit, gain should be in the range of -40db to 40db.

Parameters

  in_sample | The pointer to the 24-bit PCM input.
  gain_db | The gain to apply. must be within -40db to +40db.
  out_format | PCM output format defined as cy_en_pdm_pcm_format_t
  out_sample | pointer to output PCM. For 16-bit out format, lower 16-bits holds data.

## ◆ Cy_PDM_PCM_Channel_GetCurrentState()

__STATIC_INLINE bool Cy_PDM_PCM_Channel_GetCurrentState | ( | PDM_Type const * | base,
|  | uint8_t | channel_num
| ) |  |

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

Parameters

  base | The pointer to the PDM-PCM instance address.
  channel_num | Channel number

Returns
  true if channel is active, false when stopped.

Function Usage
  uint8_t channel_num = 0U; // Channel number used.
  bool channel_state = Cy_PDM_PCM_Channel_GetCurrentState(PDM0, channel_num);
  Cy_PDM_PCM_Channel_GetCurrentState
  __STATIC_INLINE bool Cy_PDM_PCM_Channel_GetCurrentState(PDM_Type const *base, uint8_t channel_num)
  Returns the current PDM-PCM state (active/stopped).
  Definition: cy_pdm_pcm_v2.h:679