Detected Iteration Above Threshold in Unit Time. Check if Frequency (iteration count in Unit time) above Threshold. CATION. max interval is 0xfff0: 65,520ms. max iter threshold is 0xffff. (threfore, using 131KB with span[0xffff].)

Dependencies:   myTimer

Committer:
AkinoriHashimoto
Date:
Fri Oct 09 07:39:13 2015 +0000
Revision:
1:6ab4e8504d60
Parent:
0:7672973d6bed
1st publish.; test term.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AkinoriHashimoto 0:7672973d6bed 1 #pragma once
AkinoriHashimoto 0:7672973d6bed 2
AkinoriHashimoto 0:7672973d6bed 3 /** Detected Iteration Above Threshold in Unit Time.
AkinoriHashimoto 0:7672973d6bed 4 * Check if Frequency (iteration count in Unit time) above Threshold.
AkinoriHashimoto 0:7672973d6bed 5 *
AkinoriHashimoto 0:7672973d6bed 6 * CATION. max interval is 0xfff0: 65,520ms.
AkinoriHashimoto 0:7672973d6bed 7 * max iter threshold is 0xffff.
AkinoriHashimoto 0:7672973d6bed 8 * (threfore, using 131KB with span[0xffff].)
AkinoriHashimoto 0:7672973d6bed 9 */
AkinoriHashimoto 0:7672973d6bed 10 /** Sample code
AkinoriHashimoto 0:7672973d6bed 11 #include "mbed.h"
AkinoriHashimoto 0:7672973d6bed 12 #include "DetectFreqAboveTH.h"
AkinoriHashimoto 0:7672973d6bed 13
AkinoriHashimoto 0:7672973d6bed 14 DigitalOut led1(LED1);
AkinoriHashimoto 0:7672973d6bed 15 DigitalOut led4(LED4);
AkinoriHashimoto 0:7672973d6bed 16
AkinoriHashimoto 0:7672973d6bed 17 DetectFreqAboveTH chkErrIter(5000, 100);
AkinoriHashimoto 0:7672973d6bed 18
AkinoriHashimoto 0:7672973d6bed 19 int main()
AkinoriHashimoto 0:7672973d6bed 20 {
AkinoriHashimoto 0:7672973d6bed 21 while(1) {
AkinoriHashimoto 0:7672973d6bed 22 led1= !led1;
AkinoriHashimoto 0:7672973d6bed 23 if(chkErrIter.chkAbove()) {
AkinoriHashimoto 0:7672973d6bed 24 led4= !led4;
AkinoriHashimoto 0:7672973d6bed 25 wait_ms(5100);
AkinoriHashimoto 0:7672973d6bed 26 }
AkinoriHashimoto 0:7672973d6bed 27 wait_ms(20);
AkinoriHashimoto 0:7672973d6bed 28 }
AkinoriHashimoto 0:7672973d6bed 29 }
AkinoriHashimoto 0:7672973d6bed 30 */
AkinoriHashimoto 0:7672973d6bed 31
AkinoriHashimoto 0:7672973d6bed 32 #include "mbed.h"
AkinoriHashimoto 0:7672973d6bed 33 #include "myTimer.h"
AkinoriHashimoto 0:7672973d6bed 34
AkinoriHashimoto 0:7672973d6bed 35 class DetectFreqAboveTH
AkinoriHashimoto 0:7672973d6bed 36 {
AkinoriHashimoto 0:7672973d6bed 37 public:
AkinoriHashimoto 0:7672973d6bed 38 DetectFreqAboveTH(int time_ms, int iter);
AkinoriHashimoto 0:7672973d6bed 39 ~DetectFreqAboveTH();
AkinoriHashimoto 0:7672973d6bed 40
AkinoriHashimoto 0:7672973d6bed 41 bool chkAbove();
AkinoriHashimoto 0:7672973d6bed 42
AkinoriHashimoto 0:7672973d6bed 43 private:
AkinoriHashimoto 0:7672973d6bed 44 unsigned short id, iterThreshold, *span; // circular buffer
AkinoriHashimoto 0:7672973d6bed 45 unsigned int unitTime;
AkinoriHashimoto 0:7672973d6bed 46 // 16bit: 0xFFFF
AkinoriHashimoto 0:7672973d6bed 47
AkinoriHashimoto 0:7672973d6bed 48 myTimer timer;
AkinoriHashimoto 0:7672973d6bed 49 };