summaryrefslogtreecommitdiff
path: root/src/counter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/counter.cpp')
-rw-r--r--src/counter.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/counter.cpp b/src/counter.cpp
new file mode 100644
index 0000000..89e597c
--- /dev/null
+++ b/src/counter.cpp
@@ -0,0 +1,21 @@
+#include "counter.h"
+
+Counter::Counter(PinName pin):_interrupt(pin)
+{
+ _interrupt.rise(this, &Counter::increment);
+}
+
+void Counter::increment()
+{
+ _count++;
+}
+
+int Counter::read()
+{
+ return _count;
+}
+
+void Counter::write(int new_count)
+{
+ _count = new_count;
+}