Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
counter.h
00001 // 00002 // Counter Class 00003 // 00004 // 2019.10.13 ... Originally written by Y.Kuroda 00005 // 00006 #ifndef _COUNTER_H 00007 #define _COUNTER_H 00008 00009 class Counter { 00010 public: 00011 Counter(PinName pin) : _interrupt(pin), _count(0) { // create the InterruptIn on the pin specified to Counter 00012 _interrupt.rise(callback(this, &Counter::increment)); // attach increment function of this counter instance 00013 _interrupt.fall(callback(this, &Counter::increment)); // attach increment function of this counter instance 00014 } 00015 00016 void increment() { _count++; } 00017 int read() { return _count; } 00018 int set(int c) { return _count=c; } 00019 int reset(){ return set(0); } 00020 00021 int operator=(int c) { return set(c); } 00022 operator int() { return read(); } 00023 Counter& operator=(Counter& c){ _count=c.read(); return *this; } 00024 00025 protected: 00026 InterruptIn _interrupt; 00027 volatile int _count; 00028 }; 00029 00030 #endif 00031
Generated on Thu Jul 28 2022 03:03:00 by
1.7.2