RUI3 (RAK Unified Interface 3) - RAK4631
PDMDoubleBuffer.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2016 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_DOUBLE_BUFFER_H_INCLUDED
20 #define _PDM_DOUBLE_BUFFER_H_INCLUDED
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #define DEFAULT_PDM_BUFFER_SIZE 512
26 
28 {
29 public:
31  virtual ~PDMDoubleBuffer();
32 
33  void setSize(int size);
34 
35  void reset();
36 
37  size_t availableForWrite();
38  size_t write(const void *buffer, size_t size);
39  size_t read(void *buffer, size_t size);
40  size_t peek(void *buffer, size_t size);
41  void* data();
42  size_t available();
43  void swap(int length = 0);
44 
45 private:
46  uint8_t* _buffer[2];
47  int _size;
48  volatile int _length[2];
49  volatile int _readOffset[2];
50  volatile int _index;
51 };
52 
53 #endif
size_t peek(void *buffer, size_t size)
size_t read(void *buffer, size_t size)
void swap(int length=0)
size_t availableForWrite()
uint16_t length
Definition: RAKProtocol.h:71
void setSize(int size)
virtual ~PDMDoubleBuffer()
Definition: PDMDoubleBuffer.h:27
size_t write(const void *buffer, size_t size)
size_t available()