Skip to content

Commit

Permalink
fix #82, minimal timeout 10 ms for RTOS
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Oct 17, 2024
1 parent 760f89f commit 4ff8350
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
12 changes: 7 additions & 5 deletions ADS1X15.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//
// FILE: ADS1X15.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.5.0
// VERSION: 0.5.1
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15


#include "ADS1X15.h"


#define ADS1015_CONVERSION_DELAY 1
#define ADS1115_CONVERSION_DELAY 8

Expand Down Expand Up @@ -453,20 +454,21 @@ int16_t ADS1X15::_readADC(uint16_t readmode)
{
uint32_t start = millis();
// timeout == { 129, 65, 33, 17, 9, 5, 3, 2 }
// a few ms more than max conversion time.
uint8_t timeOut = (128 >> (_datarate >> 5)) + 1;
// add 10 ms more than max conversion time.
// to prevent premature timeout in RTOS context. See #82
uint8_t timeOut = (128 >> (_datarate >> 5)) + 10;
while (isBusy())
{
yield(); // wait for conversion; yield for ESP.
if ( (millis() - start) > timeOut)
{
return ADS1X15_ERROR_TIMEOUT;
}
yield(); // wait for conversion; yield for ESP.
}
}
else
{
// needed in continuous mode too, otherwise one get old value.
// needed in continuous mode too, otherwise one get an old value.
delay(_conversionDelay);
}
return getValue();
Expand Down
4 changes: 2 additions & 2 deletions ADS1X15.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: ADS1X15.h
// AUTHOR: Rob Tillaart
// VERSION: 0.5.0
// VERSION: 0.5.1
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
Expand All @@ -12,7 +12,7 @@
#include "Arduino.h"
#include "Wire.h"

#define ADS1X15_LIB_VERSION (F("0.5.0"))
#define ADS1X15_LIB_VERSION (F("0.5.1"))

// allow compile time default address
// address in { 0x48, 0x49, 0x4A, 0x4B }, no test...
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.5.1] - 2024-10-17
- fix #82, minimal timeout 10 ms for RTOS

## [0.5.0] - 2024-08-20
- Fix #80, setComparatorPolarity() and setComparatorLatch() inverting.
- add test example to test parameters.
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ADS1X15"
},
"version": "0.5.0",
"version": "0.5.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ADS1X15
version=0.5.0
version=0.5.1
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for ADS1015 - I2C 12 bit ADC and ADS1115 I2C 16 bit ADC
Expand Down

0 comments on commit 4ff8350

Please sign in to comment.