Skip to content

Commit

Permalink
[examples] Enable all protothread as fibers
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Apr 16, 2023
1 parent 6455938 commit 934f34b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
28 changes: 19 additions & 9 deletions examples/nucleo_g071rb/amnb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Thread : public modm::pt::Protothread
Result<uint8_t, uint8_t> res2;

public:
bool inline
update()
bool
run()
{
PT_BEGIN();

Expand All @@ -98,6 +98,22 @@ class Thread : public modm::pt::Protothread
}
thread;

class NodeThread : public modm::pt::Protothread
{
public:
bool run()
{
while (true)
{
node1.update();
node2.update();
node3.update();
}
return false;
}
}
nodeThread;

// ----------------------------------------------------------------------------
int
main()
Expand Down Expand Up @@ -132,13 +148,7 @@ main()
USART4->CR3 = USART_CR3_HDSEL;
USART4->CR1 |= USART_CR1_UE;

while (true)
{
node1.update();
node2.update();
node3.update();
thread.update();
}
modm::fiber::Scheduler::run();

return 0;
}
1 change: 1 addition & 0 deletions examples/nucleo_g071rb/amnb/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<option name="modm:platform:uart:3:buffer.rx">16</option>
<option name="modm:platform:uart:4:buffer.rx">0</option>
<option name="modm:communication:amnb:with_heap">False</option>
<option name="modm:processing:protothread:use_fiber">yes</option>
</options>
<modules>
<module>modm:platform:gpio</module>
Expand Down
7 changes: 2 additions & 5 deletions examples/stm32f3_discovery/accelerometer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ReaderThread : public modm::pt::Protothread
{
public:
bool
update()
run()
{
PT_BEGIN();

Expand Down Expand Up @@ -83,10 +83,7 @@ main()
Board::initialize();
Board::initializeLsm3();

while (true)
{
reader.update();
}
modm::fiber::Scheduler::run();

return 0;
}
1 change: 1 addition & 0 deletions examples/stm32f3_discovery/accelerometer/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<extends>modm:disco-f303vc</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f3_discovery/accelerometer</option>
<option name="modm:processing:protothread:use_fiber">yes</option>
</options>
<modules>
<module>modm:math:filter</module>
Expand Down
7 changes: 2 additions & 5 deletions examples/stm32f3_discovery/rotation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ReaderThread : public modm::pt::Protothread
{
public:
bool
update()
run()
{
PT_BEGIN();

Expand Down Expand Up @@ -97,10 +97,7 @@ main()
Board::initialize();
Board::initializeL3g();

while (true)
{
reader.update();
}
modm::fiber::Scheduler::run();

return 0;
}
1 change: 1 addition & 0 deletions examples/stm32f3_discovery/rotation/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<extends>modm:disco-f303vc</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f3_discovery/rotation</option>
<option name="modm:processing:protothread:use_fiber">yes</option>
</options>
<modules>
<module>modm:math:filter</module>
Expand Down

0 comments on commit 934f34b

Please sign in to comment.