Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
scan/scan.c
- Committer:
- andrewboyson
- Date:
- 2018-12-04
- Revision:
- 40:53666b1a5848
- Parent:
- 39:5b594b1b6a0a
File content as of revision 40:53666b1a5848:
#include <stdint.h>
#include "hrtimer.h"
uint32_t ScanAverage = 0;
uint32_t ScanMinimum = 10000;
uint32_t ScanMaximum = 0;
void ScanMain()
{
//Establish this scan time
static uint32_t scanTimer = 0;
bool firstScan = !scanTimer;
uint32_t elapsed = HrTimerSinceRepetitive(&scanTimer);
if (firstScan) return;
//Average the scan time
if (elapsed > ScanAverage) ScanAverage++;
if (elapsed < ScanAverage) ScanAverage--;
if (elapsed > ScanMaximum) ScanMaximum = elapsed;
if (elapsed < ScanMaximum) ScanMaximum--;
if (elapsed < ScanMinimum) ScanMinimum = elapsed;
}