forked from hjd1964/OnStep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerial.h
60 lines (55 loc) · 1.42 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// -----------------------------------------------------------------------------------
// Communication routines for Serial0, Serial1, and bit banged SPI
class pserial {
public:
void begin(unsigned long baud);
boolean available();
char read();
void print(const char data[]);
void putch(char c);
void putl(long l);
void putf(double f);
void puts(const char data[]);
boolean transmit();
#if defined(__AVR_ATmega2560__)
volatile char _recv_buffer[256] = "";
volatile byte _recv_tail = 0;
private:
byte _recv_head = 0;
char _xmit_buffer[50] = "";
byte _xmit_index = 0;
#endif
};
class pserial1 {
public:
void begin(unsigned long baud);
boolean available();
char read();
void print(const char data[]);
void putch(char c);
void putf(double f);
void putl(long l);
void puts(const char data[]);
boolean transmit();
#if defined(__AVR_ATmega2560__)
volatile char _recv_buffer[256] = "";
volatile byte _recv_tail = 0;
private:
byte _recv_head = 0;
char _xmit_buffer[50] = "";
byte _xmit_index = 0;
#endif
};
class bbspi {
public:
void begin(int cs, int sck, int miso, int mosi);
void pause();
void end();
uint8_t transfer(uint8_t data_out);
uint32_t transfer32(uint32_t data_out);
private:
int _cs = 0;
int _sck = 0;
int _miso = 0;
int _mosi = 0;
};