Skip to content

Commit

Permalink
[ci] Compile a project with FreeRTOS plus TCP
Browse files Browse the repository at this point in the history
  • Loading branch information
strongly-typed committed Sep 17, 2020
1 parent f1bc637 commit d241fd2
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
82 changes: 82 additions & 0 deletions examples/nucleo_f103rb/freertos_plus_tcp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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;

/**
* This example uses four threads to check if task switching works correctly.
*
* It also check if the FreeRTOS TCP stack can be compiled.
* No TCP functionality in this example (yet).
*
* 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 (true)
{
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;
}
12 changes: 12 additions & 0 deletions examples/nucleo_f103rb/freertos_plus_tcp/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:nucleo-f103rb</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f103rb/freertos_plus_tcp</option>
</options>
<modules>
<module>modm:processing:rtos</module>
<module>modm:freertos:tcp</module>
<module>modm:platform:heap</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit d241fd2

Please sign in to comment.