Skip to content

Commit 9f80edb

Browse files
authored
Add DVL serial passthrough for Teensy 4.0 #181
Add DVL serial passthrough for Teensy 4.0
2 parents 3e44e1d + ea4cfb0 commit 9f80edb

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

pio_workspace/include/dvl_main.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef DVL_H
2+
3+
#include <Arduino.h>
4+
5+
void dvl_setup();
6+
void dvl_loop();
7+
8+
#endif

pio_workspace/platformio.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ lib_deps =
4343
PaulStoffregen/XPT2046_Touchscreen
4444
https://github.com/bluerobotics/BlueRobotics_MS5837_Library
4545

46+
[env:dvl]
47+
platform = teensy
48+
board = teensy40
49+
framework = arduino
50+
build_flags =
51+
-D DVL_H
52+
${env.build_flags}
53+
#upload_protocol = teensy-cli
54+
upload_port = /dev/dvl
55+
4656
[env:power]
4757
platform = teensy
4858
board = teensy40

pio_workspace/src/dvl_main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifdef DVL_H
2+
3+
#include "dvl_main.h"
4+
5+
// RX2 -> Pin 7 (receives data from DVL)
6+
// TX2 -> Pin 8 (sends data to DVL)
7+
8+
void dvl_setup(){
9+
Serial.begin(115200);
10+
Serial2.begin(115200);
11+
12+
pinMode(LED_BUILTIN, OUTPUT);
13+
digitalWrite(LED_BUILTIN, HIGH);
14+
}
15+
16+
void dvl_loop(){
17+
// Forward data from DVL (Serial2) to Jetson (Serial)
18+
if (Serial2.available()) {
19+
int inByte = Serial2.read();
20+
Serial.write(inByte);
21+
}
22+
23+
// Forward data from Jetson (Serial) to DVL (Serial2)
24+
if (Serial.available()) {
25+
int inByte = Serial.read();
26+
Serial2.write(inByte);
27+
}
28+
}
29+
30+
#endif

pio_workspace/src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "actuator_main.h"
55
#elif DISPLAY_H
66
#include "display_main.h"
7+
#elif DVL_H
8+
#include "dvl_main.h"
79
#elif POWER_H
810
#include "power_main.h"
911
#elif POWER_ROS1_H
@@ -15,6 +17,8 @@ void setup() {
1517
actuator_setup();
1618
#elif DISPLAY_H
1719
display_setup();
20+
#elif DVL_H
21+
dvl_setup();
1822
#elif POWER_H
1923
power_setup();
2024
#elif POWER_ROS1_H
@@ -27,6 +31,8 @@ void loop() {
2731
actuator_loop();
2832
#elif DISPLAY_H
2933
display_loop();
34+
#elif DVL_H
35+
dvl_loop();
3036
#elif POWER_H
3137
power_loop();
3238
#elif POWER_ROS1_H

0 commit comments

Comments
 (0)