Tschuchnik

Dependencies:   mbed

Committer:
lordofthestorm12
Date:
Thu Nov 29 17:19:40 2018 +0000
Revision:
1:26e8a018be37
Parent:
0:3e843e64ce84
Tinf Test Tschuchnik

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lordofthestorm12 0:3e843e64ce84 1 #include "mbed.h"
lordofthestorm12 0:3e843e64ce84 2
lordofthestorm12 0:3e843e64ce84 3 class IsA : BusOut{
lordofthestorm12 0:3e843e64ce84 4
lordofthestorm12 0:3e843e64ce84 5 IsA():BusOut(LED1, LED2, LED3, LED4){};
lordofthestorm12 0:3e843e64ce84 6
lordofthestorm12 0:3e843e64ce84 7 void LedOff(){write(0x00);}
lordofthestorm12 0:3e843e64ce84 8
lordofthestorm12 1:26e8a018be37 9 void LedOn(int lVal){write(lVal)};
lordofthestorm12 0:3e843e64ce84 10 void LedOn(){write(0x0f);}
lordofthestorm12 0:3e843e64ce84 11
lordofthestorm12 0:3e843e64ce84 12 };
lordofthestorm12 0:3e843e64ce84 13
lordofthestorm12 0:3e843e64ce84 14 class IsAnEvent : public InterruptIn {
lordofthestorm12 0:3e843e64ce84 15 volatile int16_t _pressed;
lordofthestorm12 0:3e843e64ce84 16 void _RisingISR();
lordofthestorm12 0:3e843e64ce84 17 public:
lordofthestorm12 0:3e843e64ce84 18 IsAnEvent() : InterruptIn(p15) {};
lordofthestorm12 0:3e843e64ce84 19 IsAnEvent(PinName pin) : InterruptIn(pin) {
lordofthestorm12 0:3e843e64ce84 20 rise(callback(this, &IsAnEvent::_RisingISR));
lordofthestorm12 0:3e843e64ce84 21 _pressed=0;
lordofthestorm12 0:3e843e64ce84 22 };
lordofthestorm12 0:3e843e64ce84 23 int CheckFlag();
lordofthestorm12 0:3e843e64ce84 24 void InitIsr();
lordofthestorm12 0:3e843e64ce84 25 };
lordofthestorm12 0:3e843e64ce84 26
lordofthestorm12 0:3e843e64ce84 27 void IsAnEvent::InitIsr() {
lordofthestorm12 0:3e843e64ce84 28 rise(callback(this, &IsAnEvent::_RisingISR));
lordofthestorm12 0:3e843e64ce84 29 }
lordofthestorm12 0:3e843e64ce84 30
lordofthestorm12 0:3e843e64ce84 31 void IsAnEvent::_RisingISR() {
lordofthestorm12 0:3e843e64ce84 32 wait_ms(50);
lordofthestorm12 0:3e843e64ce84 33 if( read() )
lordofthestorm12 0:3e843e64ce84 34 _pressed = true;
lordofthestorm12 0:3e843e64ce84 35 }
lordofthestorm12 0:3e843e64ce84 36 int IsAnEvent::CheckFlag() {
lordofthestorm12 0:3e843e64ce84 37 if( _pressed ) {
lordofthestorm12 0:3e843e64ce84 38 _pressed = false;
lordofthestorm12 0:3e843e64ce84 39 return 1;
lordofthestorm12 0:3e843e64ce84 40 }
lordofthestorm12 0:3e843e64ce84 41 return 0;
lordofthestorm12 0:3e843e64ce84 42 }
lordofthestorm12 0:3e843e64ce84 43
lordofthestorm12 0:3e843e64ce84 44 int main() {
lordofthestorm12 1:26e8a018be37 45
lordofthestorm12 1:26e8a018be37 46 enum STM {INIT, EIN, AUS };
lordofthestorm12 1:26e8a018be37 47
lordofthestorm12 0:3e843e64ce84 48 while(1) {
lordofthestorm12 0:3e843e64ce84 49
lordofthestorm12 0:3e843e64ce84 50 }
lordofthestorm12 0:3e843e64ce84 51 }