Smakaj

Dependencies:   mbed

Committer:
gabs089
Date:
Thu Nov 29 17:19:32 2018 +0000
Revision:
0:cc2bde387551
Child:
1:3edc991805bd
Smakaj tinf Test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gabs089 0:cc2bde387551 1 #include "mbed.h"
gabs089 0:cc2bde387551 2 class IsAnEvent : public InterruptIn {
gabs089 0:cc2bde387551 3 volatile int16_t _pressed;
gabs089 0:cc2bde387551 4 void _RisingISR();
gabs089 0:cc2bde387551 5 public:
gabs089 0:cc2bde387551 6 IsAnEvent() : InterruptIn(p15) {};
gabs089 0:cc2bde387551 7 IsAnEvent(PinName pin) : InterruptIn(pin) {
gabs089 0:cc2bde387551 8 rise(callback(this, &IsAnEvent::_RisingISR));
gabs089 0:cc2bde387551 9 _pressed=0;
gabs089 0:cc2bde387551 10 };
gabs089 0:cc2bde387551 11 int CheckFlag();
gabs089 0:cc2bde387551 12 void InitIsr();
gabs089 0:cc2bde387551 13 };
gabs089 0:cc2bde387551 14
gabs089 0:cc2bde387551 15 void IsAnEvent::InitIsr() {
gabs089 0:cc2bde387551 16 rise(callback(this, &IsAnEvent::_RisingISR));
gabs089 0:cc2bde387551 17 }
gabs089 0:cc2bde387551 18
gabs089 0:cc2bde387551 19 void IsAnEvent::_RisingISR() {
gabs089 0:cc2bde387551 20 wait_ms(50);
gabs089 0:cc2bde387551 21 if( read() )
gabs089 0:cc2bde387551 22 _pressed = true;
gabs089 0:cc2bde387551 23 }
gabs089 0:cc2bde387551 24 int IsAnEvent::CheckFlag() {
gabs089 0:cc2bde387551 25 if( _pressed ) {
gabs089 0:cc2bde387551 26 _pressed = false;
gabs089 0:cc2bde387551 27 return 1;
gabs089 0:cc2bde387551 28 }
gabs089 0:cc2bde387551 29 return 0;
gabs089 0:cc2bde387551 30 }