-
Notifications
You must be signed in to change notification settings - Fork 0
/
Serial.h
41 lines (32 loc) · 939 Bytes
/
Serial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef SERIAL_H__
#define SERIAL_H__
#include "Common.h"
#define SERIAL_BUFFER_SIZE 16
class SerialLine
{
public:
SerialLine();
void ClearTransmitBuffer();
virtual bool Transmit(unsigned char* buffer, int count);
virtual bool TransmitPartial(unsigned char* buffer, int count);
void RegisterReceiveHandler();
protected:
unsigned char _transmitBuffer[SERIAL_BUFFER_SIZE];
unsigned char _receiveBuffer[SERIAL_BUFFER_SIZE];
int _transmitBufferCount;
int _transmitBufferBit;
int _transmitBufferByte;
int _receiveBufferCount;
int _receiveBufferBit;
int _receiveBufferByte;
virtual void OnTransmitBegin() {;}
virtual void OnReceiveComplete(unsigned char* buffer, int count);
int PopTransmitBit();
int RemainingTransmitBytes();
int TransmitSize();
void ResetTransmitBuffer();
void PushReceiveBit(int);
int ReceivedBytes();
void ResetReceiveBuffer();
};
#endif // SERIAL_H__