RUI3 (RAK Unified Interface 3) - RAK4631
PDM.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2019 Arduino LLC. All right reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  See the GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef _PDM_H_INCLUDED
20 #define _PDM_H_INCLUDED
21 
22 #include <Arduino.h>
23 #include "udrv_pdm.h"
24 
25 // #if !defined(ARDUINO_NRF52_ADAFRUIT)
26 // #error "This library targets only Adafruit NRF52840 boards"
27 // #endif
28 
29 #include "PDMDoubleBuffer.h"
30 
31 class PDMClass
32 {
33 public:
34  PDMClass(int dataPin, int clkPin, int pwrPin);
35  virtual ~PDMClass();
36 
37  void setPins(int dataPin, int clkPin, int pwrPin);
38  int begin(int channels, long sampleRate);
39  void end();
40 
41  virtual int available();
42  virtual int read(void* buffer, size_t size);
43 
44  void onReceive(void(*)(void));
45 
46  void setGain(int gain);
47  void setBufferSize(int bufferSize);
48 
49 // private:
50  void IrqHandler();
51 
52 private:
53  int _dinPin;
54  int _clkPin;
55  int _pwrPin;
56 
57  int _channels;
58 
59  PDMDoubleBuffer _doubleBuffer;
60 
61  void (*_onReceive)(void);
62 };
63 
64 extern PDMClass PDM;
65 
66 #endif
PDMClass PDM
virtual int read(void *buffer, size_t size)
void setBufferSize(int bufferSize)
int begin(int channels, long sampleRate)
void IrqHandler()
void setPins(int dataPin, int clkPin, int pwrPin)
Definition: PDM.h:31
virtual ~PDMClass()
void end()
void onReceive(void(*)(void))
Definition: PDMDoubleBuffer.h:27
PDMClass(int dataPin, int clkPin, int pwrPin)
void setGain(int gain)
virtual int available()