PDMCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
348 #ifndef ti_drivers_pdm_PDMCC26XX__include
349 #define ti_drivers_pdm_PDMCC26XX__include
350 
351 #include <ti/drivers/dpl/HwiP.h>
352 #include <ti/drivers/dpl/SemaphoreP.h>
353 
354 #include <ti/drivers/Power.h>
356 
357 #ifdef __cplusplus
358 extern "C" {
359 #endif
360 
361 /*********************************************************************
362  * CONSTANTS
363  */
364 
372 #ifndef PDM_TASK_STACK_SIZE
373  #define PDM_TASK_STACK_SIZE 850
374 #endif
375 
377 #define PCM_SAMPLE_SIZE 16 // Only 16 bits supported for now
378 
380 #define PCM_COMPRESSION_RATE 4
381 
383 #define MINIMUM_PDM_BUFFER_QUEUE_DEPTH 3
384 
389 #define PCM_METADATA_SIZE sizeof(PDMCC26XX_metaData)
390 
391 /*********************************************************************
392  * TYPEDEFS
393  */
394 
396 typedef struct
397 {
398  uint8_t seqNum;
399  int8_t si;
400  int16_t pv;
402 
404 typedef struct
405 {
407  uint8_t pBuffer[];
409 
415 typedef void *(*PDMCC26XX_MallocFxn)(size_t memSize);
416 
423 typedef void (*PDMCC26XX_FreeFxn)(void *ptr, size_t memSize);
424 
436 typedef bool (*PDMCC26XX_Pdm2PcmFxn)(const void *pdmInBuffer,
437  uint32_t *decimationState,
438  const int32_t *biquadCoefficients,
439  int16_t *pcmOutBuffer);
440 
446 typedef struct
447 {
449  void *object;
450 
452  void const *hwAttrs;
454 
456 extern const PDMCC26XX_Config PDMCC26XX_config[];
457 
464 typedef struct
465 {
467  uint32_t micPower;
471 
476 
480 typedef enum
481 {
494 
501 typedef enum
502 {
506 
518 typedef enum
519 {
527 
533 typedef struct
534 {
535  void *arg;
536  PDMCC26XX_Status status;
538 
544 typedef void (*PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification);
545 
561 typedef struct
562 {
566  PDMCC26XX_Status status;
568 
576 typedef struct
577 {
578  /* PDM control variables */
590  uint16_t retBufSizeInBytes;
593  const int32_t *decimationFilter;
602  PDMCC26XX_Gain defaultFilterGain;
604  PDMCC26XX_PcmSampleRate pcmSampleRate;
612  uintptr_t custom;
614 
620 typedef struct
621 {
622  /* PDM control variables */
628  bool isOpen;
629  uint16_t retBufSizeInBytes;
636  const int32_t *decimationFilter;
648  HwiP_Struct hwi;
650 
655 extern void PDMCC26XX_init(PDMCC26XX_Handle handle);
656 
675 extern PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params);
676 
692 extern void PDMCC26XX_close(PDMCC26XX_Handle handle);
693 
712 extern bool PDMCC26XX_startStream(PDMCC26XX_Handle handle);
713 
732 extern bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle);
733 
752 extern bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest);
753 
754 /*
755  * ======== PDMCC26XX_Params_init ========
756  * @brief Function for initialising a PDMCC26XX_Params instance to its default value
757  *
758  * @param params Pointer to a set of uninitialised params
759  *
760  */
762 
763 #ifdef __cplusplus
764 }
765 #endif
766 
767 #endif /* ti_drivers_pdm_PDMCC26XX__include */
void PDMCC26XX_close(PDMCC26XX_Handle handle)
Function to close a given CC26XX PDM peripheral specified by the PDM handle.
size_t decimationFilterStateSize
Definition: PDMCC26XX.h:595
PDMCC26XX_Gain
Predefined gain settings.
Definition: PDMCC26XX.h:518
ADC_Params params
Definition: Driver_Init.h:11
PDMCC26XX_pcmBuffer * buffer
Definition: PDMCC26XX.h:563
int16_t pv
Definition: PDMCC26XX.h:400
const int32_t * decimationFilter
Definition: PDMCC26XX.h:593
PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params)
Function to initialize the CC26XX PDM peripheral specified by the particular handle. The parameter specifies which mode the PDM will operate.
size_t decimationFilterStateSize
Definition: PDMCC26XX.h:639
bool PDMCC26XX_startStream(PDMCC26XX_Handle handle)
Function to start streaming PDM data.
A PDMCC26XX_StreamNotification data structure is used with PDMCC26XX_CallbackFxn(). Provides notification about available buffers and potential errors.
Definition: PDMCC26XX.h:533
void * arg
Definition: PDMCC26XX.h:535
void *(* PDMCC26XX_MallocFxn)(size_t memSize)
PDMCC26XX_MallocFxn is a function pointer for the malloc function to be used by the driver...
Definition: PDMCC26XX.h:415
Definition: PDMCC26XX.h:491
Power Manager.
bool applyCompression
Definition: PDMCC26XX.h:625
Power manager interface for CC26XX/CC13XX.
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:645
Metadata associated with an array of PCM data.
Definition: PDMCC26XX.h:396
bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle)
Function to stop streaming PDM data.
int taskPriority
Definition: PDMCC26XX.h:469
HwiP_Struct hwi
Definition: PDMCC26XX.h:648
const PDMCC26XX_Config PDMCC26XX_config[]
PDMCC26XX_PcmSampleRate pcmSampleRate
Definition: PDMCC26XX.h:604
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:644
PCM buffer pointed to in a PDMCC26XX_BufferRequest.
Definition: PDMCC26XX.h:404
uint8_t pdmBufferQueueDepth
Definition: PDMCC26XX.h:583
Definition: PDMCC26XX.h:483
bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest)
Function for requesting buffer.
Definition: PDMCC26XX.h:523
void PDMCC26XX_init(PDMCC26XX_Handle handle)
PDM CC26XX initialization.
Definition: PDMCC26XX.h:489
PDMCC26XX_metaData metaData
Definition: PDMCC26XX.h:406
PDMCC26XX_StreamNotification * streamNotification
Definition: PDMCC26XX.h:643
void const * hwAttrs
Definition: PDMCC26XX.h:452
Definition: PDMCC26XX.h:504
PDMCC26XX_Pdm2PcmFxn pdm2pcmFxn
Definition: PDMCC26XX.h:647
bool micPowerActiveHigh
Definition: PDMCC26XX.h:624
Definition: PDMCC26XX.h:525
uint16_t pcmBufferSizeInBytes
Definition: PDMCC26XX.h:630
uint32_t micPower
Definition: PDMCC26XX.h:467
bool micPowerActiveHigh
Definition: PDMCC26XX.h:579
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:561
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:576
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:590
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:632
Definition: PDMCC26XX.h:522
Definition: PDMCC26XX.h:521
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:605
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
Definition: PDMCC26XX.h:446
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:629
Definition: PDMCC26XX.h:520
Definition: PDMCC26XX.h:492
void * object
Definition: PDMCC26XX.h:449
bool streamStarted
Definition: PDMCC26XX.h:623
void(* PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification)
The definition of a callback function used when buffers are ready.
Definition: PDMCC26XX.h:544
Definition: PDMCC26XX.h:482
uint8_t seqNum
Definition: PDMCC26XX.h:398
PDMCC26XX_Status status
Definition: PDMCC26XX.h:566
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:610
PDMCC26XX_Gain defaultFilterGain
Definition: PDMCC26XX.h:602
const int32_t * decimationFilter
Definition: PDMCC26XX.h:636
int8_t si
Definition: PDMCC26XX.h:399
uint32_t * decimationFilterState
Definition: PDMCC26XX.h:638
PDMCC26XX_Status status
Definition: PDMCC26XX.h:536
bool(* PDMCC26XX_Pdm2PcmFxn)(const void *pdmInBuffer, uint32_t *decimationState, const int32_t *biquadCoefficients, int16_t *pcmOutBuffer)
Function that converts PDM input buffer to PCM output.
Definition: PDMCC26XX.h:436
Definition: PDMCC26XX.h:503
bool isOpen
Definition: PDMCC26XX.h:628
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:611
PDMCC26XX_PcmSampleRate
PCM output sample rates supported by the driver.
Definition: PDMCC26XX.h:501
PDMCC26XX Object.
Definition: PDMCC26XX.h:620
PDMCC26XX_Status
Status codes that are set by the PDM driver.
Definition: PDMCC26XX.h:480
Definition: PDMCC26XX.h:524
PDMCC26XX_Config * PDMCC26XX_Handle
A handle that is returned from a PDMCC26XX_open() call.
Definition: PDMCC26XX.h:475
bool applyCompression
Definition: PDMCC26XX.h:580
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:646
uintptr_t custom
Definition: PDMCC26XX.h:612
void PDMCC26XX_Params_init(PDMCC26XX_Params *params)
void(* PDMCC26XX_FreeFxn)(void *ptr, size_t memSize)
PDMCC26XX_FreeFxn is a function pointer for the free function to be used by the driver. This is needed for memory clean up, if something goes wrong.
Definition: PDMCC26XX.h:423
PDMCC26XX Hardware attributes.
Definition: PDMCC26XX.h:464
Definition: PDMCC26XX.h:486
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:609
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale