1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
//*****************************************************************************
//
// am_hal_pdm.h
//! @file
//!
//! @brief Functions for accessing and configuring the PDM module
//!
//! @addtogroup pdm2 Pulse Density Modulation (PDM) Input Module.
//! @ingroup apollo2hal
//! @{
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2017, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 1.2.11 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_PDM_H
#define AM_HAL_PDM_H
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
//*****************************************************************************
//
//! @name PDM Left Right Swap Control
//! @brief Macro definitions for the PDM LRSWAP bit field
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! left right swap bit.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_LRSWAP_ENABLE \
AM_REG_PDM_PCFG_LRSWAP_EN
#define AM_HAL_PDM_PCFG_LRSWAP_DISABLE \
AM_REG_PDM_PCFG_LRSWAP_NOSWAP
//! @}
//*****************************************************************************
//
//! @name PDM Right Gain Setting
//! @brief Macro definitions for the PDM Right Gain Setting.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! right gain value.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M15DB AM_REG_PDM_PCFG_PGARIGHT_M15DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M300DB AM_REG_PDM_PCFG_PGARIGHT_M300DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M45DB AM_REG_PDM_PCFG_PGARIGHT_M45DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M60DB AM_REG_PDM_PCFG_PGARIGHT_M60DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M75DB AM_REG_PDM_PCFG_PGARIGHT_M75DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M90DB AM_REG_PDM_PCFG_PGARIGHT_M90DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M105DB AM_REG_PDM_PCFG_PGARIGHT_M105DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_M120DB AM_REG_PDM_PCFG_PGARIGHT_M120DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P105DB AM_REG_PDM_PCFG_PGARIGHT_P105DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P90DB AM_REG_PDM_PCFG_PGARIGHT_P90DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P75DB AM_REG_PDM_PCFG_PGARIGHT_P75DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P60DB AM_REG_PDM_PCFG_PGARIGHT_P60DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P45DB AM_REG_PDM_PCFG_PGARIGHT_P45DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P300DB AM_REG_PDM_PCFG_PGARIGHT_P300DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_P15DB AM_REG_PDM_PCFG_PGARIGHT_P15DB
#define AM_HAL_PDM_PCFG_RIGHT_PGA_0DB AM_REG_PDM_PCFG_PGARIGHT_0DB
//! @}
//*****************************************************************************
//
//! @name PDM Left Gain Setting
//! @brief Macro definitions for the PDM Left Gain Setting.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! left gain value.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_LEFT_PGA_M15DB AM_REG_PDM_PCFG_PGALEFT_M15DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M300DB AM_REG_PDM_PCFG_PGALEFT_M300DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M45DB AM_REG_PDM_PCFG_PGALEFT_M45DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M60DB AM_REG_PDM_PCFG_PGALEFT_M60DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M75DB AM_REG_PDM_PCFG_PGALEFT_M75DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M90DB AM_REG_PDM_PCFG_PGALEFT_M90DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M105DB AM_REG_PDM_PCFG_PGALEFT_M105DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_M120DB AM_REG_PDM_PCFG_PGALEFT_M120DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P105DB AM_REG_PDM_PCFG_PGALEFT_P105DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P90DB AM_REG_PDM_PCFG_PGALEFT_P90DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P75DB AM_REG_PDM_PCFG_PGALEFT_P75DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P60DB AM_REG_PDM_PCFG_PGALEFT_P60DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P45DB AM_REG_PDM_PCFG_PGALEFT_P45DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P300DB AM_REG_PDM_PCFG_PGALEFT_P300DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_P15DB AM_REG_PDM_PCFG_PGALEFT_P15DB
#define AM_HAL_PDM_PCFG_LEFT_PGA_0DB AM_REG_PDM_PCFG_PGALEFT_0DB
//! @}
//*****************************************************************************
//
//! @name PDM Configuration MCLK Divider
//! @brief Macro definitions for the PDM MCLK Divider
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! sinc decimation rate relative to the PDM sample clock (OSR).
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_MCLKDIV_DIV1 AM_REG_PDM_PCFG_MCLKDIV_MCKDIV1
#define AM_HAL_PDM_PCFG_MCLKDIV_DIV2 AM_REG_PDM_PCFG_MCLKDIV_MCKDIV2
#define AM_HAL_PDM_PCFG_MCLKDIV_DIV3 AM_REG_PDM_PCFG_MCLKDIV_MCKDIV3
#define AM_HAL_PDM_PCFG_MCLKDIV_DIV4 AM_REG_PDM_PCFG_MCLKDIV_MCKDIV4
#define AM_HAL_PDM_PCFG_MCLKDIV(DIV) AM_REG_PDM_PCFG_MCLKDIV(DIV)
//! @}
//*****************************************************************************
//
//! @name PDM Configuration SINC Decimation Rate
//! @brief Macro definitions for the PDM SINC decimation rate
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! sinc decimation rate relative to the PDM sample clock (OSR).
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_SINC_RATE(OSR) \
AM_REG_PDM_PCFG_SINCRATE(OSR)
//! @}
//*****************************************************************************
//
//! @name PDM Configuration High Pass Filter Enable
//! @brief Macro definitions for the PDM ADCHPD
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! the high pass filter.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_ADCHPD_ENABLE AM_REG_PDM_PCFG_ADCHPD_EN
#define AM_HAL_PDM_PCFG_ADCHPD_DISABLE AM_REG_PDM_PCFG_ADCHPD_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Configuration HPCUTOFF
//! @brief Macro definitions for the PDM High Pass Filter Cutoff Selector.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! high pass filter cutoff frequency. Valid range is 0 to 7.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_HPCUTOFF(HPSEL) \
AM_REG_PDM_PCFG_HPCUTOFF(HPSEL)
//! @}
//*****************************************************************************
//
//! @name PDM Configuration Gain Set Change Clock Delay
//! @brief Macro definitions for the PDM clock delay for gain set changes.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! number of clocks for spreading gain setting changes. Valid range is 0 to 7.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_CYCLES(CLOCKS) \
AM_REG_PDM_PCFG_CYCLES(CLOCKS)
//! @}
//*****************************************************************************
//
//! @name PDM Configuration SOFTMUTE enable/disable.
//! @brief Macro definitions for the PDM PCFG register mute controls.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the SOFTMUTE option.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_SOFTMUTE_ENABLE AM_REG_PDM_PCFG_SOFTMUTE_EN
#define AM_HAL_PDM_PCFG_SOFTMUTE_DISABLE AM_REG_PDM_PCFG_SOFTMUTE_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Configuration PDM Core enable/disable.
//! @brief Macro definitions for the PDM PCFG register filter engine enable.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM filter engine core.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_PCFG_PDMCORE_ENABLE AM_REG_PDM_PCFG_PDMCORE_EN
#define AM_HAL_PDM_PCFG_PDMCORE_DISABLE AM_REG_PDM_PCFG_PDMCORE_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Clock Frequencies
//! @brief Macro definitions for the PDM clock (from clkgen) frequencies.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! source clock frequency of the PDM interface.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_IOCLK_12MHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_12MHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_6MHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_6MHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_3MHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_3MHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_1_5MHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_1_5MHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_750KHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_750KHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_375KHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_375KHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
#define AM_HAL_PDM_IOCLK_187KHZ \
(AM_REG_PDM_VCFG_PDMCLKSEL_187KHz | AM_REG_PDM_VCFG_IOCLKEN_EN)
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration RSTB
//! @brief Reset the IP core.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_RSTB_RESET AM_REG_PDM_VCFG_RSTB_RESET
#define AM_HAL_PDM_VCFG_RSTB_NORMAL AM_REG_PDM_VCFG_RSTB_NORM
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration PDM Clock Enable/Disable
//! @brief Macro definitions for the PDM VCFG register PDMCLKEN.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM clock output to the pad mux and from there to the world.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_PDMCLK_ENABLE AM_REG_PDM_VCFG_PDMCLK_EN
#define AM_HAL_PDM_VCFG_PDMCLK_DISABLE AM_REG_PDM_VCFG_PDMCLK_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration I2S Mode Enable/Disable
//! @brief Macro definitions for the PDM VCFG register I2SMODE.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM clock output to the pad mux and from there to the world.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_I2SMODE_ENABLE AM_REG_PDM_VCFG_I2SMODE_EN
#define AM_HAL_PDM_VCFG_I2SMODE_DISABLE AM_REG_PDM_VCFG_I2SMODE_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration BCLK Inversion Enable/Disable
//! @brief Macro definitions for the PDM VCFG register BCLKINV.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM clock output to the pad mux and from there to the world.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_BCLKINV_ENABLE AM_REG_PDM_VCFG_BCLKINV_INV
#define AM_HAL_PDM_VCFG_BCLKINV_DISABLE AM_REG_PDM_VCFG_BCLKINV_NORM
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration DMICDEL Enable/Disable
//! @brief Macro definitions for the PDM VCFG register Digital Mic Delay.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM digital microphone clock delay.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_DMICDEL_1CYC AM_REG_PDM_VCFG_DMICKDEL_1CYC
#define AM_HAL_PDM_VCFG_DMICDEL_0CYC AM_REG_PDM_VCFG_DMICKDEL_0CYC
#define AM_HAL_PDM_VCFG_DMICDEL_ENABLE AM_REG_PDM_VCFG_DMICKDEL_1CYC
#define AM_HAL_PDM_VCFG_DMICDEL_DISABLE AM_REG_PDM_VCFG_DMICKDEL_0CYC
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration Select Apps Processor (AP) versus Internal
//! @brief Macro definitions for the PDM VCFG register Digital Mic Delay.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to select
//! the Application Processor (I2S slave) mode or the Internal FIFO interface
//! to the Apollo Cortex M4.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_SELAP_I2S AM_REG_PDM_VCFG_SELAP_I2S
#define AM_HAL_PDM_VCFG_SELAP_INTERNAL AM_REG_PDM_VCFG_SELAP_INTERNAL
#define AM_HAL_PDM_VCFG_SELAP_AP_I2S AM_REG_PDM_VCFG_SELAP_I2S
#define AM_HAL_PDM_VCFG_SELAP_CM4_FIFO AM_REG_PDM_VCFG_SELAP_INTERNAL
//! @}
//*****************************************************************************
//
//! @name PDM Voice Configuration PACK Enable/Disable
//! @brief Macro definitions for the PDM VCFG register sample packing mode.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to enable
//! or disable the PDM sample packing mode. This mode puts two 16-bit samples
//! per 32-bit FIFO word. The following packed modes are available:
//!
//! mono left: LEFT_NEW, LEFT_OLD
//! mono right: RIGHT_NEW,RIGHT_OLD
//! stereo right: LEFT, RIGHT
//! stereo right(LRSWAP): RIGHT, LEFT
//!
//!
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_PACK_ENABLE AM_REG_PDM_VCFG_PCMPACK_EN
#define AM_HAL_PDM_VCFG_PACK_DISABLE AM_REG_PDM_VCFG_PCMPACK_DIS
//! @}
//*****************************************************************************
//
//! @name PDM Channel Selects
//! @brief Macro definitions for the PDM Channel Selection.
//!
//! These macros may be used with the am_hal_pdm_config_t structure to set the
//! channel selection for the PDM interface.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_VCFG_CHANNEL_LEFT AM_REG_PDM_VCFG_CHSET_LEFT
#define AM_HAL_PDM_VCFG_CHANNEL_RIGHT AM_REG_PDM_VCFG_CHSET_RIGHT
#define AM_HAL_PDM_VCFG_CHANNEL_STEREO AM_REG_PDM_VCFG_CHSET_STEREO
//! @}
//*****************************************************************************
//
//! @name PDM Interrupts
//! @brief Macro definitions for the PDM interrupt status bits.
//!
//! These macros correspond to the bits in the PDM interrupt status register.
//! They may be used for any of the am_hal_pdm_int_x() functions.
//!
//! @{
//
//*****************************************************************************
#define AM_HAL_PDM_INT_UNDFL AM_REG_PDM_INTEN_UNDFL_M
#define AM_HAL_PDM_INT_OVF AM_REG_PDM_INTEN_OVF_M
#define AM_HAL_PDM_INT_FIFO AM_REG_PDM_INTEN_THR_M
//! @}
//*****************************************************************************
//
//! @brief Configuration structure for the PDM module.
//
//*****************************************************************************
typedef struct
{
//
//! @brief Set the PDM configuration reg with the values in this member.
//! Choose from AM_HAL_PDM_PCFG macros.
//! AM_HAL_PDM_PCFG_LRSWAP_xxx
//! AM_HAL_PDM_PCFG_RIGHT_PGA_xxx
//! AM_HAL_PDM_PCFG_LEFT_PGA_xxx
//! AM_HAL_PDM_PCFG_MCLKDIV_xxx
//! AM_HAL_PDM_PCFG_SINC_RATE()
//! AM_HAL_PDM_PCFG_ADCHPD_xxx
//! AM_HAL_PDM_PCFG_HPCUTOFF()
//! AM_HAL_PDM_PCFG_CYCLES()
//! AM_HAL_PDM_PCFG_SOFTMUTE_xxx
//! * AM_HAL_PDM_PCFG_PDMCORE_EN
//! AM_HAL_PDM_PCFG_PDMCORE_DISABLE
//
uint32_t ui32PDMConfigReg;
//
//! @brief Set the Voice Configuration reg with the values in this member.
//! Choose from AM_HAL_PDM_VCFG macros.
//! AM_HAL_PDM_IOCLK_xxx (also sets AM_REG_PDM_VCFG_IOCLKEN_EN)
//! * AM_REG_PDM_VCFG_IOCLKEN_EN
//! * AM_HAL_PDM_VCFG_RSTB_RESET
//! AM_HAL_PDM_VCFG_RSTB_NORMAL
//! * AM_HAL_PDM_VCFG_PDMCLK_EN
//! AM_HAL_PDM_VCFG_PDMCLK_DIS
//! AM_HAL_PDM_VCFG_I2SMODE_xxx
//! AM_HAL_PDM_VCFG_BCLKINV_xxx
//! AM_HAL_PDM_VCFG_DMICDEL_xxx
//! AM_HAL_PDM_VCFG_SELAP_xxx
//! AM_HAL_PDM_VCFG_PACK_xxx
//! AM_HAL_PDM_VCFG_CHANNEL_xxx
//!
//! * = These bits are set or cleared by the HAL PDM functions
//! am_hal_pdm_enable() or am_hal_pdm_disable().
//
uint32_t ui32VoiceConfigReg;
//
//! @brief Select the FIFO PCM sample threshold.
//!
//! The PDM controller will generate a processor interrupt when the number
//! of entries in the FIFO goes *above* this number.
//
uint32_t ui32FIFOThreshold;
} am_hal_pdm_config_t;
//*****************************************************************************
//
// Define function-like macros.
//
//*****************************************************************************
//*****************************************************************************
//
//! @brief Read the FIFO depth information as an in-line macro
//
//*****************************************************************************
#define am_hal_pdm_fifo_depth_read() (AM_REG(PDM, FR))
//*****************************************************************************
//
//! @brief Read the FIFO READ DATA as an in-line macro
//
//*****************************************************************************
#define am_hal_pdm_fifo_data_read() (AM_REG(PDM, FRD))
//*****************************************************************************
//
//! @brief Flush the FIFO as an in-line macro
//
//*****************************************************************************
#define am_hal_pdm_fifo_flush() (AM_REG(PDM, FLUSH) = 0)
//*****************************************************************************
//
//! @brief Set the PDM Configuration (PCFG) Register
//!
//! This function sets the PDM configuration register
//
//*****************************************************************************
#define am_hal_pdm_pcfg_set(Value) (AM_REG(PDM, PCFG) = Value)
//*****************************************************************************
//
//! @brief Get the PCFG register value from PDM module.
//
//*****************************************************************************
#define am_hal_pdm_pcfg_get() (AM_REG(PDM, PCFG))
//*****************************************************************************
//
//! @brief Set the Voice Configuration (VCFG) Register
//
//*****************************************************************************
#define am_hal_pdm_vcfg_set(Value) (AM_REG(PDM, VCFG) = Value)
//*****************************************************************************
//
//! @brief Get the VCFG register value from PDM module.
//
//*****************************************************************************
#define am_hal_pdm_vcfg_get() (AM_REG(PDM, VCFG))
//*****************************************************************************
//
//! @brief Set the FIFO Threshold
//
//*****************************************************************************
#define am_hal_pdm_thresh_set(thresh) (AM_REG(PDM, FTHR) = thresh)
//*****************************************************************************
//
//! @brief Get the FIFO Threshold register value from PDM module.
//
//*****************************************************************************
#define am_hal_pdm_thresh_get() (AM_REG(PDM, FTHR))
//*****************************************************************************
//
//! @brief Set the left microphone PGA gain.
//!
//*****************************************************************************
#define am_hal_pdm_left_gain_set(gain) (AM_BFW(PDM, PCFG, PGALEFT, gain))
//*****************************************************************************
//
//! @brief Set the right microphone PGA gain.
//
//*****************************************************************************
#define am_hal_pdm_right_gain_set(gain) (AM_BFW(PDM, PCFG, PGARIGHT, gain))
//*****************************************************************************
//
//! @brief Get the left microphone PGA gain value.
//
//*****************************************************************************
#define am_hal_pdm_left_gain_get() (AM_BFR(PDM, PCFG, PGALEFT))
//*****************************************************************************
//
//! @brief Get the right microphone PGA gain value.
//
//*****************************************************************************
#define am_hal_pdm_right_gain_get() (AM_BFR(PDM, PCFG, PGARIGHT))
//*****************************************************************************
//
//! @brief Enable the Soft Mute functionality.
//
//*****************************************************************************
#define am_hal_pdm_soft_mute_enable() (AM_BFWe(PDM, PCFG, SOFTMUTE, EN))
//*****************************************************************************
//
//! @brief Disable the Soft Mute functionality.
//
//*****************************************************************************
#define am_hal_pdm_soft_mute_disable() (AM_BFWe(PDM, PCFG, SOFTMUTE, DIS))
//*****************************************************************************
//
//! @brief Enable selected PDM Interrupts.
//!
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_pdm.h\n
//! AM_HAL_PDM_INT_UNDFL\n
//! AM_HAL_PDM_INT_OVF\n
//! AM_HAL_PDM_INT_FIFO\n
//
//*****************************************************************************
#define am_hal_pdm_int_enable(intrpt) (AM_REG(PDM, INTEN) |= intrpt)
//*****************************************************************************
//
//! @brief Return the enabled PDM Interrupts.
//!
//! Use this function to return all enabled PDM interrupts.
//!
//! @return all enabled PDM interrupts as a mask.\n
//! AM_HAL_PDM_INT_UNDFL\n
//! AM_HAL_PDM_INT_OVF\n
//! AM_HAL_PDM_INT_FIFO\n
//
//*****************************************************************************
#define am_hal_pdm_int_enable_get() (AM_REG(PDM, INTEN))
//*****************************************************************************
//
//! @brief Disable selected PDM Interrupts.
//!
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_pdm.h\n
//! AM_HAL_PDM_INT_UNDFL\n
//! AM_HAL_PDM_INT_OVF\n
//! AM_HAL_PDM_INT_FIFO\n
//
//*****************************************************************************
#define am_hal_pdm_int_disable(intrpt) (AM_REG(PDM, INTEN) &= ~intrpt)
//*****************************************************************************
//
//! @brief Clear selected PDM Interrupts.
//!
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_pdm.h\n
//! AM_HAL_PDM_INT_UNDFL\n
//! AM_HAL_PDM_INT_OVF\n
//! AM_HAL_PDM_INT_FIFO\n
//
//*****************************************************************************
#define am_hal_pdm_int_clear(intrpt) (AM_REG(PDM, INTCLR) = intrpt)
//*****************************************************************************
//
//! @brief Set selected PDM Interrupts.
//!
//! Use this function to set the PDM interrupts.
//!
//! @param ui32Interrupt - Use the macro bit fields provided in am_hal_pdm.h\n
//! AM_HAL_PDM_INT_UNDFL\n
//! AM_HAL_PDM_INT_OVF\n
//! AM_HAL_PDM_INT_FIFO\n
//
//*****************************************************************************
#define am_hal_pdm_int_set(intrpt) (AM_REG(PDM, INTSET) = intrpt)
//*****************************************************************************
//
// External function definitions
//
//*****************************************************************************
extern void am_hal_pdm_config(am_hal_pdm_config_t * cfg);
extern void am_hal_pdm_enable(void);
extern void am_hal_pdm_disable(void);
extern uint32_t am_hal_pdm_int_status_get(bool bEnabledOnly);
#ifdef __cplusplus
}
#endif
#endif // AM_HAL_PDM_H
//*****************************************************************************
//
// End Doxygen group.
//! @}
//
//*****************************************************************************
|