Browse Source

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

- visual studio intellisense fix
timer1
Youen Toupin 8 years ago
parent
commit
c21e3ea835
  1. 10
      LowLevel.h
  2. 2
      OneWireIO.vcxproj
  3. 7
      OneWireSlave.cpp

10
LowLevel.h

@ -3,6 +3,16 @@
#include <inttypes.h> #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 #if ARDUINO >= 100
#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc #include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc
#else #else

2
OneWireIO.vcxproj

@ -46,7 +46,7 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck> <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> <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> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>

7
OneWireSlave.cpp

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

Loading…
Cancel
Save