Debounce InterruptIn
Dependents: led_sigfox Allumag_lampe_sigfox Case_study_02_Turnstile B18_MP3_PLAYER ... more
DebounceInterrupts.h@4:19689187352e, 2014-02-18 (annotated)
- Committer:
- kandangath
- Date:
- Tue Feb 18 06:15:45 2014 +0000
- Revision:
- 4:19689187352e
- Parent:
- 3:e4b7033508d1
- Child:
- 5:3c0f741fb448
Add enum for interrupt trigger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kandangath | 0:ca5a0fee9f52 | 1 | |
kandangath | 0:ca5a0fee9f52 | 2 | /** |
kandangath | 1:ffacad1b455a | 3 | * Debounces an InterruptIn |
kandangath | 0:ca5a0fee9f52 | 4 | */ |
kandangath | 0:ca5a0fee9f52 | 5 | |
kandangath | 0:ca5a0fee9f52 | 6 | #ifndef DEBOUNCE_INTERRUPTS_H |
kandangath | 0:ca5a0fee9f52 | 7 | #define DEBOUNCE_INTERRUPTS_H |
kandangath | 0:ca5a0fee9f52 | 8 | |
kandangath | 0:ca5a0fee9f52 | 9 | #include <stdint.h> |
kandangath | 0:ca5a0fee9f52 | 10 | #include "mbed.h" |
kandangath | 0:ca5a0fee9f52 | 11 | |
kandangath | 4:19689187352e | 12 | enum interruptTrigger{ |
kandangath | 4:19689187352e | 13 | INT_FALL = 0, |
kandangath | 4:19689187352e | 14 | INT_RISE = 1 |
kandangath | 4:19689187352e | 15 | }; |
kandangath | 4:19689187352e | 16 | |
kandangath | 0:ca5a0fee9f52 | 17 | class DebounceInterrupts { |
kandangath | 0:ca5a0fee9f52 | 18 | private: |
kandangath | 0:ca5a0fee9f52 | 19 | unsigned int fDebounce_us; |
kandangath | 0:ca5a0fee9f52 | 20 | void (*fCallback)(void); |
kandangath | 3:e4b7033508d1 | 21 | void _onInterrupt(void); |
kandangath | 0:ca5a0fee9f52 | 22 | public: |
kandangath | 4:19689187352e | 23 | DebounceInterrupts(void (*fptr)(void), /* function to be called after debounced InterruptIn */ |
kandangath | 4:19689187352e | 24 | InterruptIn *interrupt, /* InterruptIn to monitor */ |
kandangath | 4:19689187352e | 25 | const interruptTrigger& trigger, /* true: rise, false: fall */ |
kandangath | 4:19689187352e | 26 | const uint32_t& debounce_ms=10); /* stability duration required */ |
kandangath | 0:ca5a0fee9f52 | 27 | ~DebounceInterrupts(); |
kandangath | 0:ca5a0fee9f52 | 28 | }; |
kandangath | 0:ca5a0fee9f52 | 29 | #endif |