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 TrapezoidControl QEI
Diff: CommonLibraries/RingBuffer/RingBuffer.h
- Revision:
- 0:669ef71cba68
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommonLibraries/RingBuffer/RingBuffer.h Sat Sep 08 06:05:22 2018 +0000
@@ -0,0 +1,49 @@
+/*
+ * RingBuffer.h
+ *
+ * Created: 2016/08/10 12:15:08
+ * Author: masuk
+ */
+
+
+#ifndef RINGBUFFER_H_
+#define RINGBUFFER_H_
+
+#include <stdint.h>
+
+namespace RINGBUFFER
+{
+ //循環型バッファ 使用するバッファの配列と大きさを指定してください
+ class RingBuffer
+ {
+ struct
+ {
+ char *data;
+ int size;
+ uint8_t top;
+ uint8_t bottom;
+ uint8_t length;
+ bool fullup;
+ }Buffer;
+
+ public:
+ RingBuffer(char *bufPtr, int size);
+
+ //バッファにデータを追加
+ void PutData(char data, bool ASCIItoNum = false);
+ void PutData(char *data, int length);
+ void PutData(const char *str);
+
+ //バッファからデータを1byte読み出し
+ char GetData();
+
+ //バッファが飽和しているか確認
+ bool IsFullup();
+ //バッファにデータが存在するか確認
+ bool InAnyData();
+ };
+}
+
+
+
+#endif /* RINGBUFFER_H_ */