Skip to content

Commit 0c2a3ad

Browse files
committed
[rtt] Refactor to use the SEGGER RTT implementation
1 parent 175f3e4 commit 0c2a3ad

File tree

15 files changed

+170
-373
lines changed

15 files changed

+170
-373
lines changed

examples/blue_pill_f103/rtt/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
using namespace Board;
1818

19-
Rtt rtt(0);
20-
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > rtt_device(rtt);
19+
modm::IODeviceWrapper< Rtt<0>, modm::IOBuffer::DiscardIfFull > rtt_device;
2120
// Set all four logger streams to use RTT
2221
modm::log::Logger modm::log::debug(rtt_device);
2322
modm::log::Logger modm::log::info(rtt_device);

examples/blue_pill_f103/rtt/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<extends>modm:blue-pill-f103</extends>
33
<options>
44
<option name="modm:build:build.path">../../../build/blue_pill_f103/rtt</option>
5-
<option name="modm:platform:rtt:buffer.rx">16</option>
5+
<option name="modm:rtt:buffer.rx">16</option>
66
</options>
77
<modules>
88
<module>modm:platform:rtt</module>

examples/blue_pill_f103/servo_pwm/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
using namespace Board;
1616

17-
Rtt rtt(0);
18-
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > rtt_device(rtt);
17+
modm::IODeviceWrapper< Rtt<0>, modm::IOBuffer::DiscardIfFull > rtt_device;
1918
// Set all four logger streams to use RTT
2019
modm::log::Logger modm::log::debug(rtt_device);
2120
modm::log::Logger modm::log::info(rtt_device);

examples/blue_pill_f103/servo_pwm/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<extends>modm:blue-pill-f103</extends>
33
<options>
44
<option name="modm:build:build.path">../../../build/blue_pill_f103/servo_pwm</option>
5-
<option name="modm:platform:rtt:buffer.tx">128</option>
5+
<option name="modm:rtt:buffer.tx">128</option>
66
</options>
77
<modules>
88
<module>modm:build:scons</module>

examples/nucleo_f429zi/spi_flash_fatfs/project.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<extends>modm:nucleo-f429zi</extends>
33
<options>
44
<option name="modm:build:build.path">../../../build/nucleo_f429zi/spi_flash_fatfs</option>
5-
<option name="modm:platform:rtt:buffer.tx">4096</option>
65
</options>
76
<modules>
87
<module>modm:build:scons</module>

examples/nucleo_l476rg/rtt/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
using namespace Board;
1717

18-
Rtt rtt(0);
19-
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > rtt_device(rtt);
18+
modm::IODeviceWrapper< Rtt<0>, modm::IOBuffer::DiscardIfFull > rtt_device;
2019
modm::IOStream rtt_stream(rtt_device);
2120

2221
#undef MODM_LOG_LEVEL

examples/nucleo_l476rg/rtt/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<extends>modm:nucleo-l476rg</extends>
33
<options>
44
<option name="modm:build:build.path">../../../build/nucleo_l476rg/rtt</option>
5-
<option name="modm:platform:rtt:buffer.rx">16</option>
5+
<option name="modm:rtt:buffer.rx">16</option>
66
</options>
77
<modules>
88
<module>modm:platform:rtt</module>

examples/stm32f3_discovery/rtt/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
using namespace Board;
1717

18-
Rtt rtt(0);
19-
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > rtt_device(rtt);
18+
modm::IODeviceWrapper< Rtt<0>, modm::IOBuffer::DiscardIfFull > rtt_device;
2019
// Set all four logger streams to use RTT
2120
modm::log::Logger modm::log::debug(rtt_device);
2221
modm::log::Logger modm::log::info(rtt_device);
@@ -85,7 +84,13 @@ main()
8584
{
8685
LedNorth::toggle();
8786

88-
MODM_LOG_INFO << "loop: " << counter++ << modm::endl;
87+
MODM_LOG_INFO << "loop: " << counter << modm::endl;
88+
counter++;
89+
}
90+
// loopback: read from channel 1, output on channel 2
91+
if (uint8_t value; SEGGER_RTT_ReadNoLock(1, &value, 1))
92+
{
93+
SEGGER_RTT_WriteNoLock(2, &value, 1);
8994
}
9095
}
9196

examples/stm32f3_discovery/rtt/project.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<extends>modm:disco-f303vc</extends>
33
<options>
44
<option name="modm:build:build.path">../../../build/stm32f3_discovery/rtt</option>
5-
<option name="modm:platform:rtt:buffer.rx">16</option>
5+
<option name="modm:rtt:buffer.tx">512, 0, 1024</option>
6+
<option name="modm:rtt:buffer.rx">16, 32, 0</option>
67
</options>
78
<modules>
89
<module>modm:platform:rtt</module>

src/modm/platform/uart/rtt/module.lb

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2021, Niklas Hauser
4+
# Copyright (c) 2021, 2025, Niklas Hauser
55
#
66
# This file is part of the modm project.
77
#
@@ -14,29 +14,22 @@ def init(module):
1414
module.name = ":platform:rtt"
1515
module.description = FileReader("module.md")
1616

17+
1718
def prepare(module, options):
1819
if not options[":target"].has_driver("core:cortex-m*"):
1920
return False
2021

21-
module.add_list_option(
22-
NumericOption(name="buffer.tx", description="Transmit buffer sizes",
23-
minimum=0, maximum="64Ki"), default=512)
24-
module.add_list_option(
25-
NumericOption(name="buffer.rx", description="Receive buffer sizes",
26-
minimum=0, maximum="64Ki"), default=0)
22+
module.add_alias(
23+
Alias(name="buffer.tx", destination=":rtt:buffer.tx",
24+
description="Moved to the `modm:rtt` module"))
25+
module.add_alias(
26+
Alias(name="buffer.rx", destination=":rtt:buffer.rx",
27+
description="Moved to the `modm:rtt` module"))
2728

28-
module.depends(":architecture:uart")
29+
module.depends(":architecture:uart", ":architecture:fiber", ":rtt")
2930
return True
3031

31-
def validate(env):
32-
if len(env["buffer.tx"]) != len(env["buffer.rx"]):
33-
raise ValidateException("There must be the same number of TX buffers as RX buffers!")
3432

3533
def build(env):
3634
env.outbasepath = "modm/src/modm/platform/rtt"
37-
env.substitutions = {
38-
"buffer_tx": env["buffer.tx"],
39-
"buffer_rx": env["buffer.rx"],
40-
}
41-
env.template("rtt.hpp.in")
42-
env.template("rtt.cpp.in")
35+
env.copy("rtt.hpp")

0 commit comments

Comments
 (0)