-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdot44-serialTransfer-UART.ino
101 lines (63 loc) · 1.54 KB
/
dot44-serialTransfer-UART.ino
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Note. These were working and now seem to not be working.
// Need to connect Serial1 TX to Serial1 RX.
#ifdef CORE_CM7
#include "SerialTransfer.h"
SerialTransfer myTransfer;
struct STRUCT {
char z;
float y;
} testStruct;
char arr[6];
void setup()
{
bootM4();
Serial.begin(115200);
Serial1.begin(9600);
myTransfer.begin(Serial1);
}
void loop()
{
if(myTransfer.available())
{
// use this variable to keep track of how many
// bytes we've processed from the receive buffer
uint16_t recSize = 0;
recSize = myTransfer.rxObj(testStruct, recSize);
Serial.print(testStruct.z);
Serial.print(testStruct.y);
Serial.print(" | ");
recSize = myTransfer.rxObj(arr, recSize);
Serial.println(arr);
}
}
#endif
#ifdef CORE_CM4
#include "SerialTransfer.h"
SerialTransfer myTransfer;
struct STRUCT {
char z;
float y;
} testStruct;
char arr[] = "hello";
void setup()
{
// Serial.begin(115200);
Serial1.begin(9600);
myTransfer.begin(Serial1);
testStruct.z = '$';
testStruct.y = 4.5;
}
void loop()
{
// use this variable to keep track of how many
// bytes we're stuffing in the transmit buffer
uint16_t sendSize = 0;
///////////////////////////////////////// Stuff buffer with struct
sendSize = myTransfer.txObj(testStruct, sendSize);
///////////////////////////////////////// Stuff buffer with array
sendSize = myTransfer.txObj(arr, sendSize);
///////////////////////////////////////// Send buffer
myTransfer.sendData(sendSize);
delay(5000);
}
#endif