From 523f047b1b3c42b0aa40305291ca5d29a1b543f5 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Sat, 6 May 2017 19:10:56 +0100 Subject: Seperate counter into propper code and head file --- src/counter.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/counter.cpp (limited to 'src/counter.cpp') 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; +} -- cgit v1.2.3-54-g00ecf