[feature]: IRQ Handler Simulations#5
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.