Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BufferedSoftSerial 09_PT1000 10_PT1000 11_PT1000 ... more
Buffer.h@0:5e4bca1bd5f7, 2013-05-10 (annotated)
- Committer:
- sam_grove
- Date:
- Fri May 10 18:34:16 2013 +0000
- Revision:
- 0:5e4bca1bd5f7
- Child:
- 1:490224f41c09
First version - implements basic functionality and overloaded members
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sam_grove | 0:5e4bca1bd5f7 | 1 | |
| sam_grove | 0:5e4bca1bd5f7 | 2 | #ifndef BUFFER_H |
| sam_grove | 0:5e4bca1bd5f7 | 3 | #define BUFFER_H |
| sam_grove | 0:5e4bca1bd5f7 | 4 | |
| sam_grove | 0:5e4bca1bd5f7 | 5 | #include <stdint.h> |
| sam_grove | 0:5e4bca1bd5f7 | 6 | #include <string.h> |
| sam_grove | 0:5e4bca1bd5f7 | 7 | |
| sam_grove | 0:5e4bca1bd5f7 | 8 | template <typename T> |
| sam_grove | 0:5e4bca1bd5f7 | 9 | class Buffer |
| sam_grove | 0:5e4bca1bd5f7 | 10 | { |
| sam_grove | 0:5e4bca1bd5f7 | 11 | private: |
| sam_grove | 0:5e4bca1bd5f7 | 12 | T *_buf; |
| sam_grove | 0:5e4bca1bd5f7 | 13 | uint32_t _wloc; |
| sam_grove | 0:5e4bca1bd5f7 | 14 | uint32_t _rloc; |
| sam_grove | 0:5e4bca1bd5f7 | 15 | uint32_t _size; |
| sam_grove | 0:5e4bca1bd5f7 | 16 | |
| sam_grove | 0:5e4bca1bd5f7 | 17 | enum BUFFER_SIZE{SMALL = 0x100, MEDIUM = 0x400, LARGE = 0x1000}; |
| sam_grove | 0:5e4bca1bd5f7 | 18 | |
| sam_grove | 0:5e4bca1bd5f7 | 19 | public: |
| sam_grove | 0:5e4bca1bd5f7 | 20 | Buffer(BUFFER_SIZE size = Buffer::SMALL); |
| sam_grove | 0:5e4bca1bd5f7 | 21 | ~Buffer(); |
| sam_grove | 0:5e4bca1bd5f7 | 22 | |
| sam_grove | 0:5e4bca1bd5f7 | 23 | void put(T data); |
| sam_grove | 0:5e4bca1bd5f7 | 24 | T get(void); |
| sam_grove | 0:5e4bca1bd5f7 | 25 | T *head(void); |
| sam_grove | 0:5e4bca1bd5f7 | 26 | void clear(void); |
| sam_grove | 0:5e4bca1bd5f7 | 27 | Buffer &operator= (T data){put(data);return *this;} |
| sam_grove | 0:5e4bca1bd5f7 | 28 | uint32_t available(void); |
| sam_grove | 0:5e4bca1bd5f7 | 29 | |
| sam_grove | 0:5e4bca1bd5f7 | 30 | }; |
| sam_grove | 0:5e4bca1bd5f7 | 31 | |
| sam_grove | 0:5e4bca1bd5f7 | 32 | #endif |
| sam_grove | 0:5e4bca1bd5f7 | 33 |
