TI-RTOS Drivers  tidrivers_cc13xx_cc26xx_2_21_00_04
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  */
249 #ifndef ti_drivers_pdm_PDMCC26XX__include
250 #define ti_drivers_pdm_PDMCC26XX__include
251 
252 #ifdef __cplusplus
253 extern "C" {
254 #endif
255 
260 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
261 
262 #include <ti/sysbios/knl/Semaphore.h>
263 #include <ti/drivers/PIN.h>
264 #include <ti/sysbios/family/arm/m3/Hwi.h>
265 #include <ti/drivers/Power.h>
267 
268 /*********************************************************************
269  * CONSTANTS
270  */
271 
275 #define PDM_TASK_STACK_SIZE 500
276 
284 #define PDM_BUFFER_SIZE_IN_BLOCKS 3
285 
287 #define PCM_SAMPLE_SIZE 16 // Only 16 bits supported for now
288 
290 #define PCM_COMPRESSION_RATE 4
291 
296 #define PCM_METADATA_SIZE sizeof(PDMCC26XX_metaData)
297 
298 /*********************************************************************
299  * TYPEDEFS
300  */
301 
303 typedef struct {
304  uint8_t seqNum;
305  int8_t si;
306  int16_t pv;
308 
310 typedef struct {
312  uint8_t pBuffer[];
314 
320 typedef void *(*PDMCC26XX_MallocFxn)(size_t memSize);
321 
328 typedef void (*PDMCC26XX_FreeFxn)(void *ptr, size_t memSize);
329 
335 typedef struct PDMCC26XX_Config {
337  void *object;
338 
340  void const *hwAttrs;
342 
344 extern const PDMCC26XX_Config PDMCC26XX_config[];
345 
352 typedef struct PDMCC26XX_HWAttrs {
358 
363 
367 typedef enum PDMCC26XX_Status {
380 
393 typedef enum PDMCC26XX_Gain {
401 
408  void *arg;
411 
417 typedef void (*PDMCC26XX_CallbackFxn) (PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification);
418 
434 typedef struct PDMCC26XX_BufferRequest {
440 
448 typedef struct PDMCC26XX_Params {
449  /* PDM control variables */
454  int32_t *decimationFilter;
464  uint16_t retBufSizeInBytes;
469  uintptr_t custom;
472 
478 typedef struct PDMCC26XX_Object {
479  /* PDM control variables */
484  int32_t *decimationFilter;
494  uint16_t retBufSizeInBytes;
502  /* PDM SYS/BIOS objects */
503  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
504  Semaphore_Struct blockComplete;
506  /* PIN driver state object and handle */
510  bool isOpen;
512 
517 extern void PDMCC26XX_init(PDMCC26XX_Handle handle);
518 
536 extern PDMCC26XX_Handle PDMCC26XX_open(PDMCC26XX_Params *params);
537 
553 extern void PDMCC26XX_close(PDMCC26XX_Handle handle);
554 
571 extern bool PDMCC26XX_startStream(PDMCC26XX_Handle handle);
572 
589 extern bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle);
590 
609 extern bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest);
610 
611 
612 /* Do not interfere with the app if they include the family Hwi module */
613 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
614 
615 #ifdef __cplusplus
616 }
617 #endif
618 
619 #endif /* ti_drivers_pdm_PDMCC26XX__include */
uint8_t PIN_Id
Pin identifier data type.
Definition: PIN.h:557
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:393
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:487
PDMCC26XX_pcmBuffer * buffer
Definition: PDMCC26XX.h:435
int16_t pv
Definition: PDMCC26XX.h:306
bool useDefaultFilter
Definition: PDMCC26XX.h:451
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:407
void * arg
Definition: PDMCC26XX.h:408
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:320
Definition: PDMCC26XX.h:377
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:489
Power manager interface for CC26XX.
struct PDMCC26XX_Object PDMCC26XX_Object
PDMCC26XX Object.
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:495
Metadata associated with an array of PCM data.
Definition: PDMCC26XX.h:303
PIN_Handle pinHandle
Definition: PDMCC26XX.h:508
bool PDMCC26XX_stopStream(PDMCC26XX_Handle handle)
Function to stop streaming PDM data.
int taskPriority
Definition: PDMCC26XX.h:356
const PDMCC26XX_Config PDMCC26XX_config[]
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:480
PCM buffer pointed to in a PDMCC26XX_BufferRequest.
Definition: PDMCC26XX.h:310
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 ...
Definition: PDMCC26XX.h:369
bool PDMCC26XX_requestBuffer(PDMCC26XX_Handle handle, PDMCC26XX_BufferRequest *bufferRequest)
Function for requesting buffer.
Semaphore_Struct blockComplete
Definition: PDMCC26XX.h:504
Definition: PDMCC26XX.h:397
void PDMCC26XX_init(PDMCC26XX_Handle handle)
PDM CC26XX initialization.
int32_t * decimationFilter
Definition: PDMCC26XX.h:454
struct PDMCC26XX_Config * PDMCC26XX_Handle
A handle that is returned from a PDMCC26XX_open() call.
Definition: PDMCC26XX.h:362
Definition: PDMCC26XX.h:375
PDMCC26XX_metaData metaData
Definition: PDMCC26XX.h:311
PDMCC26XX_StreamNotification * streamNotification
Definition: PDMCC26XX.h:499
void const * hwAttrs
Definition: PDMCC26XX.h:340
bool micPowerActiveHigh
Definition: PDMCC26XX.h:488
Definition: PDMCC26XX.h:399
bool micPowerActiveHigh
Definition: PDMCC26XX.h:458
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:434
PDMCC26XX Parameters are used to with the PDMCC26XX_open() call. Default values for these parameters ...
Definition: PDMCC26XX.h:448
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:464
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:491
Definition: PDMCC26XX.h:396
Definition: PDMCC26XX.h:395
uint32_t startupDelayWithClockInSamples
Definition: PDMCC26XX.h:461
The PDMCC26XX_Config structure contains a set of pointers used to characterize the PDMCC26XX driver i...
Definition: PDMCC26XX.h:335
uint16_t retBufSizeInBytes
Definition: PDMCC26XX.h:494
Definition: PDMCC26XX.h:394
Definition: PDMCC26XX.h:378
void * object
Definition: PDMCC26XX.h:337
underlying data structure for type PIN_State
Definition: PIN.h:687
void(* PDMCC26XX_CallbackFxn)(PDMCC26XX_Handle handle, PDMCC26XX_StreamNotification *streamNotification)
The definition of a callback function used when buffers are ready.
Definition: PDMCC26XX.h:417
Definition: PDMCC26XX.h:368
uint8_t seqNum
Definition: PDMCC26XX.h:304
PDMCC26XX_Status status
Definition: PDMCC26XX.h:438
PDMCC26XX_MallocFxn mallocFxn
Definition: PDMCC26XX.h:467
int8_t si
Definition: PDMCC26XX.h:305
PIN_Id micPower
Definition: PDMCC26XX.h:354
PDMCC26XX_Status status
Definition: PDMCC26XX.h:409
bool useDefaultFilter
Definition: PDMCC26XX.h:481
bool isOpen
Definition: PDMCC26XX.h:510
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:468
PDMCC26XX Object.
Definition: PDMCC26XX.h:478
PDMCC26XX_Status
Status codes that are set by the PDM driver.
Definition: PDMCC26XX.h:367
int32_t * decimationFilter
Definition: PDMCC26XX.h:484
struct PDMCC26XX_BufferRequest PDMCC26XX_BufferRequest
A PDMCC26XX_BufferRequest data structure is used with PDMCC26XX_requestBuffer().
Definition: PDMCC26XX.h:398
PIN_State pinState
Definition: PDMCC26XX.h:507
bool applyCompression
Definition: PDMCC26XX.h:459
PDMCC26XX_FreeFxn freeFxn
Definition: PDMCC26XX.h:496
uintptr_t custom
Definition: PDMCC26XX.h:469
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:328
PDMCC26XX Hardware attributes.
Definition: PDMCC26XX.h:352
PDMCC26XX_Gain micGain
Definition: PDMCC26XX.h:457
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: PDMCC26XX.h:503
Definition: PDMCC26XX.h:374
bool bStreamStarted
Definition: PDMCC26XX.h:500
PDMCC26XX_CallbackFxn callbackFxn
Definition: PDMCC26XX.h:450
Copyright 2016, Texas Instruments Incorporated