Skip to main content

Module interrupt

Module interrupt 

Source
Expand description

§Interrupt support

This module contains code to configure and handle peripheral interrupts.

§Overview

Peripheral interrupt requests are not handled by the CPU directly. Instead, they are routed through the interrupt matrix, which maps peripheral interrupts to CPU interrupts. There are more peripheral interrupt signals than CPU interrupts, and multiple peripheral interrupts can be routed to the same CPU interrupt. A set of CPU interrupts are configured to run a default handler routine, which polls the interrupt controller and calls the appropriate handlers for the pending peripheral interrupts.

This default handler implements interrupt nesting - meaning a higher Priority interrupt can preempt a lower priority interrupt handler. The number of priorities is a chip-specific detail.

§Usage

Peripheral drivers manage interrupts for you. Where appropriate, a set_interrupt_handler function is provided, which allows you to register a function to handle interrupts at a priority level of your choosing. Interrupt handler functions need to be marked by the [#[handler]] attribute. These drivers also provide listen and unlisten functions that control whether an interrupt will be generated for the matching event or not. For more information and examples, consult the documentation of the specific peripheral drivers.

If you are writing your own peripheral driver, you will need to first register interrupt handlers using the [peripheral singletons’] bind_X_interrupt functions. You can use the matching enable and disable functions to control the peripheral interrupt in the interrupt matrix, or you can, depending on the peripheral, set or clear the appropriate enable bits in the int_ena register.

[#[handler]]: crate::handler [peripheral singletons’]: crate::peripherals::I2C0

§Software interrupts

The software module implements software interrupts using peripheral interrupt signals.

Modules§

softwareunstable
Software Interrupts

Structs§

InterruptHandlerunstable
An interrupt handler
InterruptStatusunstable
Representation of peripheral-interrupt status bits.
InterruptStatusIteratorunstable
Iterator over set interrupt status bits
IsrCallbackunstable
Represents an ISR callback function
TrapFrameunstable
Registers saved in trap handler

Enums§

CpuInterruptunstable
Enumeration of available CPU interrupts.
DirectBindableCpuInterrupt
Enumeration of CPU interrupts available for direct binding.
ElevatedRunLevel
Interrupt run levels.
InterruptKindunstable
Interrupt kind
Priority
Interrupt priority levels.
PriorityErrorunstable
Priority Level Error
RunLevel
Represents the priority level of running code.

Constants§

DEFAULT_INTERRUPT_HANDLERunstable
Default (unhandled) interrupt handler

Traits§

InterruptConfigurableunstable
Trait implemented by drivers which allow the user to set an InterruptHandler

Functions§

bind_handlerunstable
Binds the given handler to a peripheral interrupt.
bound_handlerunstable
Returns the currently bound interrupt handler.
disableunstable
Disable the given peripheral interrupt.
enableunstable
Enables a peripheral interrupt at a given priority, using vectored CPU interrupts.
enable_directunstable
Enable an interrupt by directly binding it to an available CPU interrupt
wait_for_interruptunstable
Wait for an interrupt to occur.