Skip to content

Commit

Permalink
[Issue EnviroDIY#79] ESP32- Core panic when using in conjunction with…
Browse files Browse the repository at this point in the history
… the

"preferences" library.
  • Loading branch information
peterj43 committed Jul 13, 2021
1 parent 96feec0 commit f543a69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/SDI12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ String SDI12::addCRCResponse(String &resp) {
}

char * SDI12::addCRCResponse(char *resp) {
char *crcStr[3] = {0};
char crcStr[3] = {0};
uint16_t crc = 0;

for(int i = 0; i < strlen(resp); i++) {
Expand Down Expand Up @@ -979,20 +979,20 @@ takes to either a HIGH vs a LOW, and helps maintain a constant timing.
the ISR is instructed to call handleInterrupt() when they trigger. */

// 7.1 - Passes off responsibility for the interrupt to the active object.
void SDI12::handleInterrupt(){
void USE_INSTRUCTION_RAM SDI12::handleInterrupt(){
if (_activeObject) _activeObject->receiveISR();
}

// 7.2 - Creates a blank slate of bits for an incoming character
void SDI12::startChar()
void USE_INSTRUCTION_RAM SDI12::startChar()
{
rxState = 0; // got a start bit
rxMask = 0x01; // 0b00000001, bit mask, lsb first
rxValue = 0x00; // 0b00000000, RX character to be, a blank slate
} // startChar

// 7.3 - The actual interrupt service routine
void SDI12::receiveISR()
void USE_INSTRUCTION_RAM SDI12::receiveISR()
{

sdi12timer_t thisBitTCNT = READTIME; // time of this data transition (plus ISR latency)
Expand Down
2 changes: 1 addition & 1 deletion src/SDI12_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ SDI12Timer::SDI12Timer(){}

void SDI12Timer::configSDI12TimerPrescale(void) { }
void SDI12Timer::resetSDI12TimerPrescale(void) { }
sdi12timer_t SDI12Timer::SDI12TimerRead(void)
sdi12timer_t USE_INSTRUCTION_RAM SDI12Timer::SDI12TimerRead(void)
{
// Its a one microsecond clock but we want 64uS ticks so divide by 64 i.e. right shift 6
return((sdi12timer_t) (micros() >> 6));
Expand Down
8 changes: 8 additions & 0 deletions src/SDI12_boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ sensors. This library provides a general software solution, without requiring
typedef uint8_t sdi12timer_t;
#endif

#if defined(ESP32)
#define USE_INSTRUCTION_RAM IRAM_ATTR
#elif defined(ESP8266)
#define USE_INSTRUCTION_RAM ICACHE_RAM_ATTR
#else
#define USE_INSTRUCTION_RAM
#endif

class SDI12Timer
{
public:
Expand Down

0 comments on commit f543a69

Please sign in to comment.