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.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
CircularBuf.h@14:4637a9f02919, 2018-04-20 (annotated)
- Committer:
- Nurchu
- Date:
- Fri Apr 20 15:15:59 2018 +0000
- Revision:
- 14:4637a9f02919
- Child:
- 16:d0d3bb2fc3ce
Added skeleton code for CircularBuf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nurchu | 14:4637a9f02919 | 1 | template <T> |
Nurchu | 14:4637a9f02919 | 2 | class CircularBuff { |
Nurchu | 14:4637a9f02919 | 3 | public: |
Nurchu | 14:4637a9f02919 | 4 | CircularBuff(unsigned int size); |
Nurchu | 14:4637a9f02919 | 5 | ~CircularBuff(); |
Nurchu | 14:4637a9f02919 | 6 | |
Nurchu | 14:4637a9f02919 | 7 | // Pushes data onto the buffer |
Nurchu | 14:4637a9f02919 | 8 | // Arguement: |
Nurchu | 14:4637a9f02919 | 9 | // data, The array of data to push |
Nurchu | 14:4637a9f02919 | 10 | // size, The amount of data in the array |
Nurchu | 14:4637a9f02919 | 11 | void push(T* data, unsigned int size); |
Nurchu | 14:4637a9f02919 | 12 | |
Nurchu | 14:4637a9f02919 | 13 | |
Nurchu | 14:4637a9f02919 | 14 | // Pops data from the buffer |
Nurchu | 14:4637a9f02919 | 15 | // Arguement: |
Nurchu | 14:4637a9f02919 | 16 | // data, The array of data popped |
Nurchu | 14:4637a9f02919 | 17 | // size, The amount of data to pop |
Nurchu | 14:4637a9f02919 | 18 | // Return: |
Nurchu | 14:4637a9f02919 | 19 | // Amount of data actually popped |
Nurchu | 14:4637a9f02919 | 20 | unsigned int pop(T* data, unsigned int size); |
Nurchu | 14:4637a9f02919 | 21 | |
Nurchu | 14:4637a9f02919 | 22 | // Amount of data in the buffer |
Nurchu | 14:4637a9f02919 | 23 | unsigned int size(); |
Nurchu | 14:4637a9f02919 | 24 | |
Nurchu | 14:4637a9f02919 | 25 | // Clears the buffer completely |
Nurchu | 14:4637a9f02919 | 26 | void clear(); |
Nurchu | 14:4637a9f02919 | 27 | |
Nurchu | 14:4637a9f02919 | 28 | private: |
Nurchu | 14:4637a9f02919 | 29 | T* _data; |
Nurchu | 14:4637a9f02919 | 30 | unsigned int _size; |
Nurchu | 14:4637a9f02919 | 31 | unsigned int _start; |
Nurchu | 14:4637a9f02919 | 32 | unsigned int _end; |
Nurchu | 14:4637a9f02919 | 33 | }; |