.. include:: Interrupt Handling ================== .. topic:: Documentation * :doc:`../why-os/interrupts` * `Zephyr: Interrupt Service Routine APIs `__ IRQs And ISRs ------------- .. image:: sensor-irq.svg :scale: 60% :align: right * Interrupt service routine (ISR): callback ``void(int irqnum)`` * Attached to an Interrupt request (IRQ) ``irqnum`` * Called *asynchronously* |longrightarrow| runs at the most inopportune time * IRQ can safely be considered parallel (though varies per architecture) * Main loop: power saving, ideally Serving Interrupts ------------------ .. literalinclude:: code/sensor-irq.cpp :caption: :download:`code/sensor-irq.cpp` :language: c++ .. code-block:: console $ why-shell code/why-interrupt-sensor-irq > irq 2 irq #2: timestamp=196188342592226, value=97 >