-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPWMInput.hpp
More file actions
58 lines (46 loc) · 1.22 KB
/
PWMInput.hpp
File metadata and controls
58 lines (46 loc) · 1.22 KB
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
55
56
57
58
#ifndef EVT_PWMINPUT_HPP
#define EVT_PWMINPUT_HPP
#include <stdint.h>
namespace core::io {
// Forward declarations:
// The different pins are hardware specific. Forward declaration to allow
// at compilation time the decision of which pins should be used.
enum class Pin;
class PWMInput {
public:
/**
* Setup the given pin for PWMInput usage.
*
* @param[in] pin The pin to setup for PWMInput
*/
PWMInput(Pin pin);
/**
* Get the current duty cycle.
*
* @return The duty cycle of the PWM signal being read, as a percentage.
*/
virtual uint8_t getDutyCycle() = 0;
/**
* Get the current period.
*
* @return The period the PWM signal being read is operating at in timer ticks.
*/
virtual uint32_t getPeriod() = 0;
/**
* Get the current frequency.
*
* @return The frequency the PWM signal being read is operating at in Hz.
*/
virtual uint32_t getFrequency() = 0;
protected:
/// The pin PWM input is on
Pin pin;
/// The duty cycle of the PWM input
uint8_t dutyCycle;
/// The period of the PWM input
uint32_t period;
/// The frequency of the PWM input
uint32_t frequency;
};
} // namespace core::io
#endif