Skip to content

[feature]: IRQ Handler Simulations#5

Merged
Charliechen114514 merged 3 commits into
mainfrom
feat/periph-irq-pipeline
Jun 23, 2026
Merged

[feature]: IRQ Handler Simulations#5
Charliechen114514 merged 3 commits into
mainfrom
feat/periph-irq-pipeline

Conversation

@Charliechen114514

Copy link
Copy Markdown
Member

No description provided.

raise_irq was a no-op — the entire peripheral→NVIC IRQ channel was never
connected (SysTick bypassed it via sys_tick_irq). Implement it as
nvic_->set_pending(irq); this is the shared entry for all MMIO IRQs
(TIM/USART/EXTI).

Stm32f1Timer gains set_irq_callback (SysTick pattern); tick() raises on
UIF 0→1 edge when DIER.UIE is set. SoC wires TIM2 (kTim2Irqn=28). Add
unit tests (edge/UIE semantics) and TimerUifRoundtrip E2E (coordinator
Apb1 tick → handler entry → BX LR return). ctest 289/289.
Add Stm32f1Exti (IMR/EMR/RTSR/FTSR/SWIER/PR @ 0x40010400). GPIO edges
→ AFIO EXTICR routing (new exti_line_port getter) → IMR+RTSR/FTSR match
→ pending + raise NVIC (line→IRQ: 0-4=6-10, 5-9=23, 10-15=40). Reuses
the raise_irq channel from C2 (EXTI is its second consumer).

GPIO simulate_input now emits edge_signal so external input edges feed
EXTI. SoC wires gpioa/b/c edge_signal → EXTI → raise_irq. Tests: 6 unit
(registers/PR/routing/mask/edge-select) + ExtiGpioEdgeRoundtrip E2E.
ctest 296/296.
USART gains inject_rx(byte): single-slot RX buffer + SR.RXNE, DR read
returns the byte and clears RXNE (read=RX/write=TX shared). RXNEIE (CR1
bit5) + RXNE → raise USART1 (IRQ37) via the raise_irq channel — its third
consumer (TIM/EXTI/USART). TXEIE skipped (instant TX keeps TXE high →
would loop-raise; firmware polling TXE still works).

Tests: 4 unit (RXNE/DR/RXNEIE enabled+disabled) + UsartRxRoundtrip E2E
(inject_rx → handler reads DR via r4, which survives exception return
unlike auto-stacked r0-r3). ctest 301/301.
@Charliechen114514 Charliechen114514 merged commit 25046ab into main Jun 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant