Modifications

Sauter à la navigation Sauter à la recherche
1 335 octets ajoutés ,  26 mars 2017 à 20:55
Ligne 74 : Ligne 74 :     
== Gestion des interruptions ==
 
== Gestion des interruptions ==
x
+
In Pycom’s ESP32 MicroPython port there are no restrictions on what you can do within an interrupt handler. For example, other ports don’t allow you to allocate memory inside the handler or use sockets.
 +
 
 +
These limitations were raised by handling the interrupt events differently. When an interrupt happens, a message is posted into a queue, notifying a separate thread that the appropriate callback handler should be called. Such handler would receive an argument. By default it is the object associated with the event.
 +
 
 +
The programmer can do whatever is needed inside the callback, such as creating new variables, or even sending network packets. Just keep in mind that interrupts are processed sequentially, so try to keep the handlers as quick as possible in order to attend them all in a short time.
 +
 
 +
Currently there are 2 classes supporting interrupts, there the [https://docs.pycom.io/pycom_esp32/library/machine.Timer.html#machine.Timer.Alarm|Alarm] class and the [https://docs.pycom.io/pycom_esp32/library/machine.Pin.html#machine.Pin Pin]. Both classes provide the {{fname|.callback()}} method that enables the interrupt and registers the given handler. More details about the usage along with examples can be found in their respective sections.
 +
 
 +
{{ambox|text=Currently the interrupt system can queue up to 16 interrupts.}}
    
{{LOPY-TRAILER}}
 
{{LOPY-TRAILER}}
29 917

modifications

Menu de navigation