mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #6239 from bmcdonnell-ionx/interrupt-in-pin-mode
Interrupt in pin modepull/6442/head
commit
801f27efcf
|
@ -19,16 +19,33 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
// Note: This single-parameter constructor exists to maintain binary
|
||||
// compatibility.
|
||||
// If not for that, we could simplify by having only the 2-param
|
||||
// constructor, with a default value for the PinMode.
|
||||
InterruptIn::InterruptIn(PinName pin) : gpio(),
|
||||
gpio_irq(),
|
||||
_rise(NULL),
|
||||
_fall(NULL) {
|
||||
// No lock needed in the constructor
|
||||
|
||||
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
|
||||
irq_init(pin);
|
||||
gpio_init_in(&gpio, pin);
|
||||
}
|
||||
|
||||
InterruptIn::InterruptIn(PinName pin, PinMode mode) :
|
||||
gpio(),
|
||||
gpio_irq(),
|
||||
_rise(NULL),
|
||||
_fall(NULL) {
|
||||
// No lock needed in the constructor
|
||||
irq_init(pin);
|
||||
gpio_init_in_ex(&gpio, pin, mode);
|
||||
}
|
||||
|
||||
void InterruptIn::irq_init(PinName pin) {
|
||||
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
|
||||
}
|
||||
|
||||
InterruptIn::~InterruptIn() {
|
||||
// No lock needed in the destructor
|
||||
gpio_irq_free(&gpio_irq);
|
||||
|
|
|
@ -66,6 +66,15 @@ public:
|
|||
* @param pin InterruptIn pin to connect to
|
||||
*/
|
||||
InterruptIn(PinName pin);
|
||||
|
||||
/** Create an InterruptIn connected to the specified pin,
|
||||
* and the pin configured to the specified mode.
|
||||
*
|
||||
* @param pin InterruptIn pin to connect to
|
||||
* @param mode The mode to set the pin to (PullUp/PullDown/etc.)
|
||||
*/
|
||||
InterruptIn(PinName pin, PinMode mode);
|
||||
|
||||
virtual ~InterruptIn();
|
||||
|
||||
/** Read the input, represented as 0 or 1 (int)
|
||||
|
@ -153,6 +162,8 @@ protected:
|
|||
|
||||
Callback<void()> _rise;
|
||||
Callback<void()> _fall;
|
||||
|
||||
void irq_init(PinName pin);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
Loading…
Reference in New Issue