PDMCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2017, 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  */
266 #ifndef ti_drivers_pdm_PDMCC26XX__include
267 #define ti_drivers_pdm_PDMCC26XX__include
268 
269 #ifdef __cplusplus
270 extern "C" {
271 #endif
272 
273 #include <ti/drivers/dpl/HwiP.h>
274 #include <ti/drivers/dpl/SemaphoreP.h>
275 
276 #include <ti/drivers/PIN.h>
277 #include <ti/drivers/Power.h>
279 
280 /*********************************************************************
281  * CONSTANTS
282  */
283 
291 #ifndef PDM_TASK_STACK_SIZE
292 #define PDM_TASK_STACK_SIZE 850
293 #endif
294 
296 #define PCM_SAMPLE_SIZE 16 // Only 16 bits supported for now
297 
299 #define PCM_COMPRESSION_RATE 4
300 
302 #define MINIMUM_PDM_BUFFER_QUEUE_DEPTH 3
303 
308 #define PCM_METADATA_SIZE sizeof(PDMCC26XX_metaData)
309 
310 /*********************************************************************
311  * TYPEDEFS
312  */
313 
315 typedef struct {
316  uint8_t seqNum;
317  int8_t si;
318  int16_t pv;
320 
322 typedef struct {
324  uint8_t pBuffer[];
326 
332 typedef void *(*PDMCC26XX_MallocFxn)(size_t memSize);
333 
340 typedef void (*PDMCC26XX_FreeFxn)(void *ptr, size_t memSize);
341 
347 typedef struct PDMCC26XX_Config {
349  void *object;
350 
352  void const *hwAttrs;
354 
356 extern const PDMCC26XX_Config PDMCC26XX_config[];
357 
364 typedef struct PDMCC26XX_HWAttrs {
370 
375 
379 typedef enum PDMCC26XX_Status {
392 
405 typedef enum PDMCC26XX_Gain {
413 
420  void *arg;
421  PDMCC26XX_Status status;
423 
429 typedef void (*PDMCC26XX_CallbackFxn) (PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification);
430 
446 typedef struct PDMCC26XX_BufferRequest {
450  PDMCC26XX_Status status;
452 
460 typedef struct PDMCC26XX_Params {
461  /* PDM control variables */
476  uint16_t retBufSizeInBytes;
479  int32_t *decimationFilter;
488  PDMCC26XX_Gain micGain;
491  uintptr_t custom;
493 
499 typedef struct PDMCC26XX_Object {
500  /* PDM control variables */
510  bool isOpen;
511  uint16_t retBufSizeInBytes;
517  int32_t *decimationFilter;
521  PDMCC26XX_Gain micGain;
527  HwiP_Struct hwi;
529 
534 extern void PDMCC26XX_init(PDMCC26XX_Handle handle);
535 
553 extern PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params);
554 
570 extern void PDMCC26XX_close(PDMCC26XX_Handle handle);
571 
590 extern bool PDMCC26XX_startStream(PDMCC26XX_Handle handle);
591 
608 extern bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle);
609 
628 extern bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest);
629 
630 /*
631  * ======== PDMCC26XX_Params_init ========
632  * @brief Function for initialising a PDMCC26XX_Params instance to its default value
633  *
634  * @param params Pointer to a set of uninitialised params
635  *
636  */
637 extern void PDMCC26XX_Params_init(PDMCC26XX_Params *params);
638 
639 
640 #ifdef __cplusplus
641 }
642 #endif
643 
644 #endif /* ti_drivers_pdm_PDMCC26XX__include */
uint8_t PIN_Id
Pin identifier data type.
Definition: PIN.h:577
void PDMCC26XX_close(PDMCC26XX_Handle handle)
Function to close a given CC26XX PDM peripheral specified by the PDM handle.
PDMCC26XX_Gain
Predefined gain settings.
Definition: PDMCC26XX.h:405
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:521
PDMCC26XX_pcmBuffer * buffer
Definition: PDMCC26XX.h:447
int16_t pv
Definition: PDMCC26XX.h:318
bool useDefaultFilter
Definition: PDMCC26XX.h:462
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.
struct PDMCC26XX_Config PDMCC26XX_Config
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
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:419
void * arg
Definition: PDMCC26XX.h:420
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:332
Definition: PDMCC26XX.h:389
struct PDMCC26XX_StreamNotification PDMCC26XX_StreamNotification
A PDMCC26XX_StreamNotification data structure is used with PDMCC26XX_CallbackFxn(). Provides notification about available buffers and potential errors.
Power Manager interface.
bool applyCompression
Definition: PDMCC26XX.h:507
Power manager interface for CC26XX/CC13XX.
struct PDMCC26XX_Object PDMCC26XX_Object
PDMCC26XX Object.
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:523
Metadata associated with an array of PCM data.
Definition: PDMCC26XX.h:315
PIN_Handle pinHandle
Definition: PDMCC26XX.h:526
bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle)
Function to stop streaming PDM data.
int taskPriority
Definition: PDMCC26XX.h:368
HwiP_Struct hwi
Definition: PDMCC26XX.h:527
const PDMCC26XX_Config PDMCC26XX_config[]
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:522
PCM buffer pointed to in a PDMCC26XX_BufferRequest.
Definition: PDMCC26XX.h:322
struct PDMCC26XX_HWAttrs PDMCC26XX_HWAttrs
PDMCC26XX Hardware attributes.
uint8_t pdmBufferQueueDepth
Definition: PDMCC26XX.h:469
struct PDMCC26XX_Params PDMCC26XX_Params
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:381
bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest)
Function for requesting buffer.
Definition: PDMCC26XX.h:409
void PDMCC26XX_init(PDMCC26XX_Handle handle)
PDM CC26XX initialization.
int32_t * decimationFilter
Definition: PDMCC26XX.h:479
struct PDMCC26XX_Config * PDMCC26XX_Handle
A handle that is returned from a PDMCC26XX_open() call.
Definition: PDMCC26XX.h:374
Definition: PDMCC26XX.h:387
PDMCC26XX_metaData metaData
Definition: PDMCC26XX.h:323
PDMCC26XX_StreamNotification * streamNotification
Definition: PDMCC26XX.h:520
void const * hwAttrs
Definition: PDMCC26XX.h:352
bool micPowerActiveHigh
Definition: PDMCC26XX.h:506
Definition: PDMCC26XX.h:411
uint16_t pcmBufferSizeInBytes
Definition: PDMCC26XX.h:512
bool micPowerActiveHigh
Definition: PDMCC26XX.h:465
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:446
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:460
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:476
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:513
Definition: PDMCC26XX.h:408
Definition: PDMCC26XX.h:407
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:483
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
Definition: PDMCC26XX.h:347
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:511
Definition: PDMCC26XX.h:406
Definition: PDMCC26XX.h:390
void * object
Definition: PDMCC26XX.h:349
underlying data structure for type PIN_State
Definition: PIN.h:707
bool streamStarted
Definition: PDMCC26XX.h:505
void(* PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification)
The definition of a callback function used when buffers are ready.
Definition: PDMCC26XX.h:429
Definition: PDMCC26XX.h:380
uint8_t seqNum
Definition: PDMCC26XX.h:316
PDMCC26XX_Status status
Definition: PDMCC26XX.h:450
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:489
int8_t si
Definition: PDMCC26XX.h:317
PIN_Id micPower
Definition: PDMCC26XX.h:366
PDMCC26XX_Status status
Definition: PDMCC26XX.h:421
bool useDefaultFilter
Definition: PDMCC26XX.h:501
bool isOpen
Definition: PDMCC26XX.h:510
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:490
PDMCC26XX Object.
Definition: PDMCC26XX.h:499
PDMCC26XX_Status
Status codes that are set by the PDM driver.
Definition: PDMCC26XX.h:379
int32_t * decimationFilter
Definition: PDMCC26XX.h:517
struct PDMCC26XX_BufferRequest PDMCC26XX_BufferRequest
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:410
PIN_State pinState
Definition: PDMCC26XX.h:525
bool applyCompression
Definition: PDMCC26XX.h:466
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:524
uintptr_t custom
Definition: PDMCC26XX.h:491
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:340
PDMCC26XX Hardware attributes.
Definition: PDMCC26XX.h:364
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:488
Definition: PDMCC26XX.h:384
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:487
Copyright 2018, Texas Instruments Incorporated