Knock
STM32 EXTI Interrupt Handler Exercise
Task
A smart front door has a knock sensor. Knock once and the hall light comes on. Knock again and it goes off. Each knock is a short pulse on PA0. EXTI is the part of the chip that watches pins for a change of level. The given knock_init() makes each pulse raise a request on EXTI's line 0.
The core is the part of the chip that runs your code. An interrupt makes it pause main and run a function called a handler. Flip the hall light on PA5 from an interrupt, once per knock, for as long as the board runs: knock 1 -> light on; knock 2 -> light off; and so on Write line 0's handler, EXTI0_IRQHandler, which calls answer_knock(), and let line 0's requests reach the core. The registers and bit fields are on the Datasheet tab.
Circuit
Pass condition
Each knock flips PA5 once, and EXTI0_IRQHandler runs as an interrupt once per knock. Calling the handler from main does not count.
Notes
The knock sensor drives PA0 high for 1 ms per knock while your program runs. The given code stays as it is.