RTEMS 6.1-rc2
Loading...
Searching...
No Matches
fsl_pdm.h
1/*
2 * Copyright (c) 2018, Freescale Semiconductor, Inc.
3 * Copyright 2019-2020 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_PDM_H_
10#define _FSL_PDM_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
25#define FSL_PDM_DRIVER_VERSION (MAKE_VERSION(2, 8, 0))
27
29#define PDM_XFER_QUEUE_SIZE (4U)
30
32enum
33{
35#if (defined(FSL_FEATURE_PDM_HAS_STATUS_LOW_FREQ) && (FSL_FEATURE_PDM_HAS_STATUS_LOW_FREQ == 1U))
36 kStatus_PDM_CLK_LOW = MAKE_STATUS(kStatusGroup_PDM, 1),
37#endif
43#if !(defined(FSL_FEATURE_PDM_HAS_NO_HWVAD) && FSL_FEATURE_PDM_HAS_NO_HWVAD)
46#endif
47};
48
51{
52 kPDM_ErrorInterruptEnable = PDM_CTRL_1_ERREN_MASK,
54};
55
58{
59 kPDM_StatusDfBusyFlag = (int)PDM_STAT_BSY_FIL_MASK,
60#if !(defined(FSL_FEATURE_PDM_HAS_NO_FIR_RDY) && FSL_FEATURE_PDM_HAS_NO_FIR_RDY)
61 kPDM_StatusFIRFilterReady = PDM_STAT_FIR_RDY_MASK,
62#endif
63#if (defined(FSL_FEATURE_PDM_HAS_STATUS_LOW_FREQ) && (FSL_FEATURE_PDM_HAS_STATUS_LOW_FREQ == 1U))
64 kPDM_StatusFrequencyLow = PDM_STAT_LOWFREQF_MASK,
65#endif
66 kPDM_StatusCh0FifoDataAvaliable = PDM_STAT_CH0F_MASK,
67 kPDM_StatusCh1FifoDataAvaliable = PDM_STAT_CH1F_MASK,
68 kPDM_StatusCh2FifoDataAvaliable = PDM_STAT_CH2F_MASK,
69 kPDM_StatusCh3FifoDataAvaliable = PDM_STAT_CH3F_MASK,
70#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
71 kPDM_StatusCh4FifoDataAvaliable = PDM_STAT_CH4F_MASK,
72 kPDM_StatusCh5FifoDataAvaliable = PDM_STAT_CH5F_MASK,
73 kPDM_StatusCh6FifoDataAvaliable = PDM_STAT_CH6F_MASK,
74 kPDM_StatusCh7FifoDataAvaliable = PDM_STAT_CH7F_MASK,
75#endif
76};
77
80{
81 kPDM_EnableChannel0 = PDM_STAT_CH0F_MASK,
82 kPDM_EnableChannel1 = PDM_STAT_CH1F_MASK,
83 kPDM_EnableChannel2 = PDM_STAT_CH2F_MASK,
84 kPDM_EnableChannel3 = PDM_STAT_CH3F_MASK,
85#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
86 kPDM_EnableChannel4 = PDM_STAT_CH4F_MASK,
87 kPDM_EnableChannel5 = PDM_STAT_CH5F_MASK,
88 kPDM_EnableChannel6 = PDM_STAT_CH6F_MASK,
89 kPDM_EnableChannel7 = PDM_STAT_CH7F_MASK,
93#else
95#endif
96};
97
100{
101 kPDM_FifoStatusUnderflowCh0 = PDM_FIFO_STAT_FIFOUND0_MASK,
102 kPDM_FifoStatusUnderflowCh1 = PDM_FIFO_STAT_FIFOUND1_MASK,
103 kPDM_FifoStatusUnderflowCh2 = PDM_FIFO_STAT_FIFOUND2_MASK,
104 kPDM_FifoStatusUnderflowCh3 = PDM_FIFO_STAT_FIFOUND3_MASK,
105#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
106 kPDM_FifoStatusUnderflowCh4 = PDM_FIFO_STAT_FIFOUND4_MASK,
107 kPDM_FifoStatusUnderflowCh5 = PDM_FIFO_STAT_FIFOUND5_MASK,
108 kPDM_FifoStatusUnderflowCh6 = PDM_FIFO_STAT_FIFOUND6_MASK,
109 kPDM_FifoStatusUnderflowCh7 = PDM_FIFO_STAT_FIFOUND6_MASK,
110#endif
111
112 kPDM_FifoStatusOverflowCh0 = PDM_FIFO_STAT_FIFOOVF0_MASK,
113 kPDM_FifoStatusOverflowCh1 = PDM_FIFO_STAT_FIFOOVF1_MASK,
114 kPDM_FifoStatusOverflowCh2 = PDM_FIFO_STAT_FIFOOVF2_MASK,
115 kPDM_FifoStatusOverflowCh3 = PDM_FIFO_STAT_FIFOOVF3_MASK,
116#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
117 kPDM_FifoStatusOverflowCh4 = PDM_FIFO_STAT_FIFOOVF4_MASK,
118 kPDM_FifoStatusOverflowCh5 = PDM_FIFO_STAT_FIFOOVF5_MASK,
119 kPDM_FifoStatusOverflowCh6 = PDM_FIFO_STAT_FIFOOVF6_MASK,
120 kPDM_FifoStatusOverflowCh7 = PDM_FIFO_STAT_FIFOOVF7_MASK,
121#endif
122};
123
124#if defined(FSL_FEATURE_PDM_HAS_RANGE_CTRL) && FSL_FEATURE_PDM_HAS_RANGE_CTRL
126enum _pdm_range_status
127{
128 kPDM_RangeStatusUnderFlowCh0 = PDM_RANGE_STAT_RANGEUNF0_MASK,
129 kPDM_RangeStatusUnderFlowCh1 = PDM_RANGE_STAT_RANGEUNF1_MASK,
130 kPDM_RangeStatusUnderFlowCh2 = PDM_RANGE_STAT_RANGEUNF2_MASK,
131 kPDM_RangeStatusUnderFlowCh3 = PDM_RANGE_STAT_RANGEUNF3_MASK,
132#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
133 kPDM_RangeStatusUnderFlowCh4 = PDM_RANGE_STAT_RANGEUNF4_MASK,
134 kPDM_RangeStatusUnderFlowCh5 = PDM_RANGE_STAT_RANGEUNF5_MASK,
135 kPDM_RangeStatusUnderFlowCh6 = PDM_RANGE_STAT_RANGEUNF6_MASK,
136 kPDM_RangeStatusUnderFlowCh7 = PDM_RANGE_STAT_RANGEUNF7_MASK,
137#endif
138 kPDM_RangeStatusOverFlowCh0 = PDM_RANGE_STAT_RANGEOVF0_MASK,
139 kPDM_RangeStatusOverFlowCh1 = PDM_RANGE_STAT_RANGEOVF1_MASK,
140 kPDM_RangeStatusOverFlowCh2 = PDM_RANGE_STAT_RANGEOVF2_MASK,
141 kPDM_RangeStatusOverFlowCh3 = PDM_RANGE_STAT_RANGEOVF3_MASK,
142#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
143 kPDM_RangeStatusOverFlowCh4 = PDM_RANGE_STAT_RANGEOVF4_MASK,
144 kPDM_RangeStatusOverFlowCh5 = PDM_RANGE_STAT_RANGEOVF5_MASK,
145 kPDM_RangeStatusOverFlowCh6 = PDM_RANGE_STAT_RANGEOVF6_MASK,
146 kPDM_RangeStatusOverFlowCh7 = PDM_RANGE_STAT_RANGEOVF7_MASK,
147#endif
148};
149#else
152{
153 kPDM_OutputStatusUnderFlowCh0 = PDM_OUT_STAT_OUTUNF0_MASK,
154 kPDM_OutputStatusUnderFlowCh1 = PDM_OUT_STAT_OUTUNF1_MASK,
155 kPDM_OutputStatusUnderFlowCh2 = PDM_OUT_STAT_OUTUNF2_MASK,
156 kPDM_OutputStatusUnderFlowCh3 = PDM_OUT_STAT_OUTUNF3_MASK,
157#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
158 kPDM_OutputStatusUnderFlowCh4 = PDM_OUT_STAT_OUTUNF4_MASK,
159 kPDM_OutputStatusUnderFlowCh5 = PDM_OUT_STAT_OUTUNF5_MASK,
160 kPDM_OutputStatusUnderFlowCh6 = PDM_OUT_STAT_OUTUNF6_MASK,
161 kPDM_OutputStatusUnderFlowCh7 = PDM_OUT_STAT_OUTUNF7_MASK,
162#endif
163 kPDM_OutputStatusOverFlowCh0 = PDM_OUT_STAT_OUTOVF0_MASK,
164 kPDM_OutputStatusOverFlowCh1 = PDM_OUT_STAT_OUTOVF1_MASK,
165 kPDM_OutputStatusOverFlowCh2 = PDM_OUT_STAT_OUTOVF2_MASK,
166 kPDM_OutputStatusOverFlowCh3 = PDM_OUT_STAT_OUTOVF3_MASK,
167#if !defined(FSL_FEATURE_PDM_CHANNEL_NUM) || (FSL_FEATURE_PDM_CHANNEL_NUM == 8U)
168 kPDM_OutputStatusOverFlowCh4 = PDM_OUT_STAT_OUTOVF4_MASK,
169 kPDM_OutputStatusOverFlowCh5 = PDM_OUT_STAT_OUTOVF5_MASK,
170 kPDM_OutputStatusOverFlowCh6 = PDM_OUT_STAT_OUTOVF6_MASK,
171 kPDM_OutputStatusOverFlowCh7 = PDM_OUT_STAT_OUTOVF7_MASK,
172#endif
173};
174#endif
175
176#if (defined(FSL_FEATURE_PDM_HAS_DC_OUT_CTRL) && (FSL_FEATURE_PDM_HAS_DC_OUT_CTRL))
178typedef enum _pdm_dc_remover
179{
180 kPDM_DcRemoverCutOff20Hz = 0U,
181 kPDM_DcRemoverCutOff13Hz = 1U,
182 kPDM_DcRemoverCutOff40Hz = 2U,
185#else
187typedef enum _pdm_dc_remover
188{
194#endif
195
198{
206
209{
214};
215
218{
236
239{
240#if defined(FSL_FEATURE_PDM_FIFO_WIDTH) && (FSL_FEATURE_PDM_FIFO_WIDTH != 2U)
241 kPDM_DataWwidth24 = 3U,
242 kPDM_DataWwidth32 = 4U,
243#else
245#endif
246};
247
250{
251#if (defined(FSL_FEATURE_PDM_HAS_DC_OUT_CTRL) && (FSL_FEATURE_PDM_HAS_DC_OUT_CTRL))
252 pdm_dc_remover_t outputCutOffFreq;
253#endif
254
255#if !(defined(FSL_FEATURE_PDM_DC_CTRL_VALUE_FIXED) && (FSL_FEATURE_PDM_DC_CTRL_VALUE_FIXED))
257#endif
258
261
263typedef struct _pdm_config
264{
265 bool
271
272#if !(defined(FSL_FEATURE_PDM_HAS_NO_HWVAD) && FSL_FEATURE_PDM_HAS_NO_HWVAD)
275{
276 kPDM_HwvadErrorInterruptEnable = PDM_VAD0_CTRL_1_VADERIE_MASK,
277 kPDM_HwvadInterruptEnable = PDM_VAD0_CTRL_1_VADIE_MASK,
278};
279
282{
283 kPDM_HwvadStatusInputSaturation = PDM_VAD0_STAT_VADINSATF_MASK,
284 kPDM_HwvadStatusVoiceDetectFlag = PDM_VAD0_STAT_VADIF_MASK,
285};
286
289{
295
298{
300 kPDM_HwvadInternalFilterInitial = PDM_VAD0_CTRL_1_VADST10_MASK,
302
304typedef struct _pdm_hwvad_config
305{
306 uint8_t channel;
310 uint8_t inputGain;
311 uint32_t frameTime;
316
319{
325 uint32_t noiseGain;
327
330{
332 0U,
334 1U,
336
339{
342 uint32_t threshold;
345#endif
346
348typedef struct _pdm_transfer
349{
350 volatile uint8_t *data;
351 volatile size_t dataSize;
353
356
358typedef void (*pdm_transfer_callback_t)(PDM_Type *base, pdm_handle_t *handle, status_t status, void *userData);
359
360#if !(defined(FSL_FEATURE_PDM_HAS_NO_HWVAD) && FSL_FEATURE_PDM_HAS_NO_HWVAD)
362typedef void (*pdm_hwvad_callback_t)(status_t status, void *userData);
365{
366 pdm_hwvad_callback_t callback;
367 void *userData;
369#endif
370
373{
374 uint32_t state;
376 void *userData;
380 volatile uint8_t queueUser;
381 volatile uint8_t queueDriver;
383 uint32_t format;
384 uint8_t watermark;
385 uint8_t startChannel;
386 uint8_t channelNums;
387};
388
389/*******************************************************************************
390 * API
391 ******************************************************************************/
392
393#if defined(__cplusplus)
394extern "C" {
395#endif /*_cplusplus*/
396
416void PDM_Init(PDM_Type *base, const pdm_config_t *config);
417
426void PDM_Deinit(PDM_Type *base);
427
433static inline void PDM_Reset(PDM_Type *base)
434{
435 base->CTRL_1 |= PDM_CTRL_1_SRES_MASK;
436}
437
444static inline void PDM_Enable(PDM_Type *base, bool enable)
445{
446 if (enable)
447 {
448 base->CTRL_1 |= PDM_CTRL_1_PDMIEN_MASK;
449 }
450 else
451 {
452 base->CTRL_1 &= ~PDM_CTRL_1_PDMIEN_MASK;
453 }
454}
455
463static inline void PDM_EnableDoze(PDM_Type *base, bool enable)
464{
465 if (enable)
466 {
467 base->CTRL_1 |= PDM_CTRL_1_DOZEN_MASK;
468 }
469 else
470 {
471 base->CTRL_1 &= ~PDM_CTRL_1_DOZEN_MASK;
472 }
473}
474
481static inline void PDM_EnableDebugMode(PDM_Type *base, bool enable)
482{
483 if (enable)
484 {
485 base->CTRL_1 |= PDM_CTRL_1_DBG_MASK;
486 }
487 else
488 {
489 base->CTRL_1 &= ~PDM_CTRL_1_DBG_MASK;
490 }
491}
492
500static inline void PDM_EnableInDebugMode(PDM_Type *base, bool enable)
501{
502 if (enable)
503 {
504 base->CTRL_1 |= PDM_CTRL_1_DBGE_MASK;
505 }
506 else
507 {
508 base->CTRL_1 &= ~PDM_CTRL_1_DBGE_MASK;
509 }
510}
511
518static inline void PDM_EnterLowLeakageMode(PDM_Type *base, bool enable)
519{
520 if (enable)
521 {
522 base->CTRL_1 |= PDM_CTRL_1_MDIS_MASK;
523 }
524 else
525 {
526 base->CTRL_1 &= ~PDM_CTRL_1_MDIS_MASK;
527 }
528}
529
537static inline void PDM_EnableChannel(PDM_Type *base, uint8_t channel, bool enable)
538{
539 if (enable)
540 {
541 base->CTRL_1 |= (1UL << channel);
542 }
543 else
544 {
545 base->CTRL_1 &= ~(1UL << channel);
546 }
547}
548
557void PDM_SetChannelConfig(PDM_Type *base, uint32_t channel, const pdm_channel_config_t *config);
558
572status_t PDM_SetSampleRateConfig(PDM_Type *base, uint32_t sourceClock_HZ, uint32_t sampleRate_HZ);
573
585 PDM_Type *base, uint32_t enableChannelMask, pdm_df_quality_mode_t qualityMode, uint8_t osr, uint32_t clkDiv);
586
592uint32_t PDM_GetInstance(PDM_Type *base);
606static inline uint32_t PDM_GetStatus(PDM_Type *base)
607{
608 return base->STAT;
609}
610
617static inline uint32_t PDM_GetFifoStatus(PDM_Type *base)
618{
619 return base->FIFO_STAT;
620}
621
622#if defined(FSL_FEATURE_PDM_HAS_RANGE_CTRL) && FSL_FEATURE_PDM_HAS_RANGE_CTRL
629static inline uint32_t PDM_GetRangeStatus(PDM_Type *base)
630{
631 return base->RANGE_STAT;
632}
633#else
640static inline uint32_t PDM_GetOutputStatus(PDM_Type *base)
641{
642 return base->OUT_STAT;
643}
644#endif
645
653static inline void PDM_ClearStatus(PDM_Type *base, uint32_t mask)
654{
655 base->STAT = mask;
656}
657
664static inline void PDM_ClearFIFOStatus(PDM_Type *base, uint32_t mask)
665{
666 base->FIFO_STAT = mask;
667}
668
669#if defined(FSL_FEATURE_PDM_HAS_RANGE_CTRL) && FSL_FEATURE_PDM_HAS_RANGE_CTRL
676static inline void PDM_ClearRangeStatus(PDM_Type *base, uint32_t mask)
677{
678 base->RANGE_STAT = mask;
679}
680#else
687static inline void PDM_ClearOutputStatus(PDM_Type *base, uint32_t mask)
688{
689 base->OUT_STAT = mask;
690}
691#endif
692
709void PDM_EnableInterrupts(PDM_Type *base, uint32_t mask);
710
720static inline void PDM_DisableInterrupts(PDM_Type *base, uint32_t mask)
721{
722 base->CTRL_1 &= ~mask;
723}
724
738static inline void PDM_EnableDMA(PDM_Type *base, bool enable)
739{
740 if (enable)
741 {
742 base->CTRL_1 = (base->CTRL_1 & (~PDM_CTRL_1_DISEL_MASK)) | PDM_CTRL_1_DISEL(0x1U);
743 }
744 else
745 {
746 base->CTRL_1 &= ~PDM_CTRL_1_DISEL_MASK;
747 }
748}
749
759static inline uint32_t PDM_GetDataRegisterAddress(PDM_Type *base, uint32_t channel)
760{
761 return (uint32_t)(&(base->DATACH)[channel]);
762}
763
770#if defined(FSL_FEATURE_PDM_FIFO_WIDTH) && (FSL_FEATURE_PDM_FIFO_WIDTH == 2U)
778static inline int16_t PDM_ReadData(PDM_Type *base, uint32_t channel)
779{
780 return (int16_t)(base->DATACH[channel]);
781}
782
792void PDM_ReadNonBlocking(PDM_Type *base, uint32_t startChannel, uint32_t channelNums, int16_t *buffer, size_t size);
793#endif
794
806void PDM_ReadFifo(
807 PDM_Type *base, uint32_t startChannel, uint32_t channelNums, void *buffer, size_t size, uint32_t dataWidth);
808
809#if defined(FSL_FEATURE_PDM_FIFO_WIDTH) && (FSL_FEATURE_PDM_FIFO_WIDTH == 4U)
817static inline uint32_t PDM_ReadData(PDM_Type *base, uint32_t channel)
818{
819 return base->DATACH[channel];
820}
821#endif
822
831void PDM_SetChannelGain(PDM_Type *base, uint32_t channel, pdm_df_output_gain_t gain);
832
833#if !(defined(FSL_FEATURE_PDM_HAS_NO_HWVAD) && FSL_FEATURE_PDM_HAS_NO_HWVAD)
848
855static inline void PDM_ForceHwvadOutputDisable(PDM_Type *base, bool enable)
856{
857 if (enable)
858 {
859 base->VAD0_CTRL_2 &= ~PDM_VAD0_CTRL_2_VADFOUTDIS_MASK;
860 }
861 else
862 {
863 base->VAD0_CTRL_2 |= PDM_VAD0_CTRL_2_VADFOUTDIS_MASK;
864 }
865}
866
873static inline void PDM_ResetHwvad(PDM_Type *base)
874{
875 base->VAD0_CTRL_1 |= PDM_VAD0_CTRL_1_VADRST_MASK;
876}
883static inline void PDM_EnableHwvad(PDM_Type *base, bool enable)
884{
885 if (enable)
886 {
887 base->VAD0_CTRL_1 |= PDM_VAD0_CTRL_1_VADEN_MASK;
888 }
889 else
890 {
891 base->VAD0_CTRL_1 &= ~PDM_VAD0_CTRL_1_VADEN_MASK;
892 }
893}
894
904static inline void PDM_EnableHwvadInterrupts(PDM_Type *base, uint32_t mask)
905{
906 base->VAD0_CTRL_1 |= mask;
907}
908
918static inline void PDM_DisableHwvadInterrupts(PDM_Type *base, uint32_t mask)
919{
920 base->VAD0_CTRL_1 &= ~mask;
921}
922
929static inline void PDM_ClearHwvadInterruptStatusFlags(PDM_Type *base, uint32_t mask)
930{
931 base->VAD0_STAT = mask;
932}
933
940static inline uint32_t PDM_GetHwvadInterruptStatusFlags(PDM_Type *base)
941{
942 return base->VAD0_STAT & (PDM_VAD0_STAT_VADIF_MASK | PDM_VAD0_STAT_VADINSATF_MASK);
943}
944
951static inline uint32_t PDM_GetHwvadInitialFlag(PDM_Type *base)
952{
953 return base->VAD0_STAT & PDM_VAD0_STAT_VADINITF_MASK;
954}
955
956#if !(defined(FSL_FEATURE_PDM_HAS_NO_VADEF) && (FSL_FEATURE_PDM_HAS_NO_VADEF))
963static inline uint32_t PDM_GetHwvadVoiceDetectedFlag(PDM_Type *base)
964{
965 return base->VAD0_STAT & PDM_VAD0_STAT_VADEF_MASK;
966}
967#endif
968
975static inline void PDM_EnableHwvadSignalFilter(PDM_Type *base, bool enable)
976{
977 if (enable)
978 {
979 base->VAD0_SCONFIG |= PDM_VAD0_SCONFIG_VADSFILEN_MASK;
980 }
981 else
982 {
983 base->VAD0_SCONFIG &= ~PDM_VAD0_SCONFIG_VADSFILEN_MASK;
984 }
985}
986
994void PDM_SetHwvadSignalFilterConfig(PDM_Type *base, bool enableMaxBlock, uint32_t signalGain);
995
1003
1010static inline void PDM_EnableHwvadZeroCrossDetector(PDM_Type *base, bool enable)
1011{
1012 if (enable)
1013 {
1014 base->VAD0_ZCD |= PDM_VAD0_ZCD_VADZCDEN_MASK;
1015 }
1016 else
1017 {
1018 base->VAD0_ZCD &= ~PDM_VAD0_ZCD_VADZCDEN_MASK;
1019 }
1020}
1021
1029
1036static inline uint16_t PDM_GetNoiseData(PDM_Type *base)
1037{
1038 return (uint16_t)base->VAD0_NDATA;
1039}
1040
1047static inline void PDM_SetHwvadInternalFilterStatus(PDM_Type *base, pdm_hwvad_filter_status_t status)
1048{
1049 base->VAD0_CTRL_1 = (base->VAD0_CTRL_1 & (~PDM_VAD0_CTRL_1_VADST10_MASK)) | (uint32_t)status;
1050}
1051
1083 const pdm_hwvad_config_t *hwvadConfig,
1084 const pdm_hwvad_noise_filter_t *noiseConfig,
1085 const pdm_hwvad_zero_cross_detector_t *zcdConfig,
1086 uint32_t signalGain);
1087
1119 const pdm_hwvad_config_t *hwvadConfig,
1120 const pdm_hwvad_noise_filter_t *noiseConfig,
1121 const pdm_hwvad_zero_cross_detector_t *zcdConfig,
1122 uint32_t signalGain);
1123
1135void PDM_EnableHwvadInterruptCallback(PDM_Type *base, pdm_hwvad_callback_t vadCallback, void *userData, bool enable);
1137#endif
1138
1155void PDM_TransferCreateHandle(PDM_Type *base, pdm_handle_t *handle, pdm_transfer_callback_t callback, void *userData);
1156
1168 PDM_Type *base, pdm_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config, uint32_t format);
1169
1185
1196
1203void PDM_TransferHandleIRQ(PDM_Type *base, pdm_handle_t *handle);
1204
1207#if defined(__cplusplus)
1208}
1209#endif /*_cplusplus*/
1210
1213#endif /* _FSL_PDM_H_ */
#define PDM_CTRL_1_DISEL(x)
Definition: MIMXRT1166_cm4.h:65658
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_PDM
Definition: fsl_common.h:144
void PDM_SetHwvadNoiseFilterConfig(PDM_Type *base, const pdm_hwvad_noise_filter_t *config)
Configure voice activity detector noise filter.
Definition: fsl_pdm.c:842
#define PDM_XFER_QUEUE_SIZE
PDM XFER QUEUE SIZE.
Definition: fsl_pdm.h:29
_pdm_hwvad_zcd_result
PDM voice activity detector zero cross detector result.
Definition: fsl_pdm.h:330
struct _pdm_hwvad_config pdm_hwvad_config_t
PDM voice activity detector user configuration structure.
status_t PDM_SetSampleRateConfig(PDM_Type *base, uint32_t sourceClock_HZ, uint32_t sampleRate_HZ)
PDM set sample rate.
Definition: fsl_pdm.c:217
void PDM_TransferHandleIRQ(PDM_Type *base, pdm_handle_t *handle)
Tx interrupt handler.
Definition: fsl_pdm.c:598
_pdm_hwvad_int_status
The PDM hwvad interrupt status flag.
Definition: fsl_pdm.h:282
void PDM_SetHwvadZeroCrossDetectorConfig(PDM_Type *base, const pdm_hwvad_zero_cross_detector_t *config)
Configure voice activity detector zero cross detector.
Definition: fsl_pdm.c:859
void(* pdm_hwvad_callback_t)(status_t status, void *userData)
PDM HWVAD callback prototype.
Definition: fsl_pdm.h:362
_pdm_df_output_gain
PDM decimation filter output gain.
Definition: fsl_pdm.h:218
_pdm_dc_remover
PDM DC remover configurations.
Definition: fsl_pdm.h:188
void PDM_EnableInterrupts(PDM_Type *base, uint32_t mask)
Enables the PDM interrupt requests.
Definition: fsl_pdm.c:378
void PDM_SetHwvadConfig(PDM_Type *base, const pdm_hwvad_config_t *config)
Configure voice activity detector.
Definition: fsl_pdm.c:800
enum _pdm_df_output_gain pdm_df_output_gain_t
PDM decimation filter output gain.
enum _pdm_hwvad_zcd_result pdm_hwvad_zcd_result_t
PDM voice activity detector zero cross detector result.
void PDM_SetChannelGain(PDM_Type *base, uint32_t channel, pdm_df_output_gain_t gain)
Set the PDM channel gain.
Definition: fsl_pdm.c:435
void PDM_EnableHwvadInterruptCallback(PDM_Type *base, pdm_hwvad_callback_t vadCallback, void *userData, bool enable)
Enable/Disable hwvad callback.
Definition: fsl_pdm.c:884
void PDM_SetHwvadSignalFilterConfig(PDM_Type *base, bool enableMaxBlock, uint32_t signalGain)
Configure voice activity detector signal filter.
Definition: fsl_pdm.c:826
struct _pdm_transfer pdm_transfer_t
PDM SDMA transfer structure.
_pdm_data_width
PDM data width.
Definition: fsl_pdm.h:239
_pdm_hwvad_filter_status
HWVAD internal filter status.
Definition: fsl_pdm.h:298
void(* pdm_transfer_callback_t)(PDM_Type *base, pdm_handle_t *handle, status_t status, void *userData)
PDM transfer callback prototype.
Definition: fsl_pdm.h:358
enum _pdm_df_quality_mode pdm_df_quality_mode_t
PDM decimation filter quality mode.
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.
Definition: fsl_pdm.c:261
void PDM_Init(PDM_Type *base, const pdm_config_t *config)
Initializes the PDM peripheral.
Definition: fsl_pdm.c:313
void PDM_TransferCreateHandle(PDM_Type *base, pdm_handle_t *handle, pdm_transfer_callback_t callback, void *userData)
Initializes the PDM handle.
Definition: fsl_pdm.c:504
status_t PDM_TransferReceiveNonBlocking(PDM_Type *base, pdm_handle_t *handle, pdm_transfer_t *xfer)
Performs an interrupt non-blocking receive transfer on PDM.
Definition: fsl_pdm.c:542
struct _pdm_config pdm_config_t
PDM user configuration structure.
_pdm_output_status
The PDM output status.
Definition: fsl_pdm.h:152
_pdm_hwvad_hpf_config
High pass filter configure cut-off frequency.
Definition: fsl_pdm.h:289
uint32_t PDM_GetInstance(PDM_Type *base)
Get the instance number for PDM.
Definition: fsl_pdm.c:66
enum _pdm_hwvad_filter_status pdm_hwvad_filter_status_t
HWVAD internal filter status.
_pdm_interrupt_enable
The PDM interrupt enable flag.
Definition: fsl_pdm.h:51
enum _pdm_hwvad_hpf_config pdm_hwvad_hpf_config_t
High pass filter configure cut-off frequency.
void PDM_TransferAbortReceive(PDM_Type *base, pdm_handle_t *handle)
Aborts the current IRQ receive.
Definition: fsl_pdm.c:578
enum _pdm_dc_remover pdm_dc_remover_t
PDM DC remover configurations.
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)
Definition: fsl_pdm.c:771
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.
Definition: fsl_pdm.c:469
_pdm_hwvad_interrupt_enable
PDM voice activity detector interrupt type.
Definition: fsl_pdm.h:275
_pdm_channel_enable_mask
PDM channel enable mask.
Definition: fsl_pdm.h:80
struct _pdm_hwvad_noise_filter pdm_hwvad_noise_filter_t
PDM voice activity detector noise filter user configuration structure.
_pdm_fifo_status
The PDM fifo status.
Definition: fsl_pdm.h:100
_pdm_df_quality_mode
PDM decimation filter quality mode.
Definition: fsl_pdm.h:198
void PDM_Deinit(PDM_Type *base)
De-initializes the PDM peripheral.
Definition: fsl_pdm.c:356
_pdm_qulaity_mode_k_factor
PDM quality mode K factor.
Definition: fsl_pdm.h:209
void PDM_ReadFifo(PDM_Type *base, uint32_t startChannel, uint32_t channelNums, void *buffer, size_t size, uint32_t dataWidth)
PDM read fifo.
Definition: fsl_pdm.c:95
_pdm_internal_status
The PDM status.
Definition: fsl_pdm.h:58
void PDM_SetChannelConfig(PDM_Type *base, uint32_t channel, const pdm_channel_config_t *config)
PDM one channel configurations.
Definition: fsl_pdm.c:398
struct _pdm_hwvad_notification pdm_hwvad_notification_t
PDM HWVAD notification structure.
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 . Recommand configurations,
Definition: fsl_pdm.c:705
struct _pdm_channel_config pdm_channel_config_t
PDM channel configurations.
struct _pdm_hwvad_zero_cross_detector pdm_hwvad_zero_cross_detector_t
PDM voice activity detector zero cross detector configuration structure.
@ kPDM_HwvadResultOREnergyBasedDetection
Definition: fsl_pdm.h:331
@ kPDM_HwvadResultANDEnergyBasedDetection
Definition: fsl_pdm.h:333
@ kPDM_HwvadStatusInputSaturation
Definition: fsl_pdm.h:283
@ kPDM_HwvadStatusVoiceDetectFlag
Definition: fsl_pdm.h:284
@ kPDM_DfOutputGain15
Definition: fsl_pdm.h:234
@ kPDM_DfOutputGain11
Definition: fsl_pdm.h:230
@ kPDM_DfOutputGain9
Definition: fsl_pdm.h:228
@ kPDM_DfOutputGain0
Definition: fsl_pdm.h:219
@ kPDM_DfOutputGain13
Definition: fsl_pdm.h:232
@ kPDM_DfOutputGain3
Definition: fsl_pdm.h:222
@ kPDM_DfOutputGain10
Definition: fsl_pdm.h:229
@ kPDM_DfOutputGain5
Definition: fsl_pdm.h:224
@ kPDM_DfOutputGain1
Definition: fsl_pdm.h:220
@ kPDM_DfOutputGain2
Definition: fsl_pdm.h:221
@ kPDM_DfOutputGain12
Definition: fsl_pdm.h:231
@ kPDM_DfOutputGain8
Definition: fsl_pdm.h:227
@ kPDM_DfOutputGain14
Definition: fsl_pdm.h:233
@ kPDM_DfOutputGain6
Definition: fsl_pdm.h:225
@ kPDM_DfOutputGain7
Definition: fsl_pdm.h:226
@ kPDM_DfOutputGain4
Definition: fsl_pdm.h:223
@ kPDM_DcRemoverBypass
Definition: fsl_pdm.h:192
@ kPDM_DcRemoverCutOff21Hz
Definition: fsl_pdm.h:189
@ kPDM_DcRemoverCutOff152Hz
Definition: fsl_pdm.h:191
@ kPDM_DcRemoverCutOff83Hz
Definition: fsl_pdm.h:190
@ kPDM_DataWdith16
Definition: fsl_pdm.h:244
@ kPDM_HwvadInternalFilterNormalOperation
Definition: fsl_pdm.h:299
@ kPDM_HwvadInternalFilterInitial
Definition: fsl_pdm.h:300
@ kPDM_OutputStatusUnderFlowCh5
Definition: fsl_pdm.h:159
@ kPDM_OutputStatusUnderFlowCh6
Definition: fsl_pdm.h:160
@ kPDM_OutputStatusUnderFlowCh7
Definition: fsl_pdm.h:161
@ kPDM_OutputStatusOverFlowCh1
Definition: fsl_pdm.h:164
@ kPDM_OutputStatusUnderFlowCh0
Definition: fsl_pdm.h:153
@ kPDM_OutputStatusOverFlowCh7
Definition: fsl_pdm.h:171
@ kPDM_OutputStatusUnderFlowCh3
Definition: fsl_pdm.h:156
@ kPDM_OutputStatusOverFlowCh0
Definition: fsl_pdm.h:163
@ kPDM_OutputStatusOverFlowCh6
Definition: fsl_pdm.h:170
@ kPDM_OutputStatusOverFlowCh2
Definition: fsl_pdm.h:165
@ kPDM_OutputStatusUnderFlowCh2
Definition: fsl_pdm.h:155
@ kPDM_OutputStatusOverFlowCh5
Definition: fsl_pdm.h:169
@ kPDM_OutputStatusOverFlowCh4
Definition: fsl_pdm.h:168
@ kPDM_OutputStatusOverFlowCh3
Definition: fsl_pdm.h:166
@ kPDM_OutputStatusUnderFlowCh1
Definition: fsl_pdm.h:154
@ kPDM_OutputStatusUnderFlowCh4
Definition: fsl_pdm.h:158
@ kPDM_HwvadHpfCutOffFreq1750Hz
Definition: fsl_pdm.h:291
@ kPDM_HwvadHpfBypassed
Definition: fsl_pdm.h:290
@ kPDM_HwvadHpfCutOffFreq102Hz
Definition: fsl_pdm.h:293
@ kPDM_HwvadHpfCutOffFreq215Hz
Definition: fsl_pdm.h:292
@ kPDM_ErrorInterruptEnable
Definition: fsl_pdm.h:52
@ kPDM_FIFOInterruptEnable
Definition: fsl_pdm.h:53
@ kPDM_HwvadInterruptEnable
Definition: fsl_pdm.h:277
@ kPDM_HwvadErrorInterruptEnable
Definition: fsl_pdm.h:276
@ kPDM_EnableChannel4
Definition: fsl_pdm.h:86
@ kPDM_EnableChannel6
Definition: fsl_pdm.h:88
@ kPDM_EnableChannel3
Definition: fsl_pdm.h:84
@ kPDM_EnableChannel5
Definition: fsl_pdm.h:87
@ kPDM_EnableChannel7
Definition: fsl_pdm.h:89
@ kPDM_EnableChannel1
Definition: fsl_pdm.h:82
@ kPDM_EnableChannel2
Definition: fsl_pdm.h:83
@ kPDM_EnableChannel0
Definition: fsl_pdm.h:81
@ kStatus_PDM_Busy
Definition: fsl_pdm.h:34
@ kStatus_PDM_QueueFull
Definition: fsl_pdm.h:39
@ kStatus_PDM_HWVAD_Error
Definition: fsl_pdm.h:45
@ kStatus_PDM_FIFO_ERROR
Definition: fsl_pdm.h:38
@ kStatus_PDM_HWVAD_VoiceDetected
Definition: fsl_pdm.h:44
@ kStatus_PDM_Idle
Definition: fsl_pdm.h:40
@ kStatus_PDM_ChannelConfig_Failed
Definition: fsl_pdm.h:42
@ kStatus_PDM_Output_ERROR
Definition: fsl_pdm.h:41
@ kPDM_FifoStatusOverflowCh0
Definition: fsl_pdm.h:112
@ kPDM_FifoStatusUnderflowCh4
Definition: fsl_pdm.h:106
@ kPDM_FifoStatusUnderflowCh0
Definition: fsl_pdm.h:101
@ kPDM_FifoStatusOverflowCh5
Definition: fsl_pdm.h:118
@ kPDM_FifoStatusOverflowCh4
Definition: fsl_pdm.h:117
@ kPDM_FifoStatusOverflowCh6
Definition: fsl_pdm.h:119
@ kPDM_FifoStatusOverflowCh1
Definition: fsl_pdm.h:113
@ kPDM_FifoStatusUnderflowCh6
Definition: fsl_pdm.h:108
@ kPDM_FifoStatusUnderflowCh7
Definition: fsl_pdm.h:109
@ kPDM_FifoStatusUnderflowCh2
Definition: fsl_pdm.h:103
@ kPDM_FifoStatusOverflowCh2
Definition: fsl_pdm.h:114
@ kPDM_FifoStatusOverflowCh7
Definition: fsl_pdm.h:120
@ kPDM_FifoStatusOverflowCh3
Definition: fsl_pdm.h:115
@ kPDM_FifoStatusUnderflowCh3
Definition: fsl_pdm.h:104
@ kPDM_FifoStatusUnderflowCh1
Definition: fsl_pdm.h:102
@ kPDM_FifoStatusUnderflowCh5
Definition: fsl_pdm.h:107
@ kPDM_QualityModeVeryLow0
Definition: fsl_pdm.h:202
@ kPDM_QualityModeVeryLow1
Definition: fsl_pdm.h:203
@ kPDM_QualityModeMedium
Definition: fsl_pdm.h:199
@ kPDM_QualityModeHigh
Definition: fsl_pdm.h:200
@ kPDM_QualityModeVeryLow2
Definition: fsl_pdm.h:204
@ kPDM_QualityModeLow
Definition: fsl_pdm.h:201
@ kPDM_QualityModeLowKFactor
Definition: fsl_pdm.h:212
@ kPDM_QualityModeHighKFactor
Definition: fsl_pdm.h:210
@ kPDM_QualityModeMediumKFactor
Definition: fsl_pdm.h:211
@ kPDM_QualityModeVeryLow2KFactor
Definition: fsl_pdm.h:213
@ kPDM_StatusCh4FifoDataAvaliable
Definition: fsl_pdm.h:71
@ kPDM_StatusFIRFilterReady
Definition: fsl_pdm.h:61
@ kPDM_StatusCh0FifoDataAvaliable
Definition: fsl_pdm.h:66
@ kPDM_StatusCh3FifoDataAvaliable
Definition: fsl_pdm.h:69
@ kPDM_StatusDfBusyFlag
Definition: fsl_pdm.h:59
@ kPDM_StatusCh1FifoDataAvaliable
Definition: fsl_pdm.h:67
@ kPDM_StatusCh2FifoDataAvaliable
Definition: fsl_pdm.h:68
@ kPDM_StatusCh6FifoDataAvaliable
Definition: fsl_pdm.h:73
@ kPDM_StatusCh7FifoDataAvaliable
Definition: fsl_pdm.h:74
@ kPDM_StatusCh5FifoDataAvaliable
Definition: fsl_pdm.h:72
Definition: MIMXRT1166_cm4.h:65557
PDM channel configurations.
Definition: fsl_pdm.h:250
pdm_dc_remover_t cutOffFreq
Definition: fsl_pdm.h:256
pdm_df_output_gain_t gain
Definition: fsl_pdm.h:259
PDM user configuration structure.
Definition: fsl_pdm.h:264
pdm_df_quality_mode_t qualityMode
Definition: fsl_pdm.h:268
uint8_t fifoWatermark
Definition: fsl_pdm.h:267
uint8_t cicOverSampleRate
Definition: fsl_pdm.h:269
bool enableDoze
Definition: fsl_pdm.h:266
PDM handle structure.
Definition: fsl_pdm.h:373
volatile uint8_t queueDriver
Definition: fsl_pdm.h:381
size_t transferSize[PDM_XFER_QUEUE_SIZE]
Definition: fsl_pdm.h:379
pdm_transfer_callback_t callback
Definition: fsl_pdm.h:375
void * userData
Definition: fsl_pdm.h:376
uint32_t format
Definition: fsl_pdm.h:383
pdm_transfer_t pdmQueue[PDM_XFER_QUEUE_SIZE]
Definition: fsl_pdm.h:378
uint8_t startChannel
Definition: fsl_pdm.h:385
uint32_t state
Definition: fsl_pdm.h:374
volatile uint8_t queueUser
Definition: fsl_pdm.h:380
uint8_t watermark
Definition: fsl_pdm.h:384
uint8_t channelNums
Definition: fsl_pdm.h:386
PDM voice activity detector user configuration structure.
Definition: fsl_pdm.h:305
bool enablePreFilter
Definition: fsl_pdm.h:314
pdm_hwvad_hpf_config_t cutOffFreq
Definition: fsl_pdm.h:312
uint8_t channel
Definition: fsl_pdm.h:306
uint8_t cicOverSampleRate
Definition: fsl_pdm.h:308
bool enableFrameEnergy
Definition: fsl_pdm.h:313
uint8_t inputGain
Definition: fsl_pdm.h:310
uint8_t initializeTime
Definition: fsl_pdm.h:307
uint32_t frameTime
Definition: fsl_pdm.h:311
PDM voice activity detector noise filter user configuration structure.
Definition: fsl_pdm.h:319
bool enableNoiseMin
Definition: fsl_pdm.h:321
bool enableNoiseDecimation
Definition: fsl_pdm.h:322
bool enableAutoNoiseFilter
Definition: fsl_pdm.h:320
bool enableNoiseDetectOR
Definition: fsl_pdm.h:323
uint32_t noiseFilterAdjustment
Definition: fsl_pdm.h:324
uint32_t noiseGain
Definition: fsl_pdm.h:325
PDM HWVAD notification structure.
Definition: fsl_pdm.h:365
PDM voice activity detector zero cross detector configuration structure.
Definition: fsl_pdm.h:339
bool enableAutoThreshold
Definition: fsl_pdm.h:340
uint32_t adjustmentThreshold
Definition: fsl_pdm.h:343
pdm_hwvad_zcd_result_t zcdAnd
Definition: fsl_pdm.h:341
uint32_t threshold
Definition: fsl_pdm.h:342
PDM SDMA transfer structure.
Definition: fsl_pdm.h:349
volatile uint8_t * data
Definition: fsl_pdm.h:350
volatile size_t dataSize
Definition: fsl_pdm.h:351
Definition: deflate.c:114
Definition: mknod-pack_dev.c:254