BiVo EFM32GG12  0.1
An open source foundation foundation for remote monitoring of bird vocalizations.
mic_drv.h
1 /*
2  * mic_drv.h
3  *
4  * Created on: Feb 11, 2021
5  * Author: kevinimlay
6  */
7 
8 #ifndef MODULES_MIC_MIC_DRV_H_
9 #define MODULES_MIC_MIC_DRV_H_
10 
11 #include <stdint.h>
12 #include <stdbool.h>
13 #include "em_chip.h"
14 #include "em_cmu.h"
15 #include "em_emu.h"
16 #include "em_gpio.h"
17 #include "em_ldma.h"
18 #include "em_pdm.h"
19 #include "serial_usb_drv.h"
20 
22 #define MIC_CLK_PORT gpioPortB
23 #define MIC_CLK_PIN 12
24 #define MIC_CLK_PDM_LOC 1
25 #define PDM_CLK_3 3
26 
27 #define MIC_DATA_PORT gpioPortB
28 #define MIC_DATA_PIN 11
29 #define MIC_DATA_PDM_LOC 3
30 #define PDM_DATA0_3 3
31 
32 #define MIC_EN_PORT gpioPortA
33 #define MIC_EN_PIN 8
34 
36 #define BASE_CLK_RATE 19104000 // derived experimentally, may vary on temperature
37 
41 struct MicConfig {
42  int clk_prescalar;
43  int down_sample_rate;
44  int mic_gain;
45  };
46 
51 enum Mic_Ecode {
52  MIC_OK = 0, MIC_NOT_INITIALIZED = 1, MIC_BUSY = 2
53 };
54 
56 void micDriver_init(struct MicConfig config);
57 enum Mic_Ecode startRecording(int16_t *buffer, uint32_t size);
58 enum Mic_Ecode stopRecording(void);
59 bool isRecording(void);
60 
61 #endif /* MODULES_MIC_MIC_DRV_H_ */
void micDriver_init(struct MicConfig config)
Initialize the microphone driver.
Definition: mic_drv.c:149
bool isRecording(void)
Gets the status of recording. Getter for the recording flag. Should be called to check if the recordi...
Definition: mic_drv.c:142
enum Mic_Ecode startRecording(int16_t *buffer, uint32_t size)
Single-shot record an audio segment. Sets pointers for sampling into, sets the recording flag,...
Definition: mic_drv.c:102
enum Mic_Ecode stopRecording(void)
Terminates the recording. Stops recording and resets the recording flag.
Definition: mic_drv.c:124
Definition: mic_drv.h:41