aa
Dependencies: mbed TrapezoidControl QEI
CommonLibraries/RingBuffer/RingBuffer.h@44:c208a908583c, 2019-10-03 (annotated)
- Committer:
- yabahiro
- Date:
- Thu Oct 03 06:22:38 2019 +0000
- Revision:
- 44:c208a908583c
- Parent:
- 0:669ef71cba68
aa;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:669ef71cba68 | 1 | /* |
t_yamamoto | 0:669ef71cba68 | 2 | * RingBuffer.h |
t_yamamoto | 0:669ef71cba68 | 3 | * |
t_yamamoto | 0:669ef71cba68 | 4 | * Created: 2016/08/10 12:15:08 |
t_yamamoto | 0:669ef71cba68 | 5 | * Author: masuk |
t_yamamoto | 0:669ef71cba68 | 6 | */ |
t_yamamoto | 0:669ef71cba68 | 7 | |
t_yamamoto | 0:669ef71cba68 | 8 | |
t_yamamoto | 0:669ef71cba68 | 9 | #ifndef RINGBUFFER_H_ |
t_yamamoto | 0:669ef71cba68 | 10 | #define RINGBUFFER_H_ |
t_yamamoto | 0:669ef71cba68 | 11 | |
t_yamamoto | 0:669ef71cba68 | 12 | #include <stdint.h> |
t_yamamoto | 0:669ef71cba68 | 13 | |
t_yamamoto | 0:669ef71cba68 | 14 | namespace RINGBUFFER |
t_yamamoto | 0:669ef71cba68 | 15 | { |
t_yamamoto | 0:669ef71cba68 | 16 | //循環型バッファ 使用するバッファの配列と大きさを指定してください |
t_yamamoto | 0:669ef71cba68 | 17 | class RingBuffer |
t_yamamoto | 0:669ef71cba68 | 18 | { |
t_yamamoto | 0:669ef71cba68 | 19 | struct |
t_yamamoto | 0:669ef71cba68 | 20 | { |
t_yamamoto | 0:669ef71cba68 | 21 | char *data; |
t_yamamoto | 0:669ef71cba68 | 22 | int size; |
t_yamamoto | 0:669ef71cba68 | 23 | uint8_t top; |
t_yamamoto | 0:669ef71cba68 | 24 | uint8_t bottom; |
t_yamamoto | 0:669ef71cba68 | 25 | uint8_t length; |
t_yamamoto | 0:669ef71cba68 | 26 | bool fullup; |
t_yamamoto | 0:669ef71cba68 | 27 | }Buffer; |
t_yamamoto | 0:669ef71cba68 | 28 | |
t_yamamoto | 0:669ef71cba68 | 29 | public: |
t_yamamoto | 0:669ef71cba68 | 30 | RingBuffer(char *bufPtr, int size); |
t_yamamoto | 0:669ef71cba68 | 31 | |
t_yamamoto | 0:669ef71cba68 | 32 | //バッファにデータを追加 |
t_yamamoto | 0:669ef71cba68 | 33 | void PutData(char data, bool ASCIItoNum = false); |
t_yamamoto | 0:669ef71cba68 | 34 | void PutData(char *data, int length); |
t_yamamoto | 0:669ef71cba68 | 35 | void PutData(const char *str); |
t_yamamoto | 0:669ef71cba68 | 36 | |
t_yamamoto | 0:669ef71cba68 | 37 | //バッファからデータを1byte読み出し |
t_yamamoto | 0:669ef71cba68 | 38 | char GetData(); |
t_yamamoto | 0:669ef71cba68 | 39 | |
t_yamamoto | 0:669ef71cba68 | 40 | //バッファが飽和しているか確認 |
t_yamamoto | 0:669ef71cba68 | 41 | bool IsFullup(); |
t_yamamoto | 0:669ef71cba68 | 42 | //バッファにデータが存在するか確認 |
t_yamamoto | 0:669ef71cba68 | 43 | bool InAnyData(); |
t_yamamoto | 0:669ef71cba68 | 44 | }; |
t_yamamoto | 0:669ef71cba68 | 45 | } |
t_yamamoto | 0:669ef71cba68 | 46 | |
t_yamamoto | 0:669ef71cba68 | 47 | |
t_yamamoto | 0:669ef71cba68 | 48 | |
t_yamamoto | 0:669ef71cba68 | 49 | #endif /* RINGBUFFER_H_ */ |