Skip to content

Commit dfa6a7a

Browse files
factor out common function
1 parent 35308c1 commit dfa6a7a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/InterruptIn.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ InterruptIn::InterruptIn(PinName pin) : gpio(),
2424
_rise(NULL),
2525
_fall(NULL) {
2626
// No lock needed in the constructor
27-
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
27+
irq_init(pin);
2828
gpio_init_in(&gpio, pin);
2929
}
3030

@@ -34,10 +34,14 @@ InterruptIn::InterruptIn(PinName pin, PinMode mode) :
3434
_rise(NULL),
3535
_fall(NULL) {
3636
// No lock needed in the constructor
37-
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
37+
irq_init(pin);
3838
gpio_init_in_ex(&gpio, pin, mode);
3939
}
4040

41+
void InterruptIn::irq_init(PinName pin) {
42+
gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this);
43+
}
44+
4145
InterruptIn::~InterruptIn() {
4246
// No lock needed in the destructor
4347
gpio_irq_free(&gpio_irq);

drivers/InterruptIn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class InterruptIn : private NonCopyable<InterruptIn> {
159159

160160
Callback<void()> _rise;
161161
Callback<void()> _fall;
162+
163+
void irq_init(PinName pin);
162164
};
163165

164166
} // namespace mbed

0 commit comments

Comments
 (0)