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
SerialMultiByte.h
- Committer:
- highfieldsnj
- Date:
- 2019-09-05
- Revision:
- 7:ca2a6fdb24af
- Parent:
- 6:7f87c3ff29ef
File content as of revision 7:ca2a6fdb24af:
#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"
class SerialMultiByte : public RawSerial {
public:
SerialMultiByte(PinName tx, PinName rx);
SerialMultiByte(PinName tx, PinName rx, int baud);
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();
uint8_t* buffer;
uint8_t bufferPoint;
uint8_t receivedBytes;
uint8_t header[2];
uint16_t bufferSize;
uint8_t* data;
};
#endif