Skip to content

Commit

Permalink
[example] Nucleo-F767ZI protothread blink
Browse files Browse the repository at this point in the history
  • Loading branch information
rleh committed Jun 8, 2021
1 parent b61acef commit 9554d61
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
64 changes: 64 additions & 0 deletions examples/nucleo_f767zi/protothread_blink/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2014, Sascha Schade
* Copyright (c) 2014-2017, 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/timer.hpp>
#include <modm/processing/protothread.hpp>

using Led = Board::LedBlue;

class BlinkingLight : public modm::pt::Protothread
{
public:
bool
run()
{
PT_BEGIN();

// set everything up
Led::setOutput();
Led::set();

while (true)
{
timeout.restart(100ms);
Led::set();
PT_WAIT_UNTIL(timeout.isExpired());

timeout.restart(200ms);
Led::reset();
PT_WAIT_UNTIL(timeout.isExpired());
}

PT_END();
}

private:
modm::ShortTimeout timeout;
};

BlinkingLight light;


int
main()
{
Board::initialize();

while (true)
{
light.run();
}

return 0;
}
11 changes: 11 additions & 0 deletions examples/nucleo_f767zi/protothread_blink/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:nucleo-f767zi</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f767zi/protothread_blink</option>
</options>
<modules>
<module>modm:processing:protothread</module>
<module>modm:processing:timer</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit 9554d61

Please sign in to comment.