In our example above, the function serint() is
the ISR.
In general, an ISR is responsible for:
- determining which hardware device requires servicing, if any
- performing some kind of servicing of that hardware (usually this is done by simply
reading and/or writing the hardware's registers)
- updating some data structures shared between the ISR and some
of the threads running in the application
- notifying the application that some kind of event has occurred
Depending on the complexity of the hardware device, the ISR,
and the application, some of the above steps may be omitted.
Note:
It isn't safe to use floating-point operations in Interrupt Service Routines.
Let's take a look at these steps in turn.