-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathPassthrough.ino
46 lines (40 loc) · 1.09 KB
/
Passthrough.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
/*
* This sketch allows to control nicla from a PC.
* Upload this sketch on an arduino board connected to nicla
* through the eslov connector. Then connect the same arduino board
* to your PC.
* Now you can use the arduino-bhy tool, written in golang,
* to control nicla from either the PC command line or from a web page.
*
* NOTE: if Nicla is used as a Shield on top of a MKR board,
* please use BHY2Host.begin(true, NICLA_AS_SHIELD)
*/
#include "Arduino.h"
#include "Arduino_BHY2Host.h"
#ifdef ARDUINO_ARCH_MBED
#include "USB/PluggableUSBSerial.h"
arduino::USBSerial SerialUSB2(false);
#else
Serial_ SerialUSB2(USBDevice);
#endif
// Set DEBUG to true in order to enable debug print
#define DEBUG false
void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
SerialUSB2.begin(115200);
#if DEBUG
// When the passthrough is enabled, Serial is busy ->
// so it cannot be used for debugging. Serial1 is used instead
BHY2Host.debug(Serial1);
#endif
BHY2Host.begin(true);
}
void loop()
{
if (Serial1.available()) {
SerialUSB2.write(Serial1.read());
}
BHY2Host.update();
}