-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeatDetector.h
54 lines (42 loc) · 1.36 KB
/
BeatDetector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* BeatDetector.h
*
* Created on: May 30, 2016
* Author: Adam
*/
#ifndef BEATDETECTOR_H_
#define BEATDETECTOR_H_
#include "Arduino.h"
#include "Arduino_FreeRTOS.h"
// Analog pin 0 == ATmega328P pin 23
#define INPUT_PIN 0
class BeatDetector {
private:
public:
BeatDetector();
/**
* Loop function that the beat detector task is registered with. Never exits. Takes no params.
*/
void taskFunc();
/**
* Glue for FreeRTOS.
*/
static void cast(void *params);
/*
* When a master becomes a slave, it suspends the beat detector thread. When this happens,
* xLastWakeTime will be in the past, and so calls to vTaskDelayUntil will return immediately
* until xLastWakeTime has been incremented to be now.
*
* What this means is, when this object's thread is woken up, it will run as many filter cycles
* as it missed when it was sleeping (without a delay between cycles). Since this thread has
* the highest priority, it'll own the system until it's done.
*
* This function is to be called when this thread is woken. It resets xLastWakeTime to avoid
* this problem.
*
* See also: http://www.freertos.org/FreeRTOS_Support_Forum_Archive/June_2007/freertos_VTaskDelayUntil_and_VTaskResume_Problem_1764930.html
* and the note at: http://www.freertos.org/vtaskdelayuntil.html
*/
void resetLastWakeTime();
};
#endif /* BEATDETECTOR_H_ */