Tschuchnik

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 class IsA : BusOut{
00004     
00005     IsA():BusOut(LED1, LED2, LED3, LED4){};
00006     
00007     void LedOff(){write(0x00);}
00008     
00009     void LedOn(int lVal){write(lVal)};
00010     void LedOn(){write(0x0f);}
00011     
00012     };
00013 
00014 class IsAnEvent : public InterruptIn {
00015         volatile int16_t _pressed;
00016         void _RisingISR(); 
00017     public:
00018         IsAnEvent() : InterruptIn(p15) {};
00019         IsAnEvent(PinName pin) : InterruptIn(pin) {
00020              rise(callback(this, &IsAnEvent::_RisingISR)); 
00021             _pressed=0; 
00022         };
00023         int CheckFlag();
00024         void InitIsr();
00025 };
00026 
00027 void IsAnEvent::InitIsr() { 
00028     rise(callback(this, &IsAnEvent::_RisingISR)); 
00029 }
00030 
00031 void IsAnEvent::_RisingISR() {
00032     wait_ms(50);
00033     if( read() )
00034         _pressed = true;
00035 }
00036 int IsAnEvent::CheckFlag() {
00037     if( _pressed ) { 
00038         _pressed = false; 
00039         return 1; 
00040     }
00041     return 0;
00042 }
00043 
00044 int main() {
00045     
00046     enum STM {INIT, EIN, AUS };
00047     
00048     while(1) {
00049 
00050     }
00051 }