This commit is contained in:
joan 2015-11-30 14:08:19 +00:00
parent 88c63e3e9f
commit 3ba2d7dc8d
2 changed files with 28 additions and 26 deletions

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* pigpio version 41 */ /* pigpio version 42 */
/* include ------------------------------------------------------- */ /* include ------------------------------------------------------- */
@ -5244,7 +5244,7 @@ static void * pthAlertThread(void *x)
uint32_t oldLevel, newLevel, level, reportedLevel; uint32_t oldLevel, newLevel, level, reportedLevel;
uint32_t oldSlot, newSlot; uint32_t oldSlot, newSlot;
uint32_t stick, expected, nowTick, ft; uint32_t stick, expected, nowTick, ft;
int32_t diff; int32_t diff, minDiff, stickInited;
int cycle, pulse; int cycle, pulse;
int emit, seqno, emitted; int emit, seqno, emitted;
uint32_t changes, bits, changedBits, timeoutBits; uint32_t changes, bits, changedBits, timeoutBits;
@ -5279,11 +5279,14 @@ static void * pthAlertThread(void *x)
moreToDo = 0; moreToDo = 0;
stick = systReg[SYST_CLO]; stickInited = 0;
stick = 0;
nextWakeTick = nextWakeTick =
stick + alert_delays[(gpioCfg.internals>>PI_CFG_ALERT_FREQ)&15]; stick + alert_delays[(gpioCfg.internals>>PI_CFG_ALERT_FREQ)&15];
minDiff = gpioCfg.clockMicros / 2;
while (1) while (1)
{ {
newSlot = dmaCurrentSlot(dmaNowAtICB()); newSlot = dmaCurrentSlot(dmaNowAtICB());
@ -5304,8 +5307,6 @@ static void * pthAlertThread(void *x)
{ {
level = myGetLevel(oldSlot++); level = myGetLevel(oldSlot++);
newLevel = (level & monitorBits);
gpioSample[numSamples].tick = stick; gpioSample[numSamples].tick = stick;
gpioSample[numSamples].level = level; gpioSample[numSamples].level = level;
@ -5327,11 +5328,11 @@ static void * pthAlertThread(void *x)
stick = myGetTick(cycle); stick = myGetTick(cycle);
if (stickInited)
{
diff = stick - expected; diff = stick - expected;
if ((diff < -1) || (diff > 1)) if (abs(diff) > minDiff)
{
if (gpioCfg.clockMicros > 1)
{ {
ft = gpioSample[numSamples-PULSE_PER_CYCLE].tick; ft = gpioSample[numSamples-PULSE_PER_CYCLE].tick;
@ -5343,7 +5344,6 @@ static void * pthAlertThread(void *x)
((i*ticks)/PULSE_PER_CYCLE) + ft; ((i*ticks)/PULSE_PER_CYCLE) + ft;
} }
} }
}
diff += (TICKSLOTS/2); diff += (TICKSLOTS/2);
@ -5359,6 +5359,12 @@ static void * pthAlertThread(void *x)
else gpioStats.diffTick[diff]++; else gpioStats.diffTick[diff]++;
} }
else
{
stickInited = 1;
numSamples = 0;
}
}
} }
if (oldSlot == newSlot) moreToDo = 0; else moreToDo = 1; if (oldSlot == newSlot) moreToDo = 0; else moreToDo = 1;
@ -7766,10 +7772,6 @@ void gpioTerminate(void)
{ {
fprintf(stderr, fprintf(stderr,
"\n#####################################################\n"); "\n#####################################################\n");
fprintf(stderr,
"If you didn't request stats please cut & paste the\n"
"following and e-mail to pigpio@abyz.co.uk\n");
fprintf(stderr, "pigpio version=%d internals=%X\n", fprintf(stderr, "pigpio version=%d internals=%X\n",
PIGPIO_VERSION, gpioCfg.internals); PIGPIO_VERSION, gpioCfg.internals);

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#define PIGPIO_VERSION 41 #define PIGPIO_VERSION 42
/*TEXT /*TEXT