The MCUXpresso SDK provides a peripheral driver for the Microphone Interface (PDM) module of MCUXpresso SDK devices.
PDM driver includes functional APIs and transactional APIs.
Functional APIs target low-level APIs. Functional APIs can be used for PDM initialization, configuration, and operation for the optimization and customization purpose. Using the functional API requires the knowledge of the PDM peripheral and how to organize functional APIs to meet the application requirements. All functional API use the peripheral base address as the first parameter. PDM functional operation groups provide the functional API set.
Transactional APIs target high-level APIs. Transactional APIs can be used to enable the peripheral and in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are a critical requirement, see the transactional API implementation and write a custom code. Initialize the handle by calling the PDM_TransferCreateHandle() API.
Transactional APIs support asynchronous transfer. This means that the functions PDM_TransferReceiveNonBlocking() set up the interrupt for data transfer. When the transfer completes, the upper layer is notified through a callback function with kStatus_PDM_Idle status.
Typical use case
PDM receive using an interrupt method
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm_interrupt
PDM receive using a SDMA method
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sdma_transfer
PDM receive using a EDMA method
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_edma_transfer Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sai_edma Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sai_multi_channel_edma
PDM receive using a transactional method
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_interrupt_transfer
|
enum | {
kStatus_PDM_Busy = MAKE_STATUS(kStatusGroup_PDM, 0),
kStatus_PDM_CLK_LOW = MAKE_STATUS(kStatusGroup_PDM, 1),
kStatus_PDM_FIFO_ERROR = MAKE_STATUS(kStatusGroup_PDM, 2),
kStatus_PDM_QueueFull = MAKE_STATUS(kStatusGroup_PDM, 3),
kStatus_PDM_Idle = MAKE_STATUS(kStatusGroup_PDM, 4),
kStatus_PDM_Output_ERROR = MAKE_STATUS(kStatusGroup_PDM, 5),
kStatus_PDM_ChannelConfig_Failed = MAKE_STATUS(kStatusGroup_PDM, 6)
} |
| PDM return status. More...
|
|
enum | _pdm_interrupt_enable {
kPDM_ErrorInterruptEnable = PDM_CTRL_1_ERREN_MASK,
kPDM_FIFOInterruptEnable = PDM_CTRL_1_DISEL(2U)
} |
| The PDM interrupt enable flag. More...
|
|
enum | _pdm_internal_status {
kPDM_StatusDfBusyFlag = (int)PDM_STAT_BSY_FIL_MASK,
kPDM_StatusFIRFilterReady = PDM_STAT_FIR_RDY_MASK,
kPDM_StatusFrequencyLow = PDM_STAT_LOWFREQF_MASK,
kPDM_StatusCh0FifoDataAvaliable = PDM_STAT_CH0F_MASK,
kPDM_StatusCh1FifoDataAvaliable = PDM_STAT_CH1F_MASK,
kPDM_StatusCh2FifoDataAvaliable = PDM_STAT_CH2F_MASK,
kPDM_StatusCh3FifoDataAvaliable = PDM_STAT_CH3F_MASK,
kPDM_StatusCh4FifoDataAvaliable = PDM_STAT_CH4F_MASK,
kPDM_StatusCh5FifoDataAvaliable = PDM_STAT_CH5F_MASK,
kPDM_StatusCh6FifoDataAvaliable = PDM_STAT_CH6F_MASK,
kPDM_StatusCh7FifoDataAvaliable = PDM_STAT_CH7F_MASK
} |
| The PDM status. More...
|
|
enum | _pdm_channel_enable_mask {
kPDM_EnableChannel0 = PDM_STAT_CH0F_MASK,
kPDM_EnableChannel1 = PDM_STAT_CH1F_MASK,
kPDM_EnableChannel2 = PDM_STAT_CH2F_MASK,
kPDM_EnableChannel3 = PDM_STAT_CH3F_MASK,
kPDM_EnableChannel4 = PDM_STAT_CH4F_MASK,
kPDM_EnableChannel5 = PDM_STAT_CH5F_MASK,
kPDM_EnableChannel6 = PDM_STAT_CH6F_MASK,
kPDM_EnableChannel7 = PDM_STAT_CH7F_MASK
} |
| PDM channel enable mask. More...
|
|
enum | _pdm_fifo_status {
kPDM_FifoStatusUnderflowCh0 = PDM_FIFO_STAT_FIFOUND0_MASK,
kPDM_FifoStatusUnderflowCh1 = PDM_FIFO_STAT_FIFOUND1_MASK,
kPDM_FifoStatusUnderflowCh2 = PDM_FIFO_STAT_FIFOUND2_MASK,
kPDM_FifoStatusUnderflowCh3 = PDM_FIFO_STAT_FIFOUND3_MASK,
kPDM_FifoStatusUnderflowCh4 = PDM_FIFO_STAT_FIFOUND4_MASK,
kPDM_FifoStatusUnderflowCh5 = PDM_FIFO_STAT_FIFOUND5_MASK,
kPDM_FifoStatusUnderflowCh6 = PDM_FIFO_STAT_FIFOUND6_MASK,
kPDM_FifoStatusUnderflowCh7 = PDM_FIFO_STAT_FIFOUND6_MASK,
kPDM_FifoStatusOverflowCh0 = PDM_FIFO_STAT_FIFOOVF0_MASK,
kPDM_FifoStatusOverflowCh1 = PDM_FIFO_STAT_FIFOOVF1_MASK,
kPDM_FifoStatusOverflowCh2 = PDM_FIFO_STAT_FIFOOVF2_MASK,
kPDM_FifoStatusOverflowCh3 = PDM_FIFO_STAT_FIFOOVF3_MASK,
kPDM_FifoStatusOverflowCh4 = PDM_FIFO_STAT_FIFOOVF4_MASK,
kPDM_FifoStatusOverflowCh5 = PDM_FIFO_STAT_FIFOOVF5_MASK,
kPDM_FifoStatusOverflowCh6 = PDM_FIFO_STAT_FIFOOVF6_MASK,
kPDM_FifoStatusOverflowCh7 = PDM_FIFO_STAT_FIFOOVF7_MASK
} |
| The PDM fifo status. More...
|
|
enum | _pdm_range_status {
kPDM_RangeStatusUnderFlowCh0 = PDM_RANGE_STAT_RANGEUNF0_MASK,
kPDM_RangeStatusUnderFlowCh1 = PDM_RANGE_STAT_RANGEUNF1_MASK,
kPDM_RangeStatusUnderFlowCh2 = PDM_RANGE_STAT_RANGEUNF2_MASK,
kPDM_RangeStatusUnderFlowCh3 = PDM_RANGE_STAT_RANGEUNF3_MASK,
kPDM_RangeStatusUnderFlowCh4 = PDM_RANGE_STAT_RANGEUNF4_MASK,
kPDM_RangeStatusUnderFlowCh5 = PDM_RANGE_STAT_RANGEUNF5_MASK,
kPDM_RangeStatusUnderFlowCh6 = PDM_RANGE_STAT_RANGEUNF6_MASK,
kPDM_RangeStatusUnderFlowCh7 = PDM_RANGE_STAT_RANGEUNF7_MASK,
kPDM_RangeStatusOverFlowCh0 = PDM_RANGE_STAT_RANGEOVF0_MASK,
kPDM_RangeStatusOverFlowCh1 = PDM_RANGE_STAT_RANGEOVF1_MASK,
kPDM_RangeStatusOverFlowCh2 = PDM_RANGE_STAT_RANGEOVF2_MASK,
kPDM_RangeStatusOverFlowCh3 = PDM_RANGE_STAT_RANGEOVF3_MASK,
kPDM_RangeStatusOverFlowCh4 = PDM_RANGE_STAT_RANGEOVF4_MASK,
kPDM_RangeStatusOverFlowCh5 = PDM_RANGE_STAT_RANGEOVF5_MASK,
kPDM_RangeStatusOverFlowCh6 = PDM_RANGE_STAT_RANGEOVF6_MASK,
kPDM_RangeStatusOverFlowCh7 = PDM_RANGE_STAT_RANGEOVF7_MASK
} |
| The PDM output status. More...
|
|
enum | pdm_dc_remover_t {
kPDM_DcRemoverCutOff21Hz = 0U,
kPDM_DcRemoverCutOff83Hz = 1U,
kPDM_DcRemoverCutOff152Hz = 2U,
kPDM_DcRemoverBypass = 3U
} |
| PDM DC remover configurations. More...
|
|
enum | pdm_df_quality_mode_t {
kPDM_QualityModeMedium = 0U,
kPDM_QualityModeHigh = 1U,
kPDM_QualityModeLow = 7U,
kPDM_QualityModeVeryLow0 = 6U,
kPDM_QualityModeVeryLow1 = 5U,
kPDM_QualityModeVeryLow2 = 4U
} |
| PDM decimation filter quality mode. More...
|
|
enum | _pdm_qulaity_mode_k_factor {
kPDM_QualityModeHighKFactor = 1U,
kPDM_QualityModeMediumKFactor = 2U,
kPDM_QualityModeLowKFactor = 4U,
kPDM_QualityModeVeryLow2KFactor = 8U
} |
| PDM quality mode K factor. More...
|
|
enum | pdm_df_output_gain_t {
kPDM_DfOutputGain0 = 0U,
kPDM_DfOutputGain1 = 1U,
kPDM_DfOutputGain2 = 2U,
kPDM_DfOutputGain3 = 3U,
kPDM_DfOutputGain4 = 4U,
kPDM_DfOutputGain5 = 5U,
kPDM_DfOutputGain6 = 6U,
kPDM_DfOutputGain7 = 7U,
kPDM_DfOutputGain8 = 8U,
kPDM_DfOutputGain9 = 9U,
kPDM_DfOutputGain10 = 0xAU,
kPDM_DfOutputGain11 = 0xBU,
kPDM_DfOutputGain12 = 0xCU,
kPDM_DfOutputGain13 = 0xDU,
kPDM_DfOutputGain14 = 0xEU,
kPDM_DfOutputGain15 = 0xFU
} |
| PDM decimation filter output gain. More...
|
|
enum | _pdm_data_width {
kPDM_DataWwidth24 = 3U,
kPDM_DataWwidth32 = 4U
} |
| PDM data width. More...
|
|
enum | _pdm_hwvad_interrupt_enable {
kPDM_HwvadErrorInterruptEnable = PDM_VAD0_CTRL_1_VADERIE_MASK,
kPDM_HwvadInterruptEnable = PDM_VAD0_CTRL_1_VADIE_MASK
} |
| PDM voice activity detector interrupt type. More...
|
|
enum | _pdm_hwvad_int_status {
kPDM_HwvadStatusInputSaturation = PDM_VAD0_STAT_VADINSATF_MASK,
kPDM_HwvadStatusVoiceDetectFlag = PDM_VAD0_STAT_VADIF_MASK
} |
| The PDM hwvad interrupt status flag. More...
|
|
enum | pdm_hwvad_hpf_config_t {
kPDM_HwvadHpfBypassed = 0x0U,
kPDM_HwvadHpfCutOffFreq1750Hz = 0x1U,
kPDM_HwvadHpfCutOffFreq215Hz = 0x2U,
kPDM_HwvadHpfCutOffFreq102Hz = 0x3U
} |
| High pass filter configure cut-off frequency. More...
|
|
enum | pdm_hwvad_filter_status_t {
kPDM_HwvadInternalFilterNormalOperation = 0U,
kPDM_HwvadInternalFilterInitial = PDM_VAD0_CTRL_1_VADST10_MASK
} |
| HWVAD internal filter status. More...
|
|
enum | pdm_hwvad_zcd_result_t {
kPDM_HwvadResultOREnergyBasedDetection,
kPDM_HwvadResultANDEnergyBasedDetection
} |
| PDM voice activity detector zero cross detector result. More...
|
|
|
void | PDM_Init (PDM_Type *base, const pdm_config_t *config) |
| Initializes the PDM peripheral. More...
|
|
void | PDM_Deinit (PDM_Type *base) |
| De-initializes the PDM peripheral. More...
|
|
static void | PDM_Reset (PDM_Type *base) |
| Resets the PDM module. More...
|
|
static void | PDM_Enable (PDM_Type *base, bool enable) |
| Enables/disables PDM interface. More...
|
|
static void | PDM_EnableDoze (PDM_Type *base, bool enable) |
| Enables/disables DOZE. More...
|
|
static void | PDM_EnableDebugMode (PDM_Type *base, bool enable) |
| Enables/disables debug mode for PDM. More...
|
|
static void | PDM_EnableInDebugMode (PDM_Type *base, bool enable) |
| Enables/disables PDM interface in debug mode. More...
|
|
static void | PDM_EnterLowLeakageMode (PDM_Type *base, bool enable) |
| Enables/disables PDM interface disable/Low Leakage mode. More...
|
|
static void | PDM_EnableChannel (PDM_Type *base, uint8_t channel, bool enable) |
| Enables/disables the PDM channel. More...
|
|
void | PDM_SetChannelConfig (PDM_Type *base, uint32_t channel, const pdm_channel_config_t *config) |
| PDM one channel configurations. More...
|
|
status_t | PDM_SetSampleRateConfig (PDM_Type *base, uint32_t sourceClock_HZ, uint32_t sampleRate_HZ) |
| PDM set sample rate. More...
|
|
status_t | PDM_SetSampleRate (PDM_Type *base, uint32_t enableChannelMask, pdm_df_quality_mode_t qualityMode, uint8_t osr, uint32_t clkDiv) |
| PDM set sample rate. More...
|
|
uint32_t | PDM_GetInstance (PDM_Type *base) |
| Get the instance number for PDM. More...
|
|
|
void | PDM_ReadFifo (PDM_Type *base, uint32_t startChannel, uint32_t channelNums, void *buffer, size_t size, uint32_t dataWidth) |
| PDM read fifo. More...
|
|
static uint32_t | PDM_ReadData (PDM_Type *base, uint32_t channel) |
| Reads data from the PDM FIFO. More...
|
|
|
void | PDM_SetHwvadConfig (PDM_Type *base, const pdm_hwvad_config_t *config) |
| Configure voice activity detector. More...
|
|
static void | PDM_ForceHwvadOutputDisable (PDM_Type *base, bool enable) |
| PDM hwvad force output disable. More...
|
|
static void | PDM_ResetHwvad (PDM_Type *base) |
| PDM hwvad reset. More...
|
|
static void | PDM_EnableHwvad (PDM_Type *base, bool enable) |
| Enable/Disable Voice activity detector. More...
|
|
static void | PDM_EnableHwvadInterrupts (PDM_Type *base, uint32_t mask) |
| Enables the PDM Voice Detector interrupt requests. More...
|
|
static void | PDM_DisableHwvadInterrupts (PDM_Type *base, uint32_t mask) |
| Disables the PDM Voice Detector interrupt requests. More...
|
|
static void | PDM_ClearHwvadInterruptStatusFlags (PDM_Type *base, uint32_t mask) |
| Clears the PDM voice activity detector status flags. More...
|
|
static uint32_t | PDM_GetHwvadInterruptStatusFlags (PDM_Type *base) |
| Clears the PDM voice activity detector status flags. More...
|
|
static uint32_t | PDM_GetHwvadInitialFlag (PDM_Type *base) |
| Get the PDM voice activity detector initial flags. More...
|
|
static uint32_t | PDM_GetHwvadVoiceDetectedFlag (PDM_Type *base) |
| Get the PDM voice activity detector voice detected flags. More...
|
|
static void | PDM_EnableHwvadSignalFilter (PDM_Type *base, bool enable) |
| Enables/disables voice activity detector signal filter. More...
|
|
void | PDM_SetHwvadSignalFilterConfig (PDM_Type *base, bool enableMaxBlock, uint32_t signalGain) |
| Configure voice activity detector signal filter. More...
|
|
void | PDM_SetHwvadNoiseFilterConfig (PDM_Type *base, const pdm_hwvad_noise_filter_t *config) |
| Configure voice activity detector noise filter. More...
|
|
static void | PDM_EnableHwvadZeroCrossDetector (PDM_Type *base, bool enable) |
| Enables/disables voice activity detector zero cross detector. More...
|
|
void | PDM_SetHwvadZeroCrossDetectorConfig (PDM_Type *base, const pdm_hwvad_zero_cross_detector_t *config) |
| Configure voice activity detector zero cross detector. More...
|
|
static uint16_t | PDM_GetNoiseData (PDM_Type *base) |
| Reads noise data. More...
|
|
static void | PDM_SetHwvadInternalFilterStatus (PDM_Type *base, pdm_hwvad_filter_status_t status) |
| set hwvad internal filter status . More...
|
|
void | PDM_SetHwvadInEnvelopeBasedMode (PDM_Type *base, const pdm_hwvad_config_t *hwvadConfig, const pdm_hwvad_noise_filter_t *noiseConfig, const pdm_hwvad_zero_cross_detector_t *zcdConfig, uint32_t signalGain) |
| set HWVAD in envelope based mode . More...
|
|
void | PDM_SetHwvadInEnergyBasedMode (PDM_Type *base, const pdm_hwvad_config_t *hwvadConfig, const pdm_hwvad_noise_filter_t *noiseConfig, const pdm_hwvad_zero_cross_detector_t *zcdConfig, uint32_t signalGain) |
| brief set HWVAD in energy based mode . More...
|
|
|
void | PDM_TransferCreateHandle (PDM_Type *base, pdm_handle_t *handle, pdm_transfer_callback_t callback, void *userData) |
| Initializes the PDM handle. More...
|
|
status_t | PDM_TransferSetChannelConfig (PDM_Type *base, pdm_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config, uint32_t format) |
| PDM set channel transfer config. More...
|
|
status_t | PDM_TransferReceiveNonBlocking (PDM_Type *base, pdm_handle_t *handle, pdm_transfer_t *xfer) |
| Performs an interrupt non-blocking receive transfer on PDM. More...
|
|
void | PDM_TransferAbortReceive (PDM_Type *base, pdm_handle_t *handle) |
| Aborts the current IRQ receive. More...
|
|
void | PDM_TransferHandleIRQ (PDM_Type *base, pdm_handle_t *handle) |
| Tx interrupt handler. More...
|
|
struct pdm_channel_config_t |
struct pdm_hwvad_config_t |
uint8_t pdm_hwvad_config_t::initializeTime |
struct pdm_hwvad_noise_filter_t |
struct pdm_hwvad_zero_cross_detector_t |
bool pdm_hwvad_zero_cross_detector_t::enableAutoThreshold |
Data Fields |
volatile uint8_t * | data |
| Data start address to transfer. More...
|
|
volatile size_t | dataSize |
| Total Transfer bytes size. More...
|
|
volatile uint8_t* pdm_transfer_t::data |
volatile size_t pdm_transfer_t::dataSize |
Enumerator |
---|
kStatus_PDM_Busy |
PDM is busy.
|
kStatus_PDM_CLK_LOW |
PDM clock frequency low.
|
kStatus_PDM_FIFO_ERROR |
PDM FIFO underrun or overflow.
|
kStatus_PDM_QueueFull |
PDM FIFO underrun or overflow.
|
kStatus_PDM_Idle |
PDM is idle.
|
kStatus_PDM_Output_ERROR |
PDM is output error.
|
kStatus_PDM_ChannelConfig_Failed |
PDM channel config failed.
|
Enumerator |
---|
kPDM_ErrorInterruptEnable |
PDM channel error interrupt enable.
|
kPDM_FIFOInterruptEnable |
PDM channel FIFO interrupt.
|
Enumerator |
---|
kPDM_StatusDfBusyFlag |
Decimation filter is busy processing data.
|
kPDM_StatusFIRFilterReady |
FIR filter data is ready.
|
kPDM_StatusFrequencyLow |
Mic app clock frequency not high enough.
|
kPDM_StatusCh0FifoDataAvaliable |
channel 0 fifo data reached watermark level
|
kPDM_StatusCh1FifoDataAvaliable |
channel 1 fifo data reached watermark level
|
kPDM_StatusCh2FifoDataAvaliable |
channel 2 fifo data reached watermark level
|
kPDM_StatusCh3FifoDataAvaliable |
channel 3 fifo data reached watermark level
|
kPDM_StatusCh4FifoDataAvaliable |
channel 4 fifo data reached watermark level
|
kPDM_StatusCh5FifoDataAvaliable |
channel 5 fifo data reached watermark level
|
kPDM_StatusCh6FifoDataAvaliable |
channel 6 fifo data reached watermark level
|
kPDM_StatusCh7FifoDataAvaliable |
channel 7 fifo data reached watermark level
|
Enumerator |
---|
kPDM_EnableChannel0 |
channgel 0 enable mask
|
kPDM_EnableChannel1 |
channgel 1 enable mask
|
kPDM_EnableChannel2 |
channgel 2 enable mask
|
kPDM_EnableChannel3 |
channgel 3 enable mask
|
kPDM_EnableChannel4 |
channgel 4 enable mask
|
kPDM_EnableChannel5 |
channgel 5 enable mask
|
kPDM_EnableChannel6 |
channgel 6 enable mask
|
kPDM_EnableChannel7 |
channgel 7 enable mask
|
Enumerator |
---|
kPDM_FifoStatusUnderflowCh0 |
channel0 fifo status underflow
|
kPDM_FifoStatusUnderflowCh1 |
channel1 fifo status underflow
|
kPDM_FifoStatusUnderflowCh2 |
channel2 fifo status underflow
|
kPDM_FifoStatusUnderflowCh3 |
channel3 fifo status underflow
|
kPDM_FifoStatusUnderflowCh4 |
channel4 fifo status underflow
|
kPDM_FifoStatusUnderflowCh5 |
channel5 fifo status underflow
|
kPDM_FifoStatusUnderflowCh6 |
channel6 fifo status underflow
|
kPDM_FifoStatusUnderflowCh7 |
channel7 fifo status underflow
|
kPDM_FifoStatusOverflowCh0 |
channel0 fifo status overflow
|
kPDM_FifoStatusOverflowCh1 |
channel1 fifo status overflow
|
kPDM_FifoStatusOverflowCh2 |
channel2 fifo status overflow
|
kPDM_FifoStatusOverflowCh3 |
channel3 fifo status overflow
|
kPDM_FifoStatusOverflowCh4 |
channel4 fifo status overflow
|
kPDM_FifoStatusOverflowCh5 |
channel5 fifo status overflow
|
kPDM_FifoStatusOverflowCh6 |
channel6 fifo status overflow
|
kPDM_FifoStatusOverflowCh7 |
channel7 fifo status overflow
|
Enumerator |
---|
kPDM_RangeStatusUnderFlowCh0 |
channel0 range status underflow
|
kPDM_RangeStatusUnderFlowCh1 |
channel1 range status underflow
|
kPDM_RangeStatusUnderFlowCh2 |
channel2 range status underflow
|
kPDM_RangeStatusUnderFlowCh3 |
channel3 range status underflow
|
kPDM_RangeStatusUnderFlowCh4 |
channel4 range status underflow
|
kPDM_RangeStatusUnderFlowCh5 |
channel5 range status underflow
|
kPDM_RangeStatusUnderFlowCh6 |
channel6 range status underflow
|
kPDM_RangeStatusUnderFlowCh7 |
channel7 range status underflow
|
kPDM_RangeStatusOverFlowCh0 |
channel0 range status overflow
|
kPDM_RangeStatusOverFlowCh1 |
channel1 range status overflow
|
kPDM_RangeStatusOverFlowCh2 |
channel2 range status overflow
|
kPDM_RangeStatusOverFlowCh3 |
channel3 range status overflow
|
kPDM_RangeStatusOverFlowCh4 |
channel4 range status overflow
|
kPDM_RangeStatusOverFlowCh5 |
channel5 range status overflow
|
kPDM_RangeStatusOverFlowCh6 |
channel6 range status overflow
|
kPDM_RangeStatusOverFlowCh7 |
channel7 range status overflow
|
Enumerator |
---|
kPDM_DcRemoverCutOff21Hz |
DC remover cut off 21HZ.
|
kPDM_DcRemoverCutOff83Hz |
DC remover cut off 83HZ.
|
kPDM_DcRemoverCutOff152Hz |
DC remover cut off 152HZ.
|
kPDM_DcRemoverBypass |
DC remover bypass.
|
Enumerator |
---|
kPDM_QualityModeMedium |
quality mode memdium
|
kPDM_QualityModeHigh |
quality mode high
|
kPDM_QualityModeLow |
quality mode low
|
kPDM_QualityModeVeryLow0 |
quality mode very low0
|
kPDM_QualityModeVeryLow1 |
quality mode very low1
|
kPDM_QualityModeVeryLow2 |
quality mode very low2
|
Enumerator |
---|
kPDM_QualityModeHighKFactor |
high quality mode K factor = 1 / 2
|
kPDM_QualityModeMediumKFactor |
medium/very low0 quality mode K factor = 2 / 2
|
kPDM_QualityModeLowKFactor |
low/very low1 quality mode K factor = 4 / 2
|
kPDM_QualityModeVeryLow2KFactor |
very low2 quality mode K factor = 8 / 2
|
Enumerator |
---|
kPDM_DfOutputGain0 |
Decimation filter output gain 0.
|
kPDM_DfOutputGain1 |
Decimation filter output gain 1.
|
kPDM_DfOutputGain2 |
Decimation filter output gain 2.
|
kPDM_DfOutputGain3 |
Decimation filter output gain 3.
|
kPDM_DfOutputGain4 |
Decimation filter output gain 4.
|
kPDM_DfOutputGain5 |
Decimation filter output gain 5.
|
kPDM_DfOutputGain6 |
Decimation filter output gain 6.
|
kPDM_DfOutputGain7 |
Decimation filter output gain 7.
|
kPDM_DfOutputGain8 |
Decimation filter output gain 8.
|
kPDM_DfOutputGain9 |
Decimation filter output gain 9.
|
kPDM_DfOutputGain10 |
Decimation filter output gain 10.
|
kPDM_DfOutputGain11 |
Decimation filter output gain 11.
|
kPDM_DfOutputGain12 |
Decimation filter output gain 12.
|
kPDM_DfOutputGain13 |
Decimation filter output gain 13.
|
kPDM_DfOutputGain14 |
Decimation filter output gain 14.
|
kPDM_DfOutputGain15 |
Decimation filter output gain 15.
|
Enumerator |
---|
kPDM_DataWwidth24 |
PDM data width 24bit.
|
kPDM_DataWwidth32 |
PDM data width 32bit.
|
Enumerator |
---|
kPDM_HwvadErrorInterruptEnable |
PDM channel HWVAD error interrupt enable.
|
kPDM_HwvadInterruptEnable |
PDM channel HWVAD interrupt.
|
Enumerator |
---|
kPDM_HwvadStatusInputSaturation |
HWVAD saturation condition.
|
kPDM_HwvadStatusVoiceDetectFlag |
HWVAD voice detect interrupt triggered.
|
Enumerator |
---|
kPDM_HwvadHpfBypassed |
High-pass filter bypass.
|
kPDM_HwvadHpfCutOffFreq1750Hz |
High-pass filter cut off frequency 1750HZ.
|
kPDM_HwvadHpfCutOffFreq215Hz |
High-pass filter cut off frequency 215HZ.
|
kPDM_HwvadHpfCutOffFreq102Hz |
High-pass filter cut off frequency 102HZ.
|
Enumerator |
---|
kPDM_HwvadInternalFilterNormalOperation |
internal filter ready for normal operation
|
kPDM_HwvadInternalFilterInitial |
interla filter are initial
|
Enumerator |
---|
kPDM_HwvadResultOREnergyBasedDetection |
zero cross detector result will be OR with energy based detection
|
kPDM_HwvadResultANDEnergyBasedDetection |
zero cross detector result will be AND with energy based detection
|
void PDM_Init |
( |
PDM_Type * |
base, |
|
|
const pdm_config_t * |
config |
|
) |
| |
Ungates the PDM clock, resets the module, and configures PDM with a configuration structure. The configuration structure can be custom filled or set with default values by PDM_GetDefaultConfig().
- Note
- This API should be called at the beginning of the application to use the PDM driver. Otherwise, accessing the PDM module can cause a hard fault because the clock is not enabled.
- Parameters
-
base | PDM base pointer |
config | PDM configuration structure. |
void PDM_Deinit |
( |
PDM_Type * |
base | ) |
|
This API gates the PDM clock. The PDM module can't operate unless PDM_Init is called to enable the clock.
- Parameters
-
static void PDM_Reset |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
static void PDM_Enable |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means PDM interface is enabled, false means PDM interface is disabled. |
static void PDM_EnableDoze |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means the module will enter Disable/Low Leakage mode when ipg_doze is asserted, false means the module will not enter Disable/Low Leakage mode when ipg_doze is asserted. |
static void PDM_EnableDebugMode |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
The PDM interface cannot enter debug mode once in Disable/Low Leakage or Low Power mode.
- Parameters
-
base | PDM base pointer |
enable | True means PDM interface enter debug mode, false means PDM interface in normal mode. |
static void PDM_EnableInDebugMode |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means PDM interface is enabled debug mode, false means PDM interface is disabled after after completing the current frame in debug mode. |
static void PDM_EnterLowLeakageMode |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means PDM interface is in disable/low leakage mode, False means PDM interface is in normal mode. |
static void PDM_EnableChannel |
( |
PDM_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
channel | PDM channel number need to enable or disable. |
enable | True means enable PDM channel, false means disable. |
void PDM_SetChannelConfig |
( |
PDM_Type * |
base, |
|
|
uint32_t |
channel, |
|
|
const pdm_channel_config_t * |
config |
|
) |
| |
- Parameters
-
base | PDM base pointer |
config | PDM channel configurations. |
channel | channel number. after completing the current frame in debug mode. |
status_t PDM_SetSampleRateConfig |
( |
PDM_Type * |
base, |
|
|
uint32_t |
sourceClock_HZ, |
|
|
uint32_t |
sampleRate_HZ |
|
) |
| |
- Note
- This function is depend on the configuration of the PDM and PDM channel, so the correct call sequence is
- Parameters
-
base | PDM base pointer |
sourceClock_HZ | PDM source clock frequency. |
sampleRate_HZ | PDM sample rate. |
- Deprecated:
- Do not use this function. It has been superceded by PDM_SetSampleRateConfig
- Parameters
-
base | PDM base pointer |
enableChannelMask | PDM channel enable mask. |
qualityMode | quality mode. |
osr | cic oversample rate |
clkDiv | clock divider |
uint32_t PDM_GetInstance |
( |
PDM_Type * |
base | ) |
|
static uint32_t PDM_GetStatus |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
Use the Status Mask in _pdm_internal_status to get the status value needed
- Parameters
-
- Returns
- PDM status flag value.
static uint32_t PDM_GetFifoStatus |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
Use the Status Mask in _pdm_fifo_status to get the status value needed
- Parameters
-
- Returns
- FIFO status.
static uint32_t PDM_GetRangeStatus |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
Use the Status Mask in _pdm_range_status to get the status value needed
- Parameters
-
- Returns
- output status.
static void PDM_ClearStatus |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | State mask. It can be a combination of the status between kPDM_StatusFrequencyLow and kPDM_StatusCh7FifoDataAvaliable. |
static void PDM_ClearFIFOStatus |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | State mask.It can be a combination of the status in _pdm_fifo_status. |
static void PDM_ClearRangeStatus |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | State mask. It can be a combination of the status in _pdm_range_status. |
void PDM_EnableInterrupts |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | PDM base pointer |
mask | interrupt source The parameter can be a combination of the following sources if defined.
- kPDM_ErrorInterruptEnable
- kPDM_FIFOInterruptEnable
|
static void PDM_DisableInterrupts |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | interrupt source The parameter can be a combination of the following sources if defined.
- kPDM_ErrorInterruptEnable
- kPDM_FIFOInterruptEnable
|
static void PDM_EnableDMA |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means enable DMA, false means disable DMA. |
static uint32_t PDM_GetDataRegisterAddress |
( |
PDM_Type * |
base, |
|
|
uint32_t |
channel |
|
) |
| |
|
inlinestatic |
This API is used to provide a transfer address for the PDM DMA transfer configuration.
- Parameters
-
base | PDM base pointer. |
channel | Which data channel used. |
- Returns
- data register address.
void PDM_ReadFifo |
( |
PDM_Type * |
base, |
|
|
uint32_t |
startChannel, |
|
|
uint32_t |
channelNums, |
|
|
void * |
buffer, |
|
|
size_t |
size, |
|
|
uint32_t |
dataWidth |
|
) |
| |
- Note
- : This function support 16 bit only for IP version that only supports 16bit.
- Parameters
-
base | PDM base pointer. |
startChannel | start channel number. |
channelNums | total enabled channelnums. |
buffer | received buffer address. |
size | number of samples to read. |
dataWidth | sample width. |
static uint32_t PDM_ReadData |
( |
PDM_Type * |
base, |
|
|
uint32_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer. |
channel | Data channel used. |
- Returns
- Data in PDM FIFO.
- Parameters
-
base | PDM base pointer |
config | Voice activity detector configure structure pointer . |
static void PDM_ForceHwvadOutputDisable |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | true is output force disable, false is output not force. |
static void PDM_ResetHwvad |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
It will reset VADNDATA register and will clean all internal buffers, should be called when the PDM isn't running.
- Parameters
-
static void PDM_EnableHwvad |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
Should be called when the PDM isn't running.
- Parameters
-
base | PDM base pointer. |
enable | True means enable voice activity detector, false means disable. |
static void PDM_EnableHwvadInterrupts |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | interrupt source The parameter can be a combination of the following sources if defined.
- kPDM_HWVADErrorInterruptEnable
- kPDM_HWVADInterruptEnable
|
static void PDM_DisableHwvadInterrupts |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | interrupt source The parameter can be a combination of the following sources if defined.
- kPDM_HWVADErrorInterruptEnable
- kPDM_HWVADInterruptEnable
|
static void PDM_ClearHwvadInterruptStatusFlags |
( |
PDM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
mask | State mask,reference _pdm_hwvad_int_status. |
static uint32_t PDM_GetHwvadInterruptStatusFlags |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- status, reference _pdm_hwvad_int_status
static uint32_t PDM_GetHwvadInitialFlag |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- initial flag.
static uint32_t PDM_GetHwvadVoiceDetectedFlag |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
NOte: this flag is auto cleared when voice gone.
- Parameters
-
- Returns
- voice detected flag.
static void PDM_EnableHwvadSignalFilter |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means enable signal filter, false means disable. |
void PDM_SetHwvadSignalFilterConfig |
( |
PDM_Type * |
base, |
|
|
bool |
enableMaxBlock, |
|
|
uint32_t |
signalGain |
|
) |
| |
- Parameters
-
base | PDM base pointer |
enableMaxBlock | If signal maximum block enabled. |
signalGain | Gain value for the signal energy. |
- Parameters
-
base | PDM base pointer |
config | Voice activity detector noise filter configure structure pointer . |
static void PDM_EnableHwvadZeroCrossDetector |
( |
PDM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PDM base pointer |
enable | True means enable zero cross detector, false means disable. |
- Parameters
-
base | PDM base pointer |
config | Voice activity detector zero cross detector configure structure pointer . |
static uint16_t PDM_GetNoiseData |
( |
PDM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- Data in PDM noise data register.
Note: filter initial status should be asserted for two more cycles, then set it to normal operation.
- Parameters
-
base | PDM base pointer. |
status | internal filter status. |
Recommand configurations,
* .initializeTime = 10U,
* .cicOverSampleRate = 0U,
* .inputGain = 0U,
* .frameTime = 10U,
* .enableFrameEnergy = false,
* .enablePreFilter = true,
};
* .enableNoiseMin = true,
* .enableNoiseDecimation = true,
* .noiseFilterAdjustment = 0U,
* .noiseGain = 7U,
* .enableNoiseDetectOR = true,
* };
*
- Parameters
-
base | PDM base pointer. |
hwvadConfig | internal filter status. |
noiseConfig | Voice activity detector noise filter configure structure pointer. |
zcdConfig | Voice activity detector zero cross detector configure structure pointer . |
signalGain | signal gain value. |
Recommand configurations, code static const pdm_hwvad_config_t hwvadConfig = { .channel = 0, .initializeTime = 10U, .cicOverSampleRate = 0U, .inputGain = 0U, .frameTime = 10U, .cutOffFreq = kPDM_HwvadHpfBypassed, .enableFrameEnergy = true, .enablePreFilter = true, };
static const pdm_hwvad_noise_filter_t noiseFilterConfig = { .enableAutoNoiseFilter = true, .enableNoiseMin = false, .enableNoiseDecimation = false, .noiseFilterAdjustment = 0U, .noiseGain = 7U, .enableNoiseDetectOR = false, }; code param base PDM base pointer. param hwvadConfig internal filter status. param noiseConfig Voice activity detector noise filter configure structure pointer. param zcdConfig Voice activity detector zero cross detector configure structure pointer . param signalGain signal gain value, signal gain value should be properly according to application.
void PDM_TransferCreateHandle |
( |
PDM_Type * |
base, |
|
|
pdm_handle_t * |
handle, |
|
|
pdm_transfer_callback_t |
callback, |
|
|
void * |
userData |
|
) |
| |
This function initializes the handle for the PDM transactional APIs. Call this function once to get the handle initialized.
- Parameters
-
base | PDM base pointer. |
handle | PDM handle pointer. |
callback | Pointer to the user callback function. |
userData | User parameter passed to the callback function. |
status_t PDM_TransferSetChannelConfig |
( |
PDM_Type * |
base, |
|
|
pdm_handle_t * |
handle, |
|
|
uint32_t |
channel, |
|
|
const pdm_channel_config_t * |
config, |
|
|
uint32_t |
format |
|
) |
| |
- Parameters
-
base | PDM base pointer. |
handle | PDM handle pointer. |
channel | PDM channel. |
config | channel config. |
format | data format, support data width configurations,_pdm_data_width. |
- Return values
-
kStatus_PDM_ChannelConfig_Failed | or kStatus_Success. |
- Note
- This API returns immediately after the transfer initiates. Call the PDM_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_PDM_Busy, the transfer is finished.
- Parameters
-
base | PDM base pointer |
handle | Pointer to the pdm_handle_t structure which stores the transfer state. |
xfer | Pointer to the pdm_transfer_t structure. |
- Return values
-
kStatus_Success | Successfully started the data receive. |
kStatus_PDM_Busy | Previous receive still not finished. |
void PDM_TransferAbortReceive |
( |
PDM_Type * |
base, |
|
|
pdm_handle_t * |
handle |
|
) |
| |
- Note
- This API can be called when an interrupt non-blocking transfer initiates to abort the transfer early.
- Parameters
-
base | PDM base pointer |
handle | Pointer to the pdm_handle_t structure which stores the transfer state. |
void PDM_TransferHandleIRQ |
( |
PDM_Type * |
base, |
|
|
pdm_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | PDM base pointer. |
handle | Pointer to the pdm_handle_t structure. |