Skip to content

Commit

Permalink
[examples] Deduplicate FreeRTOS examples
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 7, 2024
1 parent 22a36f7 commit f533689
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 594 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Examples STM32F3 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303k8 nucleo_f303re)
(cd examples && ../tools/scripts/examples_compile.py stm32f3_discovery nucleo_f303re)
- name: Examples STM32F7 Series
if: always()
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,24 @@ using namespace modm::platform;
*/

// ----------------------------------------------------------------------------
template <typename Gpio, int SleepTime>
class P: modm::rtos::Thread
class BlinkThread: modm::rtos::Thread
{
char c;
uint8_t position;
uint16_t delay;
uint8_t i = 0;
volatile float a = 10.f;
public:
P(char c): Thread(2,1<<10), c(c) {}
BlinkThread(char c, uint16_t delay, uint8_t position)
: Thread(2, 1024), c{c}, position{position}, delay{delay} {}

void run()
{
Gpio::setOutput();
while (true)
{
sleep(SleepTime * MILLISECONDS);
sleep(delay * MILLISECONDS);

Gpio::toggle();
Board::Leds::write((1ul << position) ^ Board::Leds::read());
{
static modm::rtos::Mutex lm;
modm::rtos::MutexGuard m(lm);
Expand All @@ -63,17 +64,21 @@ class P: modm::rtos::Thread
}
};

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


// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
Board::Leds::setOutput();

MODM_LOG_INFO << "\n\nReboot: FreeRTOS blink example" << modm::endl;

modm::rtos::Scheduler::schedule();
return 0;
}
24 changes: 24 additions & 0 deletions examples/generic/freertos/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<library>
<!-- Cortex-M0 -->
<extends>modm:nucleo-f072rb</extends>
<!-- Cortex-M0+ -->
<!-- <extends>modm:nucleo-g071rb</extends> -->
<!-- Cortex-M3 -->
<!-- <extends>modm:nucleo-f103rb</extends> -->
<!-- Cortex-M4 -->
<!-- <extends>modm:nucleo-f429zi</extends> -->
<!-- Cortex-M7 -->
<!-- <extends>modm:nucleo-f767zi</extends> -->
<!-- <extends>modm:nucleo-h743zi</extends> -->
<!-- Cortex-M33 -->
<!-- <extends>modm:nucleo-u575zi-q</extends> -->
<!-- <extends>modm:nucleo-l552ze-q</extends> -->
<options>
<option name="modm:build:build.path">../../../build/generic/rtos</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:platform:heap</module>
<module>modm:build:scons</module>
</modules>
</library>
11 changes: 0 additions & 11 deletions examples/nucleo_f103rb/rtos/project.xml

This file was deleted.

79 changes: 0 additions & 79 deletions examples/nucleo_f303k8/rtos/main.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions examples/nucleo_f303k8/rtos/project.xml

This file was deleted.

80 changes: 0 additions & 80 deletions examples/nucleo_f303re/rtos/main.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions examples/nucleo_f303re/rtos/project.xml

This file was deleted.

79 changes: 0 additions & 79 deletions examples/nucleo_f411re/rtos/main.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions examples/nucleo_f411re/rtos/project.xml

This file was deleted.

Loading

0 comments on commit f533689

Please sign in to comment.