File tree 4 files changed +73
-4
lines changed
examples/BidirectionalCommunication/TestUnoR4
4 files changed +73
-4
lines changed Original file line number Diff line number Diff line change
1
+ #include < TMC2209.h>
2
+
3
+ // This example will not work on Arduino boards without HardwareSerial ports,
4
+ // such as the Uno, Nano, and Mini.
5
+ //
6
+ // See this reference for more details:
7
+ // https://www.arduino.cc/reference/en/language/functions/communication/serial/
8
+
9
+ UART & serial_stream = Serial1;
10
+
11
+ const long SERIAL_BAUD_RATE = 115200 ;
12
+ const int DELAY = 3000 ;
13
+
14
+ // Instantiate TMC2209
15
+ TMC2209 stepper_driver;
16
+
17
+
18
+ void setup ()
19
+ {
20
+ Serial.begin (SERIAL_BAUD_RATE);
21
+
22
+ stepper_driver.setup (serial_stream);
23
+ }
24
+
25
+ void loop ()
26
+ {
27
+ if (stepper_driver.isSetupAndCommunicating ())
28
+ {
29
+ Serial.println (" Stepper driver is setup and communicating!" );
30
+ Serial.println (" Try turning driver power off to see what happens." );
31
+ }
32
+ else if (stepper_driver.isCommunicatingButNotSetup ())
33
+ {
34
+ Serial.println (" Stepper driver is communicating but not setup!" );
35
+ Serial.println (" Running setup again..." );
36
+ stepper_driver.setup (serial_stream);
37
+ }
38
+ else
39
+ {
40
+ Serial.println (" Stepper driver is not communicating!" );
41
+ Serial.println (" Try turning driver power on to see what happens." );
42
+ }
43
+ Serial.println ();
44
+ delay (DELAY);
45
+ }
Original file line number Diff line number Diff line change 1
1
[platformio]
2
- src_dir = examples/UnidirectionalCommunication/MoveAtVelocity
3
- # src_dir = examples/UnidirectionalCommunication/SoftwareSerial
4
- # src_dir = examples/BidirectionalCommunication/TestRP2040
5
- # src_dir = examples/UnidirectionalCommunication/TestRP2040
2
+ ; src_dir = examples/UnidirectionalCommunication/MoveAtVelocity
3
+ ; src_dir = examples/UnidirectionalCommunication/SoftwareSerial
4
+ ; src_dir = examples/BidirectionalCommunication/TestRP2040
5
+ ; src_dir = examples/UnidirectionalCommunication/TestRP2040
6
+ ; src_dir = examples/BidirectionalCommunication/TestUnoR4
6
7
7
8
lib_dir = src
8
9
default_envs = teensy40
@@ -51,6 +52,14 @@ lib_deps =
51
52
SoftwareSerial
52
53
${env.lib_deps}
53
54
55
+ [env:uno_r4_minima]
56
+ platform = renesas-ra
57
+ framework = arduino
58
+ board = uno_r4_minima
59
+ lib_deps =
60
+ SoftwareSerial
61
+ ${env.lib_deps}
62
+
54
63
[env:pico]
55
64
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
56
65
board = rpipico
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ class TMC2209
51
51
SerialAddress serial_address,
52
52
int16_t alternate_rx_pin,
53
53
int16_t alternate_tx_pin);
54
+ #elif defined(ARDUINO_UNOR4_MINIMA)
55
+ void setup (UART & serial,
56
+ long serial_baud_rate,
57
+ SerialAddress serial_address);
54
58
#endif
55
59
56
60
#if SOFTWARE_SERIAL_INCLUDED
Original file line number Diff line number Diff line change @@ -73,6 +73,17 @@ void TMC2209::setup(SerialUART & serial,
73
73
74
74
initialize (serial_baud_rate, serial_address);
75
75
}
76
+ #elif defined(ARDUINO_UNOR4_MINIMA)
77
+ void TMC2209::setup (UART & serial,
78
+ long serial_baud_rate,
79
+ SerialAddress serial_address)
80
+ {
81
+ hardware_serial_ptr_ = &serial;
82
+ hardware_serial_ptr_->end ();
83
+ hardware_serial_ptr_->begin (serial_baud_rate);
84
+
85
+ initialize (serial_baud_rate, serial_address);
86
+ }
76
87
#endif
77
88
78
89
#if SOFTWARE_SERIAL_INCLUDED
You can’t perform that action at this time.
0 commit comments