MIC - Microphone Driver (ADC)BSP > Thunderboard Sense BSP
Detailed Description
Driver for the Knowles SPV1840LR5H-B MEMS Microphone.
Functions |
|
void | MIC_deInit (void) |
Powers down the MEMS microphone stops the ADC and frees up the DMA channel.
|
|
float | MIC_getMean (void) |
Calculates the average value of the samples in the buffer.
|
|
uint16_t * | MIC_getSampleBuffer (void) |
Gets the sample buffer.
|
|
float | MIC_getSoundLevel (float *var) |
Calculates the sound level.
|
|
uint32_t | MIC_init (uint32_t fs, uint16_t *buffer, size_t len) |
Initializes MEMS microphone and sets up the DMA, ADC and clocking.
|
|
bool | MIC_isBusy (void) |
Checks if the microphone is in use.
|
|
void | MIC_start (uint32_t nSamples) |
Starts taking samples using DMA from the microphone.
|
|
Error Codes |
|
#define | MIC_OK 0 |
Macro Definition Documentation
#define MIC_OK 0 |
No errors
Definition at line
43
of file
mic.h
.
Function Documentation
void MIC_deInit | ( | void |
|
) |
Powers down the MEMS microphone stops the ADC and frees up the DMA channel.
- Returns
- None
Definition at line
174
of file
mic.c
.
References BOARD_micEnable() , and DMADRV_FreeChannel() .
float MIC_getMean | ( | void |
|
) |
Calculates the average value of the samples in the buffer.
- Returns
- The mean value of the samples in the buffer
Definition at line
247
of file
mic.c
.
Referenced by MIC_getSoundLevel() .
uint16_t * MIC_getSampleBuffer | ( | void |
|
) |
Gets the sample buffer.
- Returns
- Returns a pointer to the sample buffer
Definition at line
235
of file
mic.c
.
float MIC_getSoundLevel | ( | float * |
var
|
) |
Calculates the sound level.
- Parameters
-
[out] var
The variance of the samples
- Returns
- The sound level in dB
Definition at line
272
of file
mic.c
.
References MIC_getMean() .
uint32_t MIC_init | ( | uint32_t |
fs,
|
uint16_t * |
buffer,
|
||
size_t |
len
|
||
) |
Initializes MEMS microphone and sets up the DMA, ADC and clocking.
- Parameters
-
[in] fs
The desired sample rate in Hz [in] buffer
Pointer to the sample buffer to store the ADC data [in] len
The size of the sample buffer
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
78
of file
mic.c
.
References ADC0 , ADC_Init() , ADC_INIT_DEFAULT , ADC_InitScan() , ADC_INITSCAN_DEFAULT , ADC_PrescaleCalc() , ADC_TimebaseCalc() , adcInit() , adcRef2V5 , BOARD_micEnable() , CMU , CMU_ClockEnable() , CMU_ClockFreqGet() , CMU_ClockSelectSet() , cmuClock_ADC0 , cmuClock_AUX , cmuClock_LFA , cmuClock_PRS , cmuSelect_LFXO , LETIMER_Init_TypeDef::comp0Top , DMADRV_AllocateChannel() , DMADRV_Init() , ECODE_EMDRV_DMADRV_OK , LETIMER_Init_TypeDef::enable , LETIMER_CompareSet() , LETIMER_Init() , LETIMER_INIT_DEFAULT , LETIMER_RepeatSet() , letimerUFOAPulse , ADC_Init_TypeDef::prescale , ADC_InitScan_TypeDef::prsEnable , ADC_InitScan_TypeDef::prsSel , ADC_InitScan_TypeDef::reference , ADC_Init_TypeDef::timebase , and LETIMER_Init_TypeDef::ufoa0 .
bool MIC_isBusy | ( | void |
|
) |
Checks if the microphone is in use.
- Returns
- Returns true if the DMA is busy taking microphone samples
Definition at line
311
of file
mic.c
.
void MIC_start | ( | uint32_t |
nSamples
|
) |
Starts taking samples using DMA from the microphone.
- Parameters
-
[in] nSamples
The number of the samples to take
- Returns
- None
Definition at line
200
of file
mic.c
.
References ADC0 , DMADRV_PeripheralMemory() , dmadrvDataSize2 , and dmadrvPeripheralSignal_ADC0_SCAN .