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: Nucleo_NHK_2018_syudo_wheel a_team_R1370 Nucleo_NHK_2018_syudo_wheel 2018NHK_gaku_ver2 ... more
Diff: SerialMultiByte.h
- Revision:
- 0:a6b2ad4005b0
- Child:
- 1:a28d64ee7a79
diff -r 000000000000 -r a6b2ad4005b0 SerialMultiByte.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialMultiByte.h Wed Aug 29 02:49:51 2018 +0000
@@ -0,0 +1,37 @@
+#ifndef SERIAL_MULTI_BYTE_H
+#define SERIAL_MULTI_BYTE_H
+
+#define DEFAULT_BAUD 115200
+#define DEFAULT_FIRST_HEADER 0xAA
+#define DEFAULT_SECOND_HEADER 0xBB
+#define DEFAULT_DATA_SIZE 4
+
+#include "mbed.h"
+#include <vector>
+
+class SerialMultiByte : public RawSerial {
+ public :
+ SerialMultiByte(PinName tx, PinName rx);
+ void setHeaders(uint8_t firstHeader, uint8_t secondHeader);
+ void setHeaders(uint8_t headers[]);
+
+ void startReceive(uint16_t dataSize);
+ void getData(uint8_t data_[]);
+ void sendData(uint8_t data_[], uint16_t length);
+
+ private :
+ void receiveLoop();
+ void receiveByte();
+ void checkData();
+
+ Thread thread;
+
+ uint8_t header[2];
+ std::vector<uint8_t> buffer;
+ uint16_t bufferSize;
+ uint8_t* data;
+
+
+};
+
+#endif
\ No newline at end of file