- fixed presence pulse timings, according to andrewradke feedback (https://github.com/neuoy/OneWireArduinoSlave/issues/4)

- visual studio intellisense fix
This commit is contained in:
Youen Toupin 2017-04-30 22:45:32 +02:00
parent c819cfdf17
commit c21e3ea835
3 changed files with 15 additions and 4 deletions

View File

@ -3,6 +3,16 @@
#include <inttypes.h>
#ifdef VS_INTELLISENSE
static inline void UserTimer_Init(void)
{
}
static inline void UserTimer_Run(short skipTicks)
{
}
#define UserTimer_Stop() {}
#endif
#if ARDUINO >= 100
#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc
#else

View File

@ -46,7 +46,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>D:\Outils\Arduino\hardware\arduino\avr\cores\arduino;D:\Outils\Arduino\hardware\tools\avr\avr\include;C:\Program Files %28x86%29\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files %28x86%29\Arduino\hardware\tools\avr\avr\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);ARDUINO=160;__AVR__;UBRRH;__AVR_ATmega328__</PreprocessorDefinitions>
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);ARDUINO=160;__AVR__;UBRRH;__AVR_ATmega328__;VS_INTELLISENSE</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -14,8 +14,8 @@ namespace
const unsigned long ResetMinDuration = 480;
const unsigned long ResetMaxDuration = 900;
const unsigned long PresenceWaitDuration = 30;
const unsigned long PresenceDuration = 300;
const unsigned long PresenceWaitDuration = 15;
const unsigned long PresenceDuration = 200;
const unsigned long ReadBitSamplingTime = 25;
@ -415,7 +415,8 @@ void OneWireSlave::waitReset_()
lastReset_ = now;
pin_.detachInterrupt();
setTimerEvent_(PresenceWaitDuration - (micros() - now), &OneWireSlave::beginPresence_);
unsigned long alreadyElapsedTime = micros() - now;
setTimerEvent_(alreadyElapsedTime < PresenceWaitDuration ? PresenceWaitDuration - alreadyElapsedTime : 0, &OneWireSlave::beginPresence_);
endWrite_(true, false);
if (clientReceiveCallback_ != 0)
clientReceiveCallback_(RE_Reset, 0);