Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fiber] Add more yields into modm #1205

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/modm/platform/i2c/bitbang/bitbang_i2c_master_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef MODM_SOFTWARE_BITBANG_I2C_HPP
# error "Don't include this file directly, use 'bitbang_i2c_master.hpp' instead!"
#endif
#include <modm/processing/fiber.hpp>

// debugging for serious dummies
/*
Expand Down Expand Up @@ -314,6 +315,8 @@ template <class Scl, class Sda>
bool
modm::platform::BitBangI2cMaster<Scl, Sda>::write(uint8_t data)
{
modm::this_fiber::yield();

DEBUG_SW_I2C('W');
// shift through all 8 bits
for(uint_fast8_t i = 0; i < 8; ++i)
Expand Down Expand Up @@ -359,6 +362,8 @@ template <class Scl, class Sda>
bool
modm::platform::BitBangI2cMaster<Scl, Sda>::read(uint8_t &data, bool ack)
{
modm::this_fiber::yield();

DEBUG_SW_I2C('R');
// release data line
SDA::set();
Expand Down
3 changes: 3 additions & 0 deletions src/modm/platform/spi/bitbang/bitbang_spi_master_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef MODM_SOFTWARE_BITBANG_SPI_MASTER_HPP
# error "Don't include this file directly, use 'bitbang_spi_master.hpp' instead!"
#endif
#include <modm/processing/fiber.hpp>

template <typename Sck, typename Mosi, typename Miso>
uint16_t
Expand Down Expand Up @@ -84,6 +85,8 @@ template <typename Sck, typename Mosi, typename Miso>
uint8_t
modm::platform::BitBangSpiMaster<Sck, Mosi, Miso>::transferBlocking(uint8_t data)
{
modm::this_fiber::yield();

for (uint_fast8_t ii = 0; ii < 8; ++ii)
{
// CPHA=1, sample on falling edge
Expand Down
Loading