Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
InterruptIn Class Reference
[InterruptIn class]
A digital interrupt input, used to call a function on a rising or falling edge. More...
#include <InterruptIn.h>
Inherits NonCopyable< InterruptIn >.
Public Member Functions | |
InterruptIn (PinName pin) | |
Create an InterruptIn connected to the specified pin. | |
InterruptIn (PinName pin, PinMode mode) | |
Create an InterruptIn connected to the specified pin, and the pin configured to the specified mode. | |
int | read () |
Read the input, represented as 0 or 1 (int) | |
operator int () | |
An operator shorthand for read() | |
void | rise (Callback< void()> func) |
Attach a function to call when a rising edge occurs on the input. | |
template<typename T , typename M > | |
MBED_DEPRECATED_SINCE ("mbed-os-5.1","The rise function does not support cv-qualifiers. Replaced by ""rise(callback(obj, method)).") void rise(T *obj | |
Attach a member function to call when a rising edge occurs on the input. | |
void | fall (Callback< void()> func) |
Attach a function to call when a falling edge occurs on the input. | |
template<typename T , typename M > | |
MBED_DEPRECATED_SINCE ("mbed-os-5.1","The fall function does not support cv-qualifiers. Replaced by ""fall(callback(obj, method)).") void fall(T *obj | |
Attach a member function to call when a falling edge occurs on the input. | |
void | enable_irq () |
Enable IRQ. | |
void | disable_irq () |
Disable IRQ. | |
Private Member Functions | |
MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &) | |
NonCopyable copy constructor. | |
MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator | |
NonCopyable copy assignment operator. |
Detailed Description
A digital interrupt input, used to call a function on a rising or falling edge.
- Note:
- Synchronization level: Interrupt safe
Example:
// Flash an LED while waiting for events #include "mbed.h" InterruptIn event(p16); DigitalOut led(LED1); void trigger() { printf("triggered!\n"); } int main() { // register trigger() to be called upon the rising edge of event event.rise(&trigger); while(1) { led = !led; wait(0.25); } }
Definition at line 65 of file InterruptIn.h.
Constructor & Destructor Documentation
InterruptIn | ( | PinName | pin ) |
Create an InterruptIn connected to the specified pin.
- Parameters:
-
pin InterruptIn pin to connect to
Definition at line 27 of file InterruptIn.cpp.
InterruptIn | ( | PinName | pin, |
PinMode | mode | ||
) |
Create an InterruptIn connected to the specified pin, and the pin configured to the specified mode.
- Parameters:
-
pin InterruptIn pin to connect to mode Desired Pin mode configuration. (Valid values could be PullNone, PullDown, PullUp and PullDefault. See PinNames.h for your target for definitions)
Definition at line 37 of file InterruptIn.cpp.
Member Function Documentation
void disable_irq | ( | ) |
Disable IRQ.
This method depends on hardware implementation, might disable one port interrupts. For further information, check gpio_irq_disable().
Definition at line 124 of file InterruptIn.cpp.
void enable_irq | ( | ) |
Enable IRQ.
This method depends on hardware implementation, might enable one port interrupts. For further information, check gpio_irq_enable().
Definition at line 117 of file InterruptIn.cpp.
void fall | ( | Callback< void()> | func ) |
Attach a function to call when a falling edge occurs on the input.
- Parameters:
-
func A pointer to a void function, or 0 to set as none
Definition at line 85 of file InterruptIn.cpp.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , |
"The fall function does not support cv-qualifiers. Replaced by ""fall(callback(obj, method))." | |||
) |
Attach a member function to call when a falling edge occurs on the input.
- Parameters:
-
obj pointer to the object to call the member function on method pointer to the member function to be called
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , |
"The rise function does not support cv-qualifiers. Replaced by ""rise(callback(obj, method))." | |||
) |
Attach a member function to call when a rising edge occurs on the input.
- Parameters:
-
obj pointer to the object to call the member function on method pointer to the member function to be called
operator int | ( | ) |
An operator shorthand for read()
Definition at line 131 of file InterruptIn.cpp.
int read | ( | void | ) |
Read the input, represented as 0 or 1 (int)
- Returns:
- An integer representing the state of the input pin, 0 for logical 0, 1 for logical 1
Definition at line 59 of file InterruptIn.cpp.
void rise | ( | Callback< void()> | func ) |
Attach a function to call when a rising edge occurs on the input.
- Parameters:
-
func A pointer to a void function, or 0 to set as none
Definition at line 72 of file InterruptIn.cpp.
Generated on Tue Jul 12 2022 13:55:42 by
