abc
Dependents: Microwave_MBED MicrowaveSimulation_LPC1768 RTOS_Alarm_Clock USB_Project_Host ... more
DebounceInterrupts.cpp@4:19689187352e, 2014-02-18 (annotated)
- Committer:
- kandangath
- Date:
- Tue Feb 18 06:15:45 2014 +0000
- Revision:
- 4:19689187352e
- Parent:
- 3:e4b7033508d1
- Child:
- 6:e1461ccdf3c0
Add enum for interrupt trigger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kandangath | 0:ca5a0fee9f52 | 1 | #include "DebounceInterrupts.h" |
kandangath | 0:ca5a0fee9f52 | 2 | |
kandangath | 0:ca5a0fee9f52 | 3 | Timeout timeout; |
kandangath | 0:ca5a0fee9f52 | 4 | |
kandangath | 0:ca5a0fee9f52 | 5 | DebounceInterrupts::DebounceInterrupts(void (*fptr)(void), |
kandangath | 0:ca5a0fee9f52 | 6 | InterruptIn *interruptIn, |
kandangath | 4:19689187352e | 7 | const interruptTrigger& trigger, |
kandangath | 0:ca5a0fee9f52 | 8 | const unsigned int& debounce_ms) |
kandangath | 0:ca5a0fee9f52 | 9 | { |
kandangath | 0:ca5a0fee9f52 | 10 | fCallback = fptr; |
kandangath | 4:19689187352e | 11 | |
kandangath | 4:19689187352e | 12 | switch(trigger) { |
kandangath | 4:19689187352e | 13 | case INT_RISE: |
kandangath | 3:e4b7033508d1 | 14 | interruptIn->rise(this, &DebounceInterrupts::_onInterrupt); |
kandangath | 4:19689187352e | 15 | break; |
kandangath | 4:19689187352e | 16 | case INT_FALL: |
kandangath | 3:e4b7033508d1 | 17 | interruptIn->fall(this, &DebounceInterrupts::_onInterrupt); |
kandangath | 4:19689187352e | 18 | break; |
kandangath | 4:19689187352e | 19 | default: |
kandangath | 4:19689187352e | 20 | break; |
kandangath | 0:ca5a0fee9f52 | 21 | } |
kandangath | 4:19689187352e | 22 | |
kandangath | 0:ca5a0fee9f52 | 23 | fDebounce_us = 1000*debounce_ms; |
kandangath | 0:ca5a0fee9f52 | 24 | } |
kandangath | 0:ca5a0fee9f52 | 25 | |
kandangath | 0:ca5a0fee9f52 | 26 | DebounceInterrupts::~DebounceInterrupts() |
kandangath | 0:ca5a0fee9f52 | 27 | { |
kandangath | 0:ca5a0fee9f52 | 28 | } |
kandangath | 0:ca5a0fee9f52 | 29 | |
kandangath | 3:e4b7033508d1 | 30 | void DebounceInterrupts::_onInterrupt() |
kandangath | 0:ca5a0fee9f52 | 31 | { |
kandangath | 0:ca5a0fee9f52 | 32 | timeout.detach(); |
kandangath | 0:ca5a0fee9f52 | 33 | timeout.attach_us(fCallback,fDebounce_us); |
kandangath | 0:ca5a0fee9f52 | 34 | } |