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  */
323 #ifndef ti_drivers_pdm_PDMCC26XX__include
324 #define ti_drivers_pdm_PDMCC26XX__include
325 
326 #include <ti/drivers/dpl/HwiP.h>
327 #include <ti/drivers/dpl/SemaphoreP.h>
328 
329 #include <ti/drivers/PIN.h>
330 #include <ti/drivers/Power.h>
332 
333 #ifdef __cplusplus
334 extern "C" {
335 #endif
336 
337 /*********************************************************************
338  * CONSTANTS
339  */
340 
348 #ifndef PDM_TASK_STACK_SIZE
349 #define PDM_TASK_STACK_SIZE 850
350 #endif
351 
353 #define PCM_SAMPLE_SIZE 16 // Only 16 bits supported for now
354 
356 #define PCM_COMPRESSION_RATE 4
357 
359 #define MINIMUM_PDM_BUFFER_QUEUE_DEPTH 3
360 
365 #define PCM_METADATA_SIZE sizeof(PDMCC26XX_metaData)
366 
367 /*********************************************************************
368  * TYPEDEFS
369  */
370 
372 typedef struct {
373  uint8_t seqNum;
374  int8_t si;
375  int16_t pv;
377 
379 typedef struct {
381  uint8_t pBuffer[];
383 
389 typedef void *(*PDMCC26XX_MallocFxn)(size_t memSize);
390 
397 typedef void (*PDMCC26XX_FreeFxn)(void *ptr, size_t memSize);
398 
410 typedef bool (*PDMCC26XX_Pdm2PcmFxn)(const void *pdmInBuffer, uint32_t *decimationState, const int32_t *biquadCoefficients, int16_t *pcmOutBuffer);
411 
417 typedef struct {
419  void *object;
420 
422  void const *hwAttrs;
424 
426 extern const PDMCC26XX_Config PDMCC26XX_config[];
427 
434 typedef struct {
440 
445 
449 typedef enum {
462 
469 typedef enum {
473 
485 typedef enum {
493 
499 typedef struct {
500  void *arg;
501  PDMCC26XX_Status status;
503 
509 typedef void (*PDMCC26XX_CallbackFxn) (PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification);
510 
526 typedef struct {
530  PDMCC26XX_Status status;
532 
540 typedef struct {
541  /* PDM control variables */
553  uint16_t retBufSizeInBytes;
556  const int32_t *decimationFilter;
563  PDMCC26XX_Gain defaultFilterGain;
564  PDMCC26XX_PcmSampleRate pcmSampleRate;
572  uintptr_t custom;
574 
580 typedef struct {
581  /* PDM control variables */
587  bool isOpen;
588  uint16_t retBufSizeInBytes;
594  const int32_t *decimationFilter;
607  HwiP_Struct hwi;
609 
614 extern void PDMCC26XX_init(PDMCC26XX_Handle handle);
615 
633 extern PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params);
634 
650 extern void PDMCC26XX_close(PDMCC26XX_Handle handle);
651 
670 extern bool PDMCC26XX_startStream(PDMCC26XX_Handle handle);
671 
688 extern bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle);
689 
708 extern bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest);
709 
710 /*
711  * ======== PDMCC26XX_Params_init ========
712  * @brief Function for initialising a PDMCC26XX_Params instance to its default value
713  *
714  * @param params Pointer to a set of uninitialised params
715  *
716  */
717 extern void PDMCC26XX_Params_init(PDMCC26XX_Params *params);
718 
719 
720 #ifdef __cplusplus
721 }
722 #endif
723 
724 #endif /* ti_drivers_pdm_PDMCC26XX__include */
uint8_t PIN_Id
Pin identifier data type.
Definition: PIN.h:578
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:557
PDMCC26XX_Gain
Predefined gain settings.
Definition: PDMCC26XX.h:485
PDMCC26XX_pcmBuffer * buffer
Definition: PDMCC26XX.h:527
int16_t pv
Definition: PDMCC26XX.h:375
const int32_t * decimationFilter
Definition: PDMCC26XX.h:556
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:596
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:499
void * arg
Definition: PDMCC26XX.h:500
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:389
Definition: PDMCC26XX.h:459
Power Manager.
bool applyCompression
Definition: PDMCC26XX.h:584
Power manager interface for CC26XX/CC13XX.
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:602
Metadata associated with an array of PCM data.
Definition: PDMCC26XX.h:372
PIN_Handle pinHandle
Definition: PDMCC26XX.h:606
bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle)
Function to stop streaming PDM data.
int taskPriority
Definition: PDMCC26XX.h:438
HwiP_Struct hwi
Definition: PDMCC26XX.h:607
const PDMCC26XX_Config PDMCC26XX_config[]
PDMCC26XX_PcmSampleRate pcmSampleRate
Definition: PDMCC26XX.h:564
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:601
PCM buffer pointed to in a PDMCC26XX_BufferRequest.
Definition: PDMCC26XX.h:379
uint8_t pdmBufferQueueDepth
Definition: PDMCC26XX.h:546
Definition: PDMCC26XX.h:451
bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest)
Function for requesting buffer.
Definition: PDMCC26XX.h:489
void PDMCC26XX_init(PDMCC26XX_Handle handle)
PDM CC26XX initialization.
Definition: PDMCC26XX.h:457
PDMCC26XX_metaData metaData
Definition: PDMCC26XX.h:380
PDMCC26XX_StreamNotification * streamNotification
Definition: PDMCC26XX.h:600
void const * hwAttrs
Definition: PDMCC26XX.h:422
Definition: PDMCC26XX.h:471
PDMCC26XX_Pdm2PcmFxn pdm2pcmFxn
Definition: PDMCC26XX.h:604
bool micPowerActiveHigh
Definition: PDMCC26XX.h:583
Definition: PDMCC26XX.h:491
uint16_t pcmBufferSizeInBytes
Definition: PDMCC26XX.h:589
bool micPowerActiveHigh
Definition: PDMCC26XX.h:542
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:526
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:540
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:553
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:590
Definition: PDMCC26XX.h:488
Definition: PDMCC26XX.h:487
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:565
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
Definition: PDMCC26XX.h:417
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:588
Definition: PDMCC26XX.h:486
Definition: PDMCC26XX.h:460
void * object
Definition: PDMCC26XX.h:419
underlying data structure for type PIN_State
Definition: PIN.h:708
bool streamStarted
Definition: PDMCC26XX.h:582
void(* PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification)
The definition of a callback function used when buffers are ready.
Definition: PDMCC26XX.h:509
Definition: PDMCC26XX.h:450
uint8_t seqNum
Definition: PDMCC26XX.h:373
PDMCC26XX_Status status
Definition: PDMCC26XX.h:530
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:570
PDMCC26XX_Gain defaultFilterGain
Definition: PDMCC26XX.h:563
const int32_t * decimationFilter
Definition: PDMCC26XX.h:594
int8_t si
Definition: PDMCC26XX.h:374
PIN_Id micPower
Definition: PDMCC26XX.h:436
uint32_t * decimationFilterState
Definition: PDMCC26XX.h:595
PDMCC26XX_Status status
Definition: PDMCC26XX.h:501
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:410
Definition: PDMCC26XX.h:470
bool isOpen
Definition: PDMCC26XX.h:587
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:571
PDMCC26XX_PcmSampleRate
PCM output sample rates supported by the driver.
Definition: PDMCC26XX.h:469
PDMCC26XX Object.
Definition: PDMCC26XX.h:580
PDMCC26XX_Status
Status codes that are set by the PDM driver.
Definition: PDMCC26XX.h:449
Definition: PDMCC26XX.h:490
PDMCC26XX_Config * PDMCC26XX_Handle
A handle that is returned from a PDMCC26XX_open() call.
Definition: PDMCC26XX.h:444
PIN_State pinState
Definition: PDMCC26XX.h:605
bool applyCompression
Definition: PDMCC26XX.h:543
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:603
uintptr_t custom
Definition: PDMCC26XX.h:572
void PDMCC26XX_Params_init(PDMCC26XX_Params *params)
Generic PIN & GPIO driver.
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:397
PDMCC26XX Hardware attributes.
Definition: PDMCC26XX.h:434
Definition: PDMCC26XX.h:454
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:569
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale