ExtInt - External Interrupt
This class configures I/O pins to interrupt when external events occur.
Constructor#
machine.ExtInt
#
Parameter:
GPIOn
- Integer type. GPIO pin number to be controlled. See Pin Modules for pin definitions (excluding BG95M3). Click here to view pin correspondences of BG95M3 platform.mode
- Integer type. Trigger mode.
IRQ_RISING
– Trigger rising edgeIRQ_FALLING
– Trigger falling edgeIRQ_RISING_FALLING
– Trigger rising and falling edgepull
- Integer type. Pull selection mode.PULL_PU
– Pull-up modePULL_PD
– Pull-down modePULL_DISABLE
– Floating modecallback
- Integer type. The interrupt triggers the callback function.
A tuple with the length of 2 bytes
args[0]: GPIO number
args[1]: Trigger edge (0: rising edge 1: falling edge)[filter_time]
- Integer type. Filtering time,uint: ms, default value is 0.Allowed input nonzero value is multiple of 10.If the value is not 0, the filtering is performed at the specified time.parameter [filter_time] only EG912N/EG915N/EC600M/EC800M/EG810M/EC200A/UC200A series module support
Pin Correspondences of BG95M3 Module
GPIO2 – Pin5GPIO3 – Pin6
GPIO6 – Pin19
GPIO7 – Pin22
GPIO8 – Pin23
GPIO9 – Pin25
GPIO11 – Pin27
GPIO12 – Pin28
GPIO14 – Pin41
GPIO16 – Pin65
GPIO17 – Pin66
GPIO18 – Pin85
GPIO19 – Pin86
GPIO22 – Pin20
GPIO23 – Pin21
GPIO24 – Pin30
GPIO25 – Pin34
GPIO26 – Pin35
GPIO29 – Pin38
GPIO30 – Pin39
Example:
Methods#
extint.enable
#
This method enables interrupts that is to enable external interrupt of an extint object. When the interrupt pin receives the rising edge signal or falling edge signal, it will call a callback function to execute the interrupt.
Return Value:
0
- Successful execution
-1
- Failed execution
extint.disable
#
This method disables interrupts associated with extint objects.
Return Value:
0
- Successful execution
-1
- Failed execution
extint.line
#
This method reads the line number mapped by the pin.
Return Value:
The line number mapped by the pin.
Example:
extint.read_count
#
This method returns number of times an interrupt was triggered.
Parameter:
is_reset
- Integer type. Whether to reset the count after reading.0
indicates that the count is not resetted and1
indicates a count resetting.
Return Value:
The list [rising_count, falling_count]
rising_count
: Number of times that the rising edge triggers an interruptfalling_count
: Number of times that the falling edge triggers an interrupt
extint.count_reset
#
This method clears number of times an interrupt is triggered.
Return Value:
0
- Successful execution
-1
- Failed execution
extint.read_level
#
This method reads the current pin level.
Return Value:
Pin level.
0
- low level.
1
- high level.