1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Stock NVIC interrupt controller driver (plan.md Phase 13).
//!
//! NVIC is architectural — same registers at the same fixed addresses on
//! every Cortex-M — so unlike RISC-V's CLINT/PLIC (platform-defined base
//! addresses, Group C constants from the board), this needs nothing from
//! the BSP beyond which IRQ *number* corresponds to which peripheral
//! (that mapping lives in each `rivet-bsp-*` crate's `irq` module).
//!
//! Raw register access (`NVIC::PTR`), not `cortex_m::peripheral::NVIC`'s
//! generic `Nr`-trait convenience methods — this crate has no PAC-
//! generated interrupt-number enum to hand it, and never will (the whole
//! point of Group A/B is not depending on a board-specific PAC).
use ;
/// Enable IRQ `n` (0-based, the "external interrupt" numbering — vector
/// table slot `16 + n`).
/// Disable IRQ `n`.
/// Set IRQ `n`'s priority (0 = highest). NVIC priority registers are
/// byte-addressable per IRQ on ARMv7-M, so this is a single non-atomic
/// byte write — no read-modify-write hazard.
/// Force IRQ `n` pending (software trigger, via NVIC's ISPR). Used by the
/// `irq_test` example to exercise the real hardware dispatch path
/// (vector table → NVIC → `rivet_irq_handler` → `rivet::irq::dispatch`)
/// without needing an external device to assert a physical interrupt
/// line — a standard, legitimate NVIC self-test technique (ARMv7-M ISPR
/// is specified for exactly this).
/// Generic vector-table target for every external-interrupt slot: reads
/// which IRQ is actually active from `SCB.ICSR.VECTACTIVE` and dispatches
/// through `rivet::irq`. One shared symbol works for every IRQ number —
/// the vector table entries are all `LONG(rivet_irq_handler)` — because
/// `VectActive` is exactly "which vector actually fired", the same
/// information a per-IRQ-numbered handler function's identity would
/// otherwise encode.
extern "C"