Skip to content

Commit

Permalink
Fix wait_Miso defines in cc1101.h (#213)
Browse files Browse the repository at this point in the history
Static variables are only initialized once so the implementation only
worked for a total of 255 iterations.
After that, functions like cmdStrobe(), readReg() or
writeReg() return immediately if the MISO pin is high.

The variable miso_count is now out of while's scope and therefore no
longer needs to be static.
  • Loading branch information
devzero84 authored Jun 13, 2021
1 parent 00089bb commit c6e7fba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cc1101.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ namespace cc1101 {
#endif
#endif

#define wait_Miso() while(isHigh(misoPin) ) { static uint8_t miso_count=255;delay(1); if(miso_count==0) return; miso_count--; } // wait until SPI MISO line goes low
#define wait_Miso_rf() while(isHigh(misoPin) ) { static uint8_t miso_count=255;delay(1); if(miso_count==0) return false; miso_count--; } // wait until SPI MISO line goes low
#define wait_Miso() { uint8_t miso_count = 255; while(isHigh(misoPin)) { delay(1); if(miso_count == 0) return ; miso_count--; } } // wait until SPI MISO line goes low
#define wait_Miso_rf() { uint8_t miso_count = 255; while(isHigh(misoPin)) { delay(1); if(miso_count == 0) return false; miso_count--; } } // wait until SPI MISO line goes low

#ifdef ARDUINO_MAPLEMINI_F103CB
#define cc1101_Select() digitalLow(cc1101::radioCsPin[radionr]) // select (SPI) CC1101 | variant from array, Circuit board for 4 cc110x
Expand Down

0 comments on commit c6e7fba

Please sign in to comment.