The I3C controller has two sets of five interrupt registers:
- Interrupt Enable Register (I3C_MST_IER)
- Interrupt Disable Register (I3C_MST_IDR)
- Interrupt Mask Register (I3C_MST_IMR)
- Interrupt Clear Register (I3C_MST_ICR)
- Interrupt Status Register (I3C_MST_ISR)
After reset, status (I3C_MST_ISR) and mask
(I3C_MST_IMR) registers both read zeroes, so all interrupts are disabled. CPU
handles interrupts by several typical operations:
- To activate an interrupt, interrupt enable register
(I3C_MST_IER) should be programmed with 0x1 on bit positions corresponding
to interrupts sources which should be signaled to CPU. This interrupt mask
is written to I3C_MST_IMR and defines which sources will be propagated.
- After receiving interrupt, I3C_MST_ISR should be read to
identify the interrupt source. Since I3C_MST_ISR is always updated by all
interrupt sources regardless of I3C_MST_IMR, the I3C_MST_ISR value should be
compared to the programmed mask (stored in software or read from
I3C_MST_IMR) as it can contain other flags which were not propagated.
Interrupt handler should clear flag which triggered interrupt in I3C_MST_ISR
by writing 0x1 to corresponding bits of I3C_MST_ICR. It is crucial for
correct interrupt source identification to read status, apply mask and clear
current interrupt flag before another (from the same or different source)
interrupt can occur, so these actions should be executed at the beginning of
the interrupt handler routine.
- If during operation additional interrupt sources need to be
enabled, clearing their flags prior to enabling is necessary to avoid false
signaling of events which occurred earlier.
- To disable interrupt source anytime during operation,
corresponding bit in interrupt disable register (I3C_MST_IDR) should be
programmed with 0x1, which in turn clears corresponding bit in I3C_MST_IMR,
disabling interrupt source.