MIC - Microphone Driver (I2S)BSP > Thunderboard Sense BSP
Detailed Description
Driver for the Invensense ICS-43434 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. | |
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 173
of file mic_i2s.c
.
References BOARD_micEnable(), DMADRV_FreeChannel(), DMADRV_StopTransfer(), GPIO_PinModeSet(), gpioModeDisabled, and USART_Reset().
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 239
of file mic_i2s.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 227
of file mic_i2s.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 264
of file mic_i2s.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 93
of file mic_i2s.c
.
References USART_InitSync_TypeDef::autoTx, USART_InitSync_TypeDef::baudrate, BOARD_micEnable(), BOARD_OK, CMU_ClockEnable(), cmuClock_GPIO, DMADRV_AllocateChannel(), DMADRV_Init(), DMADRV_LdmaStartTransfer(), USART_InitI2s_TypeDef::dmaSplit, LDMA_Descriptor_t::dstInc, ECODE_EMDRV_DMADRV_OK, USART_InitSync_TypeDef::enable, USART_InitI2s_TypeDef::format, GPIO_PinModeSet(), gpioModeInput, gpioModePushPull, ldmaCtrlDstIncNone, ldmaCtrlSizeHalf, LDMA_Descriptor_t::size, USART_InitI2s_TypeDef::sync, USART_InitI2s(), USART_INITI2S_DEFAULT, USART_ROUTEPEN_CLKPEN, USART_ROUTEPEN_CSPEN, USART_ROUTEPEN_RXPEN, usartEnable, usartI2sFormatW32D16, and LDMA_Descriptor_t::xfer.
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 305
of file mic_i2s.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 207
of file mic_i2s.c
.