Gabriel Smakaj
/
Test
Smakaj
main.cpp
- Committer:
- gabs089
- Date:
- 2018-11-29
- Revision:
- 0:cc2bde387551
- Child:
- 1:3edc991805bd
File content as of revision 0:cc2bde387551:
#include "mbed.h" class IsAnEvent : public InterruptIn { volatile int16_t _pressed; void _RisingISR(); public: IsAnEvent() : InterruptIn(p15) {}; IsAnEvent(PinName pin) : InterruptIn(pin) { rise(callback(this, &IsAnEvent::_RisingISR)); _pressed=0; }; int CheckFlag(); void InitIsr(); }; void IsAnEvent::InitIsr() { rise(callback(this, &IsAnEvent::_RisingISR)); } void IsAnEvent::_RisingISR() { wait_ms(50); if( read() ) _pressed = true; } int IsAnEvent::CheckFlag() { if( _pressed ) { _pressed = false; return 1; } return 0; }