Skip to content

Commit f533689

Browse files
committed
[examples] Deduplicate FreeRTOS examples
1 parent 22a36f7 commit f533689

File tree

18 files changed

+40
-594
lines changed

18 files changed

+40
-594
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
- name: Examples STM32F3 Series
142142
if: always()
143143
run: |
144-
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303k8 nucleo_f303re)
144+
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303re)
145145
- name: Examples STM32F7 Series
146146
if: always()
147147
run: |

examples/nucleo_f103rb/rtos/main.cpp renamed to examples/generic/freertos/main.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,24 @@ using namespace modm::platform;
3535
*/
3636

3737
// ----------------------------------------------------------------------------
38-
template <typename Gpio, int SleepTime>
39-
class P: modm::rtos::Thread
38+
class BlinkThread: modm::rtos::Thread
4039
{
4140
char c;
41+
uint8_t position;
42+
uint16_t delay;
4243
uint8_t i = 0;
4344
volatile float a = 10.f;
4445
public:
45-
P(char c): Thread(2,1<<10), c(c) {}
46+
BlinkThread(char c, uint16_t delay, uint8_t position)
47+
: Thread(2, 1024), c{c}, position{position}, delay{delay} {}
4648

4749
void run()
4850
{
49-
Gpio::setOutput();
5051
while (true)
5152
{
52-
sleep(SleepTime * MILLISECONDS);
53+
sleep(delay * MILLISECONDS);
5354

54-
Gpio::toggle();
55+
Board::Leds::write((1ul << position) ^ Board::Leds::read());
5556
{
5657
static modm::rtos::Mutex lm;
5758
modm::rtos::MutexGuard m(lm);
@@ -63,17 +64,21 @@ class P: modm::rtos::Thread
6364
}
6465
};
6566

66-
P< Board::LedD13, 260 > p1('0');
67-
P< Board::LedD13, 260 + 10 > p2('a');
68-
P< Board::LedD13, 260 + 20 > p3('A');
69-
P< Board::LedD13, 260 + 30 > p4('!');
67+
BlinkThread p1('0', 260 , 0);
68+
BlinkThread p2('a', 260 + 10, 1);
69+
BlinkThread p3('A', 260 + 20, 2);
70+
BlinkThread p4('!', 260 + 30, 3);
7071

7172

7273
// ----------------------------------------------------------------------------
7374
int
7475
main()
7576
{
7677
Board::initialize();
78+
Board::Leds::setOutput();
79+
80+
MODM_LOG_INFO << "\n\nReboot: FreeRTOS blink example" << modm::endl;
81+
7782
modm::rtos::Scheduler::schedule();
7883
return 0;
7984
}

examples/generic/freertos/project.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<library>
2+
<!-- Cortex-M0 -->
3+
<extends>modm:nucleo-f072rb</extends>
4+
<!-- Cortex-M0+ -->
5+
<!-- <extends>modm:nucleo-g071rb</extends> -->
6+
<!-- Cortex-M3 -->
7+
<!-- <extends>modm:nucleo-f103rb</extends> -->
8+
<!-- Cortex-M4 -->
9+
<!-- <extends>modm:nucleo-f429zi</extends> -->
10+
<!-- Cortex-M7 -->
11+
<!-- <extends>modm:nucleo-f767zi</extends> -->
12+
<!-- <extends>modm:nucleo-h743zi</extends> -->
13+
<!-- Cortex-M33 -->
14+
<!-- <extends>modm:nucleo-u575zi-q</extends> -->
15+
<!-- <extends>modm:nucleo-l552ze-q</extends> -->
16+
<options>
17+
<option name="modm:build:build.path">../../../build/generic/rtos</option>
18+
</options>
19+
<modules>
20+
<module>modm:processing:rtos</module>
21+
<module>modm:platform:heap</module>
22+
<module>modm:build:scons</module>
23+
</modules>
24+
</library>

examples/nucleo_f103rb/rtos/project.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/nucleo_f303k8/rtos/main.cpp

Lines changed: 0 additions & 79 deletions
This file was deleted.

examples/nucleo_f303k8/rtos/project.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/nucleo_f303re/rtos/main.cpp

Lines changed: 0 additions & 80 deletions
This file was deleted.

examples/nucleo_f303re/rtos/project.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/nucleo_f411re/rtos/main.cpp

Lines changed: 0 additions & 79 deletions
This file was deleted.

examples/nucleo_f411re/rtos/project.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)