MTB CAT1 Peripheral driver library

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...
 
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...
 
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...
 
void Cy_PDM_PCM_Channel_DeInit (PDM_Type *base, uint8_t channel_num)
 Uninitializes the PDM-PCM channel. More...
 
void Cy_PDM_PCM_DeInit (PDM_Type *base)
 Uninitializes the PDM-PCM module. 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 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 intialized before calling this function. Cy_PDM_PCM_Init
Parameters
baseThe pointer to the PDM-PCM instance address
channel_configThe pointer to a configuration structure.
channel_numThe 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_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
baseThe pointer to the PDM-PCM instance address
configThe 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_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
baseThe pointer to the PDM-PCM instance address
configThe pointer to a configuration structure. cy_stc_pdm_pcm_config_v2_t
test_configtest Mode configuration. cy_stc_test_config_t
Returns
error / status code. See cy_en_pdm_pcm_status_t.

◆ Cy_PDM_PCM_Channel_DeInit()

void Cy_PDM_PCM_Channel_DeInit ( PDM_Type base,
uint8_t  channel_num 
)

Uninitializes the PDM-PCM channel.

Parameters
baseThe pointer to the PDM-PCM instance address.
channel_numchannel 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_DeInit()

void Cy_PDM_PCM_DeInit ( PDM_Type base)

Uninitializes the PDM-PCM module.

Parameters
baseThe pointer to the PDM-PCM instance address.
Function Usage

◆ 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number to be activated
Function Usage
uint8_t channel_num = 0U;
Cy_PDM_PCM_Activate_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.

Parameters
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number to be deactivated
Function Usage
uint8_t channel_num = 0U;
Cy_PDM_PCM_DeActivate_Channel(PDM0, channel_num);

◆ 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
baseThe pointer to the PDM-PCM instance address.
rateHalve rate sampling or Full rate sampling cy_en_pdm_pcm_halve_rate_sel_t.
Function Usage

◆ 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number to be enabled
Function Usage
uint8_t channel_num = 0U;
Cy_PDM_PCM_Channel_Enable(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.

Parameters
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number to be disabled
Function Usage
uint8_t channel_num = 0U;
Cy_PDM_PCM_Channel_Disable(PDM0, channel_num);

◆ 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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number for which the CIC filter Decimation code to be set
decimcodedecimation 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_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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number for which the FIR0 Decimation code and the filter to be set.
decimcodeDecimation code value to be set. cy_en_pdm_pcm_ch_fir0_decimcode_t.
scaleScale 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()

__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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number for which the FIR1 Decimation code and the filter to be set.
decimcodeDecimation code value to be set. cy_en_pdm_pcm_ch_fir1_decimcode_t.
scaleScale 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_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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number for which DC block coef to be set.
coefcoef 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_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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number
interruptInterrupt 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_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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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;
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_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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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;
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
baseThe pointer to the PDM-PCM instance address
channel_numChannel number
interruptThe 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number
interruptThe 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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_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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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;
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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number
Function Usage
uint8_t channel_num = 0U; // Channel number used.
Cy_PDM_PCM_Channel_FreezeFifo(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).

Parameters
baseThe pointer to the PDM-PCM instance address.
channel_numChannel number
Function Usage
uint8_t channel_num = 0U; // Channel number used.
Cy_PDM_PCM_Channel_UnfreezeFifo(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).

Parameters
basePointer to PDM-PCM instance address.
channel_numChannel number
Returns
Silent FIFO value is read and returned.
Function Usage
uint8_t channel_num = 0U; // Channel number used.

◆ 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
baseThe pointer to the PDM-PCM instance address.
channel_numChannel 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);