Oliver Ainhirn
/
TINF_Test
29.11.2018 TINF Test
main.cpp@1:097ca77eb087, 2018-11-29 (annotated)
- Committer:
- corsa1600
- Date:
- Thu Nov 29 17:15:33 2018 +0000
- Revision:
- 1:097ca77eb087
- Parent:
- 0:0d3dab410e8c
- Child:
- 2:ccf72b284e3d
Aufforderung vom Lehrer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
corsa1600 | 0:0d3dab410e8c | 1 | #include "mbed.h" |
corsa1600 | 0:0d3dab410e8c | 2 | |
corsa1600 | 1:097ca77eb087 | 3 | BusOut BoardLeds ( LED1 , LED2, LED3, LED4); |
corsa1600 | 1:097ca77eb087 | 4 | |
corsa1600 | 0:0d3dab410e8c | 5 | class IsAnEvent : public InterruptIn { |
corsa1600 | 0:0d3dab410e8c | 6 | volatile int16_t _pressed; |
corsa1600 | 0:0d3dab410e8c | 7 | void _RisingISR(); |
corsa1600 | 0:0d3dab410e8c | 8 | public: |
corsa1600 | 0:0d3dab410e8c | 9 | IsAnEvent() : InterruptIn(p14) {}; |
corsa1600 | 0:0d3dab410e8c | 10 | IsAnEvent(PinName pin) : InterruptIn(pin) { |
corsa1600 | 0:0d3dab410e8c | 11 | rise(callback(this, &IsAnEvent::_RisingISR)); |
corsa1600 | 0:0d3dab410e8c | 12 | _pressed=0; |
corsa1600 | 0:0d3dab410e8c | 13 | }; |
corsa1600 | 0:0d3dab410e8c | 14 | int CheckFlag(); |
corsa1600 | 0:0d3dab410e8c | 15 | void InitIsr(); |
corsa1600 | 0:0d3dab410e8c | 16 | }; |
corsa1600 | 0:0d3dab410e8c | 17 | |
corsa1600 | 0:0d3dab410e8c | 18 | void IsAnEvent::InitIsr() { |
corsa1600 | 0:0d3dab410e8c | 19 | rise(callback(this, &IsAnEvent::_RisingISR)); |
corsa1600 | 0:0d3dab410e8c | 20 | } |
corsa1600 | 0:0d3dab410e8c | 21 | |
corsa1600 | 0:0d3dab410e8c | 22 | void IsAnEvent::_RisingISR() { |
corsa1600 | 0:0d3dab410e8c | 23 | wait_ms(50); |
corsa1600 | 0:0d3dab410e8c | 24 | if( read() ) |
corsa1600 | 0:0d3dab410e8c | 25 | _pressed = true; |
corsa1600 | 0:0d3dab410e8c | 26 | } |
corsa1600 | 0:0d3dab410e8c | 27 | int IsAnEvent::CheckFlag() { |
corsa1600 | 0:0d3dab410e8c | 28 | if( _pressed ) { |
corsa1600 | 0:0d3dab410e8c | 29 | _pressed = false; |
corsa1600 | 0:0d3dab410e8c | 30 | return 1; |
corsa1600 | 0:0d3dab410e8c | 31 | } |
corsa1600 | 0:0d3dab410e8c | 32 | return 0; |
corsa1600 | 0:0d3dab410e8c | 33 | } |