BLE-Stack APIs  3.00.01
PDMCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, 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  */
257 #ifndef ti_drivers_pdm_PDMCC26XX__include
258 #define ti_drivers_pdm_PDMCC26XX__include
259 
260 #ifdef __cplusplus
261 extern "C" {
262 #endif
263 
268 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
269 
270 #include <ti/sysbios/knl/Semaphore.h>
271 #include <ti/drivers/PIN.h>
272 #include <ti/sysbios/family/arm/m3/Hwi.h>
273 #include <ti/drivers/Power.h>
274 #include <ti/drivers/power/PowerCC26XX.h>
275 
276 /*********************************************************************
277  * CONSTANTS
278  */
279 
287 #ifndef PDM_TASK_STACK_SIZE
288 #define PDM_TASK_STACK_SIZE 550
289 #endif
290 
292 #define PCM_SAMPLE_SIZE 16 // Only 16 bits supported for now
293 
295 #define PCM_COMPRESSION_RATE 4
296 
298 #define MINIMUM_PDM_BUFFER_QUEUE_DEPTH 3
299 
304 #define PCM_METADATA_SIZE sizeof(PDMCC26XX_metaData)
305 
306 /*********************************************************************
307  * TYPEDEFS
308  */
309 
311 typedef struct {
312  uint8_t seqNum;
313  int8_t si;
314  int16_t pv;
316 
318 typedef struct {
320  uint8_t pBuffer[];
322 
328 typedef void *(*PDMCC26XX_MallocFxn)(size_t memSize);
329 
336 typedef void (*PDMCC26XX_FreeFxn)(void *ptr, size_t memSize);
337 
343 typedef struct PDMCC26XX_Config {
345  void *object;
346 
348  void const *hwAttrs;
350 
352 extern const PDMCC26XX_Config PDMCC26XX_config[];
353 
360 typedef struct PDMCC26XX_HWAttrs {
362  PIN_Id micPower;
366 
371 
375 typedef enum PDMCC26XX_Status {
388 
401 typedef enum PDMCC26XX_Gain {
409 
416  void *arg;
417  PDMCC26XX_Status status;
419 
425 typedef void (*PDMCC26XX_CallbackFxn) (PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification);
426 
442 typedef struct PDMCC26XX_BufferRequest {
446  PDMCC26XX_Status status;
448 
456 typedef struct PDMCC26XX_Params {
457  /* PDM control variables */
465  uint8_t pdmBufferQueueDepth;
472  uint16_t retBufSizeInBytes;
475  int32_t *decimationFilter;
484  PDMCC26XX_Gain micGain;
487  uintptr_t custom;
489 
495 typedef struct PDMCC26XX_Object {
496  /* PDM control variables */
506  bool isOpen;
507  uint16_t retBufSizeInBytes;
513  int32_t *decimationFilter;
517  PDMCC26XX_Gain micGain;
521  PIN_State pinState;
522  PIN_Handle pinHandle;
523  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
525 
530 extern void PDMCC26XX_init(PDMCC26XX_Handle handle);
531 
549 extern PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params);
550 
566 extern void PDMCC26XX_close(PDMCC26XX_Handle handle);
567 
584 extern bool PDMCC26XX_startStream(PDMCC26XX_Handle handle);
585 
602 extern bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle);
603 
622 extern bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest);
623 
624 /*
625  * ======== PDMCC26XX_Params_init ========
626  * @brief Function for initialising a PDMCC26XX_Params instance to its default value
627  *
628  * @param params Pointer to a set of uninitialised params
629  *
630  */
631 extern void PDMCC26XX_Params_init(PDMCC26XX_Params *params);
632 
633 
634 /* Do not interfere with the app if they include the family Hwi module */
635 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
636 
637 #ifdef __cplusplus
638 }
639 #endif
640 
641 #endif /* ti_drivers_pdm_PDMCC26XX__include */
int16_t pv
Definition: PDMCC26XX.h:314
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:401
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.
PDMCC26XX_Status status
Definition: PDMCC26XX.h:417
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.
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:486
A PDMCC26XX_StreamNotification data structure is used with PDMCC26XX_CallbackFxn(). Provides notification about available buffers and potential errors.
Definition: PDMCC26XX.h:415
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:328
void * object
Definition: PDMCC26XX.h:345
Definition: PDMCC26XX.h:385
struct PDMCC26XX_StreamNotification PDMCC26XX_StreamNotification
A PDMCC26XX_StreamNotification data structure is used with PDMCC26XX_CallbackFxn(). Provides notification about available buffers and potential errors.
uint16_t pcmBufferSizeInBytes
Definition: PDMCC26XX.h:508
PDMCC26XX_pcmBuffer * buffer
Definition: PDMCC26XX.h:443
void * arg
Definition: PDMCC26XX.h:416
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:518
struct PDMCC26XX_Object PDMCC26XX_Object
PDMCC26XX Object.
Metadata associated with an array of PCM data.
Definition: PDMCC26XX.h:311
bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle)
Function to stop streaming PDM data.
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:483
const PDMCC26XX_Config PDMCC26XX_config[]
PCM buffer pointed to in a PDMCC26XX_BufferRequest.
Definition: PDMCC26XX.h:318
PDMCC26XX_StreamNotification * streamNotification
Definition: PDMCC26XX.h:516
struct PDMCC26XX_HWAttrs PDMCC26XX_HWAttrs
PDMCC26XX Hardware attributes.
struct PDMCC26XX_Params PDMCC26XX_Params
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:519
bool micPowerActiveHigh
Definition: PDMCC26XX.h:461
Definition: PDMCC26XX.h:377
bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest)
Function for requesting buffer.
PDMCC26XX_Status status
Definition: PDMCC26XX.h:446
bool micPowerActiveHigh
Definition: PDMCC26XX.h:502
Definition: PDMCC26XX.h:405
int32_t * decimationFilter
Definition: PDMCC26XX.h:513
void PDMCC26XX_init(PDMCC26XX_Handle handle)
PDM CC26XX initialization.
int8_t si
Definition: PDMCC26XX.h:313
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:507
struct PDMCC26XX_Config * PDMCC26XX_Handle
A handle that is returned from a PDMCC26XX_open() call.
Definition: PDMCC26XX.h:370
Definition: PDMCC26XX.h:383
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:520
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:517
Definition: PDMCC26XX.h:407
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:442
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:456
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:479
PDMCC26XX_metaData metaData
Definition: PDMCC26XX.h:319
Definition: PDMCC26XX.h:404
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:484
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: PDMCC26XX.h:523
Definition: PDMCC26XX.h:403
int taskPriority
Definition: PDMCC26XX.h:364
bool useDefaultFilter
Definition: PDMCC26XX.h:497
PIN_Handle pinHandle
Definition: PDMCC26XX.h:522
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
Definition: PDMCC26XX.h:343
bool applyCompression
Definition: PDMCC26XX.h:503
Definition: PDMCC26XX.h:402
Definition: PDMCC26XX.h:386
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:509
bool useDefaultFilter
Definition: PDMCC26XX.h:458
bool isOpen
Definition: PDMCC26XX.h:506
void(* PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification)
The definition of a callback function used when buffers are ready.
Definition: PDMCC26XX.h:425
Definition: PDMCC26XX.h:376
uint8_t seqNum
Definition: PDMCC26XX.h:312
bool streamStarted
Definition: PDMCC26XX.h:501
PIN_Id micPower
Definition: PDMCC26XX.h:362
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:485
bool applyCompression
Definition: PDMCC26XX.h:462
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:472
uintptr_t custom
Definition: PDMCC26XX.h:487
PDMCC26XX Object.
Definition: PDMCC26XX.h:495
PDMCC26XX_Status
Status codes that are set by the PDM driver.
Definition: PDMCC26XX.h:375
struct PDMCC26XX_BufferRequest PDMCC26XX_BufferRequest
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:406
void const * hwAttrs
Definition: PDMCC26XX.h:348
PIN_State pinState
Definition: PDMCC26XX.h:521
int32_t * decimationFilter
Definition: PDMCC26XX.h:475
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:336
PDMCC26XX Hardware attributes.
Definition: PDMCC26XX.h:360
Definition: PDMCC26XX.h:380
Copyright 2017, Texas Instruments Incorporated