Skip to content

Commit edb1a09

Browse files
committed
[fiber] Add yields to SPI and I2C bitbang drivers
1 parent a7cfe65 commit edb1a09

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/modm/platform/i2c/bitbang/bitbang_i2c_master_impl.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef MODM_SOFTWARE_BITBANG_I2C_HPP
1919
# error "Don't include this file directly, use 'bitbang_i2c_master.hpp' instead!"
2020
#endif
21+
#include <modm/processing/fiber.hpp>
2122

2223
// debugging for serious dummies
2324
/*
@@ -314,6 +315,8 @@ template <class Scl, class Sda>
314315
bool
315316
modm::platform::BitBangI2cMaster<Scl, Sda>::write(uint8_t data)
316317
{
318+
modm::this_fiber::yield();
319+
317320
DEBUG_SW_I2C('W');
318321
// shift through all 8 bits
319322
for(uint_fast8_t i = 0; i < 8; ++i)
@@ -359,6 +362,8 @@ template <class Scl, class Sda>
359362
bool
360363
modm::platform::BitBangI2cMaster<Scl, Sda>::read(uint8_t &data, bool ack)
361364
{
365+
modm::this_fiber::yield();
366+
362367
DEBUG_SW_I2C('R');
363368
// release data line
364369
SDA::set();

src/modm/platform/spi/bitbang/bitbang_spi_master_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef MODM_SOFTWARE_BITBANG_SPI_MASTER_HPP
1818
# error "Don't include this file directly, use 'bitbang_spi_master.hpp' instead!"
1919
#endif
20+
#include <modm/processing/fiber.hpp>
2021

2122
template <typename Sck, typename Mosi, typename Miso>
2223
uint16_t
@@ -84,6 +85,8 @@ template <typename Sck, typename Mosi, typename Miso>
8485
uint8_t
8586
modm::platform::BitBangSpiMaster<Sck, Mosi, Miso>::transferBlocking(uint8_t data)
8687
{
88+
modm::this_fiber::yield();
89+
8790
for (uint_fast8_t ii = 0; ii < 8; ++ii)
8891
{
8992
// CPHA=1, sample on falling edge

0 commit comments

Comments
 (0)