Version: v0.19.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2021 License: BSD-3-Clause Imports: 0 Imported by: 0



Package interrupt provides access to hardware interrupts. It provides a way to define interrupts and to enable/disable them.



This section is empty.


This section is empty.


func Restore

func Restore(state State)

Restore restores interrupts to what they were before. Give the previous state returned by Disable as a parameter. If interrupts were disabled before calling Disable, this will not re-enable interrupts, allowing for nested cricital sections.


type Interrupt

type Interrupt struct {
	// contains filtered or unexported fields

Interrupt provides direct access to hardware interrupts. You can configure this interrupt through this interface.

Do not use the zero value of an Interrupt object. Instead, call New to obtain an interrupt handle.

func New

func New(id int, handler func(Interrupt)) Interrupt

New is a compiler intrinsic that creates a new Interrupt object. You may call it only once, and must pass constant parameters to it. That means that the interrupt ID must be a Go constant and that the handler must be a simple function: closures are not supported.

type State

type State uintptr

State represents the previous global interrupt state.

func Disable

func Disable() (state State)

Disable disables all interrupts and returns the previous interrupt state. It can be used in a critical section like this:

state := interrupt.Disable()
// critical section

Critical sections can be nested. Make sure to call Restore in the same order as you called Disable (this happens naturally with the pattern above).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to