friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/SharedBuffer.h
Go to the documentation of this file.
1 // EtherDune Shared circular buffer class
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: Implements a "shared" circular buffer using spare ENC28J60 memory
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
153 #ifndef SHARED_BUFFER_H
154 #define SHARED_BUFFER_H
155 
156 #include "List.h"
157 
159 {
160 
161  static uint16_t head;
162  static uint16_t usedSpace;
163  static List bufferList;
164 
165  uint16_t nextRead;
166  uint16_t lastWritten;
167 
168  static uint16_t append(uint16_t len, const byte* data);
169  static uint16_t writeAt(uint16_t index, uint16_t len, const byte* data);
170  static uint16_t readAt(uint16_t index, uint16_t len, byte* data );
171 
172 
173 public:
174 
175  uint16_t write(uint16_t len, const byte* data);
176  uint16_t release();
177 
178  SharedBuffer();
179  ~SharedBuffer();
180 
181  void flush();
182  bool isEmpty();
183  uint16_t fillTxBuffer(uint16_t dstOffset, uint16_t& checksum, uint16_t count=0xFFFF);
184 
185 
186 
187 };
188 
189 
190 
191 
192 
193 
194 
195 #endif
uint16_t release()
Releases one fragment of data
Base list item class.
Definition: List.h:29
Basic linked list class.
Definition: List.h:43
void flush()
Releases all data in this buffer, freeing up space.
uint16_t write(uint16_t len, const byte *data)
Writes a fragment to the shared buffer
Implements a "shared" circular buffer using spare ENC28J60 memory.
Definition: SharedBuffer.h:158
bool isEmpty()
Determines whether this buffer is empty
uint16_t fillTxBuffer(uint16_t dstOffset, uint16_t &checksum, uint16_t count=0xFFFF)
Copies up to count fragments to the transmit buffer via DMA, concatenating them starting at given off...