Skip to content

Commit

Permalink
[ext] Upgrade the :freertos module to a:FreeRTOS
Browse files Browse the repository at this point in the history
Upgrades to AWS a:FreeRTOS v10 with MIT license and adds a generic
port for all Cortex-M architectures and adds examples.
  • Loading branch information
salkinium committed May 9, 2019
2 parents 5c0d30c + 6768f87 commit 66c0868
Show file tree
Hide file tree
Showing 55 changed files with 724 additions and 13,521 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "ext/mpaland/printf"]
path = ext/mpaland/printf
url = https://github.com/modm-ext/printf.git
[submodule "ext/aws/freertos"]
path = ext/aws/freertos
url = https://github.com/modm-ext/freertos-partial.git
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ make gdb

## Interesting Examples

We have a lot of examples, <!--examplecount-->171<!--/examplecount--> to be
We have a lot of examples, <!--examplecount-->175<!--/examplecount--> to be
exact, but here are some of our favorite examples for our supported development
boards:

Expand Down
80 changes: 80 additions & 0 deletions examples/nucleo_f103rb/rtos/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2014, Georgi Grinshpun
* Copyright (c) 2014, Sascha Schade
* Copyright (c) 2015-2017, 2019 Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <modm/processing/rtos.hpp>

using namespace modm::platform;
using namespace modm::literals;

/**
* This example uses four threads to check if task switching works correctly.
*
* What to expect?
* ---------------
* - All our LEDs blinking at different rates, about 3 to 4 Hz
* - A string at 115200 baud
*
* 0aA!1bB"2cC#3dD$4eE%5fF&6gG'7hH(8iI9)jJ0*aA1!bB2"cC
*
* Each thread prints out a sequence
* 0123456789
* abcdefghij
* ABCDEFGHIJ
* !"#$%&'()*
* respectivly.
*/

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

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

Gpio::toggle();
{
static modm::rtos::Mutex lm;
modm::rtos::MutexGuard m(lm);
MODM_LOG_INFO << char(i + c);
}
i = (i+1)%10;
a *= 3.141f;
}
}
};

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('!');


// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
modm::rtos::Scheduler::schedule();
return 0;
}
10 changes: 10 additions & 0 deletions examples/nucleo_f103rb/rtos/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-f103rb</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f103rb/rtos</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:build:scons</module>
</modules>
</library>
80 changes: 80 additions & 0 deletions examples/nucleo_f303k8/rtos/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2014, Georgi Grinshpun
* Copyright (c) 2014, Sascha Schade
* Copyright (c) 2015-2017, 2019 Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <modm/processing/rtos.hpp>

using namespace modm::platform;
using namespace modm::literals;

/**
* This example uses four threads to check if task switching works correctly.
*
* What to expect?
* ---------------
* - All our LEDs blinking at different rates, about 3 to 4 Hz
* - A string at 115200 baud
*
* 0aA!1bB"2cC#3dD$4eE%5fF&6gG'7hH(8iI9)jJ0*aA1!bB2"cC
*
* Each thread prints out a sequence
* 0123456789
* abcdefghij
* ABCDEFGHIJ
* !"#$%&'()*
* respectivly.
*/

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

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

Gpio::toggle();
{
static modm::rtos::Mutex lm;
modm::rtos::MutexGuard m(lm);
MODM_LOG_INFO << char(i + c);
}
i = (i+1)%10;
a *= 3.141f;
}
}
};

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('!');


// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
modm::rtos::Scheduler::schedule();
return 0;
}
10 changes: 10 additions & 0 deletions examples/nucleo_f303k8/rtos/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-f303k8</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f303k8/rtos</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:build:scons</module>
</modules>
</library>
80 changes: 80 additions & 0 deletions examples/nucleo_f411re/rtos/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2014, Georgi Grinshpun
* Copyright (c) 2014, Sascha Schade
* Copyright (c) 2015-2017, 2019 Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <modm/processing/rtos.hpp>

using namespace modm::platform;
using namespace modm::literals;

/**
* This example uses four threads to check if task switching works correctly.
*
* What to expect?
* ---------------
* - All our LEDs blinking at different rates, about 3 to 4 Hz
* - A string at 115200 baud
*
* 0aA!1bB"2cC#3dD$4eE%5fF&6gG'7hH(8iI9)jJ0*aA1!bB2"cC
*
* Each thread prints out a sequence
* 0123456789
* abcdefghij
* ABCDEFGHIJ
* !"#$%&'()*
* respectivly.
*/

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

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

Gpio::toggle();
{
static modm::rtos::Mutex lm;
modm::rtos::MutexGuard m(lm);
MODM_LOG_INFO << char(i + c);
}
i = (i+1)%10;
a *= 3.141f;
}
}
};

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('!');


// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
modm::rtos::Scheduler::schedule();
return 0;
}
10 changes: 10 additions & 0 deletions examples/nucleo_f411re/rtos/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-f411re</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f411re/rtos</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:build:scons</module>
</modules>
</library>
80 changes: 80 additions & 0 deletions examples/nucleo_g071rb/rtos/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2014, Georgi Grinshpun
* Copyright (c) 2014, Sascha Schade
* Copyright (c) 2015-2017, 2019 Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <modm/processing/rtos.hpp>

using namespace modm::platform;
using namespace modm::literals;

/**
* This example uses four threads to check if task switching works correctly.
*
* What to expect?
* ---------------
* - All our LEDs blinking at different rates, about 3 to 4 Hz
* - A string at 115200 baud
*
* 0aA!1bB"2cC#3dD$4eE%5fF&6gG'7hH(8iI9)jJ0*aA1!bB2"cC
*
* Each thread prints out a sequence
* 0123456789
* abcdefghij
* ABCDEFGHIJ
* !"#$%&'()*
* respectivly.
*/

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

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

Gpio::toggle();
{
static modm::rtos::Mutex lm;
modm::rtos::MutexGuard m(lm);
MODM_LOG_INFO << char(i + c);
}
i = (i+1)%10;
a *= 3.141f;
}
}
};

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('!');


// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
modm::rtos::Scheduler::schedule();
return 0;
}
10 changes: 10 additions & 0 deletions examples/nucleo_g071rb/rtos/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:nucleo-g071rb</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_g071rb/rtos</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:build:scons</module>
</modules>
</library>
Loading

0 comments on commit 66c0868

Please sign in to comment.